Challenge Overview
Don’t send unnecessary notifications in two cases.
Project Background
Topcoder Notifications Service is the backend service which handles notifications for Topcode Connect — client facing application of Topcoder.
There are some situations when users get notifications about posts which they shouldn't get notifications about. And we want to fix these cases.
Technology Stack
-
Node.js
-
PostgreSQL
-
Kafka
Code access
The work for this challenge has to be done in one repository:
- Notifications Service repo https://github.com/topcoder-platform/tc-notifications branch dev commit 3d20925732436ac271458acb57d87c73411eb861 or later.
- Config for local setup is provided on the forum.
- I recommend using the next guide on how to run Kafka locally. It also has instructions on how to send events locally, so you can use it for local testing.
Individual requirements
In this spec customer users or customers are the users who have only one role: “Topcoder User”.
1. Don't send notifications about private topics which users don't have access to
-
Recently we introduced private topics which cannot be seen by customers users. But so far notification service is not aware of this, and would still send notifications to customers about private topics and posts. We should fix it so customers don’t get notifications related to private topics and posts.
-
This should be done for all events related to topics and posts. Instead of creating a predefined list of exact events, I think we can treat all the events which have “topicId” property defined in their payload as events related to the topics. But just for your information, the next list of events is related at the moment to posts and topics
-
Private topics are the topics with the tag “MESSAGES”. We already have one place in tc-notifcations service where we check for topics tags for phases. You may use it for reference to understand “tags” structure, see the code. Also, you may check this Connect project which has private and public topics for reference (test user is provided on the forum).
-
See the example of “notifications.connect.project.topic.created” event https://codeshare.io/5DJ39p.
-
Private posts are the posts which belong to a private topic. See the example of “notifications.connect.project.post.created” event https://codeshare.io/Gq9y8M.
2. Don't send notifications about posts inside phases which users don't have access to
-
Customers don’t see phases with “draft” status in Connect app, see code.
-
But when we make posts in “draft” phases, customer users still got notifications about these posts even though they cannot see the related phases. We have to fix it, so customers don’t get notification related to posts in phases with “draft” status.
-
Events related to posts in phases have the same names as for regular posts. For this issue, we can treat event related to posts in phases if event payload has defined “topicId” and “postId” and tags contain “PHASE#123456”, where 123456 is a phase id. Note, that we already have code which detects such tag and extracts the phase id.
- As you would need to use the same code, extract it to a reusable method instead of copying it and repeating it. You may put it here. -
To check the status of the related phase you would have to load the phase data. Add one more service endpoint to the services. Check how getProject method is implemented to see how to get a token. Ednpoint for getting a phase is /v4/projects/${projectId}/phases/${phaseId}.
-
See the example of the “notifications.connect.project.post.created” event for a phase https://codeshare.io/2WJjeW
General requirements
-
All the changes have to be done inside tc-notifications/connect folder, as this folder contains code related to the connect notifications.
-
Keep the code clear. Create two methods for these two requirements called: getExcludedPrivatePostNotifications and getExcludeDraftPhasesNotifications, which should be used inside excludeNotifications method here. Note, that other methods that are used to exclude notifications, also used to include notifications here. But these two new methods would be only used to exclude notifications.
-
Lint should pass.
Verification guide
Create a brief verification guide. It should contain:
-
Any local setup steps which should be done, but are not covered by the readme.
-
Examples for KAFKA events to send for EACH event types which are affected by these changes: 6 examples for the first task and 4 examples for the second task.
Final Submission Guidelines
-
Patch to the Notifications Service branch dev.
-
Verification guide.