Description
Background
We would like to send a email notification to the Job Candidate when client has viewed they profile.
To indicate that client has viewed Job Candidate profile we would use the event when client has downloaded Job Candidate resume in TaaS App.
The resume URL comes from the DB and it just a third party URL. We don't know when someone clicks that URL and downloads the resume. So we would need so kind of a proxy endpoint which would trigger notification and redirect to resume dwonloading.
Task
-
Implement endpoint "GET /jobCandidates/:id/resume" which we could use to trigger notification and which would redirect/trigger resume downloading from URL which we have in DB
JobCandiate.resume
. -
Send email notification if endpoint "GET /jobCandidates/:id/resume" is called by the customer user:
- we treat the user as customer, if user doesn't have any other roles except of
Topcoder User
https://github.com/topcoder-platform/taas-apis/blob/feature/notifications-api/app-routes.js#L53 and if the user is not the one who is JobCandidate. (regular user who is JobCandidate also has onlyTopcoder User
role, so we have to make sure that it's not candidate downloads resume but another user). - to send email notification we has send Kafka Message to the topic
notifications.action.create
with the next payload https://gist.github.com/maxceem/bb2ad68d2f8a790f01e3326f9f8015eb. - inside data we have to pass: Job Name, Job Candidate user handle.
- email should be sent to the JobCandidate user
- we treat the user as customer, if user doesn't have any other roles except of
-
Update email template so it can render this type of notification with the text:
Hi {jobCandidateUserHanle}. Your resume for the job "{Job Name}" has been viewed by the client.
- type of notification:
taas.notification.job-candidate-resume-viewed
- type of notification:
-
We already have a special script to demo Email notifications https://github.com/topcoder-platform/taas-apis/tree/dev/scripts/demo-email-notifications. Run it and it would listen to the Kafka topic
notifications.action.create
and render emails with data from the Kafka message intoout
folder. -
Important: this notification should come only once for the Job Candidate. I guess the only way to make it only one time is add a new column to the JobCandidate model where we would track if this JobCandidate has been already viewed by the customer or no, like
viewedByCustomer
=true/false
. -
Update Postman/Swagger
-
Create migration script
-
Update ES mapping in both repositories. Update ES processor.
Branch to work
feature/notifications-api