Skip to content

Support different "originators" of member invitations #623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
maxceem opened this issue Feb 9, 2021 · 4 comments
Closed

Support different "originators" of member invitations #623

maxceem opened this issue Feb 9, 2021 · 4 comments
Milestone

Comments

@maxceem
Copy link
Contributor

maxceem commented Feb 9, 2021

Context

We have functionality to invite members to the Topcoder Projects inside Connect App which looks like this. When users are invited they also receive a email notifications with links to accept or decline invitation as on screenshot. This email is styled for Connect App, and links to decline and accept invitation lead to Connect App. At the moment we are implementing functionality to invite members to the same Topcoder Projects inside another application called TaaS App. It uses the same Projects API to invite members. As a result user get the same emails with links to Connect App.

General Task

We have to update Projects API and related services so when invited members we can indicate which application invited members so users would get different email notifications with links and styles for the corresponding application Connect App or TaaS App.

Current Workflow

  • User creates invite in Projects API via endpoint "POST /v5/projects/:projectId/invites"
  • Projects API sends 2 Kafka Events:
    • Event for Notifications Service "connect.notification.project.member.invite.created" (source code) - for each invite by email or by handle.
    • Event for Email Service "connect.notification.email.project.member.invite.created" (source code) - only if user doesn't exist yet and is invited by email.
  • Notifications Service listens to this Kafka Event "connect.notification.project.member.invite.created" and if email notifications are enabled for the user it send another Kafka Event "connect.notification.email.project.notifications.generic" to the Email Service (source code).
  • Email Service consumes these events "connect.notification.email.project.member.invite.created" and "connect.notification.email.project.notifications.generic" and sends email using Sendgrid.
  • Email is send using a template that we put into the Sendgrid config. This template we generate using code inside Notification Service, see its README.

Task Details

  1. Update endpoint "POST /v5/projects/:projectId/invites" so it accepts an optional query param "originator". This param would define which service is invited user.
  2. Pass this param inside payloads of the Kafka Events so we can know the value inside Email Service and it should pass this value to the Sendgrid
  3. Update code inside https://github.com/topcoder-platform/tc-notifications/tree/dev/emails so we can have multiple folders there for each "originator". For now we would have folders "connect" and "taas". Put all the current templates into "connect". And create a copy of the same templates for "taas". Iniside "taas" folder only keep templates for invites, and remove all other templates as we don't send emails for "taas" in other cases. Update the code of invite templates for "taas" so it all the texts says "TaaS App" instead of "Connect". And all the links lead to the TaaS App, instead of the Connect App.
  • Update template generation logic. The final template which is generate should include templates for Connect App and for TaaS App inside, because we are putting this template into Sendgrid in one place. This final template should generate email for Connect App or TaaS App based on the value of the "originator" which is send from Email Service to Sendgrid.
@nkumar-topcoder
Copy link
Contributor

cc: @RishiRajSahu @vikasrohit

@RishiRajSahu
Copy link
Contributor

@maxceem looks good to me we are not much altering the flow except the new optional param originator, only one question

  • Do need to create separate template ? I guess we can simply put if condition like we do for ref-codes to send different mails wrt originator.

@maxceem
Copy link
Contributor Author

maxceem commented Feb 10, 2021

Do need to create separate template ? I guess we can simply put if condition like we do for ref-codes to send different mails wrt originator.

@RishiRajSahu on the one hand it would be technically easier. But I can see many places which has to be updated depend on the originator, see screenshot below:

  • in TaaS App instead of Project we call it Team
  • we have to update "Connect" to "TaaS" everywhere together with the description
  • we might want to update or remove Notification Settings link

image

So to update all these places we would have put many conditions across the templates to check if it's TaaS or Connect app. And if tomorrow we add the 3rd application, these conditions would become even more complex.

So to make the logic general and straightforward I suggest create folders per each originator. So template would be generated per each originator separately.

But, at the end all these templates would be combined into one single template which we add to the Sendgrid, which would look like this:

{{if originator === "TaaS"}}
{{include tempaltes/taas.html}}
{{elseif originator === "Connect"}}
{{include tempaltes/connect.html}}

@maxceem
Copy link
Contributor Author

maxceem commented Mar 16, 2021

The requirements in TaaS App have been changed, so we don't need this anymore.
So closing this.

@maxceem maxceem closed this as completed Mar 16, 2021
@drasticdpk drasticdpk added this to the 3.4.0 milestone May 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants