Key Information

Register
Submit
The challenge is finished.

Challenge Overview

In a recent challenge series we have built a notifications service for the Topcoder Connect platform. It supports only web notifications (ie API) and in this challenge we want to add support for email notifications. 
Here is the overall diagram of what we want to achieve 


In this challenge we will update two services: tc-notifications (to send email events to the bus) and tc-message-service (to handle incomming emails).
Notification service updates
We'll handle only three types of notifications in this challenge: notifications.connect.project.topic.created, notifications.connect.project.post.created and notifications.connect.project.post.mention . When a new notification is created notification service shuld send the email event to the bus api. The event body will have the following structure
{
"type": "email.project.created",//depends on the notification type
"message": "{ \"data\": { \"name\": \"full user name\",\"handle\": \"user handle\",\"topicTitle\": \"topic title\",\"post\": \"post content\", \"date\": \"timestamp\", \"projectName\": \"project name\" }, \"recipients\": [\"email address for the target user\"], \"replyTo\" : \"replyToAddress\"  }"
}
To get the user details, call Topcoder members api (with the admin token attached in the forums). In case the notification is for user mention, add a configurable email address to the recipients list (for example mentions@topcoder.com). Reply to address format will be "configurable+{token}@domain.com". Fill in the token placeholder as a jwt token (encoded with base64) that contains post id, topic id, userId, and userEmail. Use the existing "authSecret" config variable to sign the token.

Message service updates
Message service will handle incomming emails (replies to posts). Create a webhook in Sendgrid and add an endpoint to the message service to receive the emails. When a new email is received, first check the 'to' field to extract the jwt token. Parse and validate the token and get postId, topicId, userId, userEmail and verify that userEmail is the same as incomming email address. On successful validation, create a new post using the existing services. In case of error, return 500 response code to Sendgrid - it will take care or retrying failed messages. Each handled email should be persisted to database for audit purposes. Create an 'email_log' table in the message database with these columns: id, from address, to address, cc addresses, subject, created at, updated at, raw text, user id, topic id, post id, token, status. 

General requirements
Add detailed logging to all updated code with debug/info levels

Environment setup
To work on this challenge you will need to set up the following services locally:
  • Cloud Karafka - create an account and a free Kafka instance
  • tc-bus-api - configure it so it uses your Kafka instance   
  • tc-email-service - configure it so it uses your Kafka instance. Create your Sendgrid instance with trial account    
  • tc-message-service - for local development and configure it so it uses your local tc-bus-api   (use postman for sending test messages)
  • tc-notifications - for local development and configure it so it is using your local Kafka instance
Use develop branch for all services except for message service where you should use feature/discourse-migration branch.
 


Final Submission Guidelines

Submit updated code to notifications and message service
Submit a deployment/verification guide
Submit a short demo video (unlisted Youtube link)

ELIGIBLE EVENTS:

2018 Topcoder(R) Open

REVIEW STYLE:

Final Review:

Community Review Board

Approval:

User Sign-Off

SHARE:

ID: 30063539