-
Notifications
You must be signed in to change notification settings - Fork 116
feat: add email for recruiter rejected candidate match #3273
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -233,6 +233,27 @@ export const notifyRecruiterCandidateMatchAccepted = async ({ | |||||
| } | ||||||
| }; | ||||||
|
|
||||||
| export const notifyRecruiterCandidateMatchRejected = async ({ | ||||||
| logger, | ||||||
| data, | ||||||
| }: { | ||||||
| logger: FastifyBaseLogger; | ||||||
| data: ChangeObject<OpportunityMatch>; | ||||||
| }) => { | ||||||
| const message = new CandidateRejectedOpportunityMessage({ | ||||||
| opportunityId: data.opportunityId, | ||||||
| userId: data.userId, | ||||||
| createdAt: getSecondsTimestamp(data.createdAt), | ||||||
| updatedAt: getSecondsTimestamp(data.updatedAt), | ||||||
| }); | ||||||
|
|
||||||
| await triggerTypedEvent( | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Think this could be here?
Suggested change
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nope it's not needed. it's automatically infer the type from the topic name provided as argument
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah ok maybe just the notification one that prefers it |
||||||
| logger, | ||||||
| 'api.v1.recruiter-rejected-candidate-match', | ||||||
| message, | ||||||
| ); | ||||||
| }; | ||||||
|
|
||||||
| export const notifyCandidateOpportunityMatchRejected = async ({ | ||||||
| con, | ||||||
| logger, | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| import { TypedWorker } from './worker'; | ||
| import { CandidateRejectedOpportunityMessage } from '@dailydotdev/schema'; | ||
| import { User } from '../entity'; | ||
| import { sendEmail, baseNotificationEmailData } from '../common'; | ||
| import { isSubscribedToNotificationType } from './notifications/utils'; | ||
| import { NotificationChannel, NotificationType } from '../notifications/common'; | ||
|
|
||
| const worker: TypedWorker<'api.v1.recruiter-rejected-candidate-match'> = { | ||
| subscription: 'api.recruiter-rejected-candidate-match-email', | ||
| handler: async ({ data }, con, logger): Promise<void> => { | ||
| const { userId, opportunityId } = data; | ||
|
|
||
| try { | ||
| const user = await con.getRepository(User).findOne({ | ||
| where: { id: userId }, | ||
| select: ['id', 'email', 'notificationFlags'], | ||
| }); | ||
|
|
||
| if (!user) { | ||
| logger.warn( | ||
| { userId, opportunityId }, | ||
| 'User not found for recruiter rejected candidate email', | ||
| ); | ||
| return; | ||
| } | ||
|
|
||
| if (!user.email) { | ||
| logger.warn( | ||
| { userId, opportunityId }, | ||
| 'User has no email for recruiter rejected candidate email', | ||
| ); | ||
| return; | ||
| } | ||
|
|
||
| const shouldReceiveEmail = isSubscribedToNotificationType( | ||
| user.notificationFlags, | ||
| NotificationType.NewOpportunityMatch, | ||
| NotificationChannel.Email, | ||
| ); | ||
|
|
||
| if (!shouldReceiveEmail) { | ||
| logger.info( | ||
| { userId, opportunityId }, | ||
| 'User is not subscribed to recruiter rejected opportunity emails', | ||
| ); | ||
| return; | ||
| } | ||
|
|
||
| await sendEmail({ | ||
| ...baseNotificationEmailData, | ||
| reply_to: 'ido@daily.dev', | ||
| transactional_message_id: '85', | ||
| message_data: { | ||
| opportunity_id: opportunityId, | ||
| }, | ||
| identifiers: { | ||
| id: user.id, | ||
| }, | ||
| to: user.email, | ||
| }); | ||
|
Comment on lines
+49
to
+60
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you use this direct one and not the notification worker way?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. because we don't trigger an actual notification. just email this was my understanding
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. with a notification we can't ask for feedback
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes but you just null the notification? isn't it better to uniform instead of duplicate?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah thinks you're right I thought we could individually turn off
But guess we only added that to email, we should maybe do that? For now this is fine then. (just hate duplication of this function)
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i'll try to find a way to streamline it, out of this PR |
||
| } catch (_err) { | ||
| const err = _err as Error; | ||
| logger.error( | ||
| { err, userId, opportunityId }, | ||
| 'failed to send recruiter rejected candidate email', | ||
| ); | ||
| throw err; | ||
| } | ||
| }, | ||
| parseMessage: (message) => | ||
| CandidateRejectedOpportunityMessage.fromBinary(message.data), | ||
| }; | ||
|
|
||
| export default worker; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i pushed a change to main earlier, didn't notice we test for the title. i actually looked for it but missed this place. so i'm fixing it here