Skip to content

Commit

Permalink
fix invite and all emails that needs to check if user want to receive…
Browse files Browse the repository at this point in the history
… notifications
  • Loading branch information
alexanmtz committed Nov 20, 2024
1 parent 849db10 commit 7388bad
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 10 deletions.
9 changes: 6 additions & 3 deletions modules/orders/orderBuilds.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ module.exports = Promise.method(function orderBuilds(orderParameters) {
plan: orderParameters.plan
},
include: [
models.User,
{
association: models.Order.Plan,
include: [models.Plan.plan]
include: [models.Plan.plan],
}
]
}
Expand All @@ -37,9 +38,11 @@ module.exports = Promise.method(function orderBuilds(orderParameters) {
.then(orderCreated => {
return orderCreated.reload({
include: [
models.Task
models.Task,
models.User
]
}).then(order => {
const orderUser = order.User.dataValues
const taskTitle = order?.Task?.dataValues?.title || ''
if (orderParameters.customer_id && orderParameters.provider === 'stripe' && orderParameters.source_type === 'invoice-item') {
const unitAmount = (parseInt(orderParameters.amount) * 100 * 1.08).toFixed(0)
Expand Down Expand Up @@ -67,7 +70,7 @@ module.exports = Promise.method(function orderBuilds(orderParameters) {
}
}).then(invoiceItem => {
stripe.invoices.finalizeInvoice(invoice.id).then(finalizedInvoice => {
Sendmail.success({ email: orderParameters.email }, 'Invoice created', `An invoice has been created for the task: ${taskUrl}, you can pay it by clicking on the following link: ${finalizedInvoice.hosted_invoice_url}`)
Sendmail.success({ ...orderUser, email: orderParameters.email }, 'Invoice created', `An invoice has been created for the task: ${taskUrl}, you can pay it by clicking on the following link: ${finalizedInvoice.hosted_invoice_url}`)
return order.update(
{
source_id: invoice.id
Expand Down
2 changes: 1 addition & 1 deletion modules/tasks/requestAssignedUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const actionAssign = async (data) => {
`

SendMail.success(
{ email: taskOwner.email, language },
{ email: taskOwner.email, language, receiveNotifications: taskOwner.receiveNotifications},
i18n.__('mail.assigned.request.deny.subject'), body
)

Expand Down
4 changes: 2 additions & 2 deletions modules/tasks/taskClaim.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const sendConfirmationEmail = (task, user, comments) => {
})}`

return SendMail.success(
{ email: user.email, language },
{ email: user.email, language, receiveNotifications: user.receiveNotifications },
i18n.__('mail.issue.claim.request.subject'), body
)
}
Expand Down Expand Up @@ -55,7 +55,7 @@ const verifyIssueAndClaim = async (task, user, comments, token) => {
})}`

return SendMail.success(
{ email: taskUser.email, language },
{ email: taskUser.email, language, receiveNotifications: taskUser.receiveNotifications },
i18n.__('mail.issue.claim.confirmation.subject'), body
)
})
Expand Down
3 changes: 2 additions & 1 deletion modules/tasks/taskFunding.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ module.exports = Promise.method(function ({ id }, { comment, email, suggestedVal
const taskUrl = `${process.env.FRONTEND_HOST}/#/task/${task.id}`
const user = task.User.dataValues
const language = user.language || 'en'
const receiveNotifications = user.receiveNotifications
i18n.setLocale(language)
SendMail.success(
{ email, language },
{ email, language, receiveNotifications },
i18n.__('mail.funding.send.action', { username: username }),
`${i18n.__('mail.funding.send.message', {
title: task.title,
Expand Down
3 changes: 2 additions & 1 deletion modules/tasks/taskInvite.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ module.exports = Promise.method(function ({ id }, { message, email, name }) {
const taskUrl = `${process.env.FRONTEND_HOST}/#/task/${task.id}`
const user = task.User.dataValues
const language = user.language || 'en'
const receiveNotifications = user.receiveNotifications
i18n.setLocale(language)
SendMail.success(
{ email, language },
{ email, language, receiveNotifications },
i18n.__('mail.invite.send.action', { name: name }),
`${i18n.__('mail.invite.send.message', {
name: name,
Expand Down
3 changes: 2 additions & 1 deletion modules/tasks/taskReport.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ module.exports = Promise.method(function ({ id }, { task, reason, baseUrl }) {
.then(task => {
const taskUrl = `${process.env.FRONTEND_HOST}/#/task/${task.id}`
i18n.setLocale('en')
const receiveNotifications = task.User.receiveNotifications
SendMail.success(
{ email: reportEmail, language: 'en' },
{ email: reportEmail, language: 'en', receiveNotifications },
i18n.__('mail.report.send.action'),
`${i18n.__('mail.report.send.message', {
title: task.title,
Expand Down
2 changes: 1 addition & 1 deletion modules/team/requestJoinCoreTeam.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { joinTeamEmail } = require('../mail/constants')

module.exports = Promise.method(function requestJoinCoreTeam (params) {
SendMail.success(
{ email: joinTeamEmail, language: 'en' },
{ email: joinTeamEmail, language: 'en', receiveNotifications: true },
'Want to join Core Team',
'The user with the email ' + params.param.email + ' wants to join to Gitpay core tem')
})

0 comments on commit 7388bad

Please sign in to comment.