Skip to content
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

fix(condo): DOMA-6834 added organizationId to ticket comment pushes #3724

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/condo/domains/notification/constants/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ const MESSAGE_META = {
commentId: { defaultValue: '', required: true },
url: { defaultValue: '', required: true },
residentId: { defaultValue: '', required: true },
organizationId: { defaultValue: '', required: true },
},
},
[METER_VERIFICATION_DATE_REMINDER_TYPE]: {
Expand Down
20 changes: 10 additions & 10 deletions apps/condo/domains/ticket/tasks/sendTicketCommentNotifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@ const { RESIDENT, STAFF } = require('@condo/domains/user/constants/common')
const CREATE_RESIDENT_VISIBLE_COMMENT_BY_STAFF_TYPE = 'CREATE_RESIDENT_VISIBLE_COMMENT_BY_STAFF'
const CREATE_RESIDENT_COMMENT_BY_RESIDENT_TYPE = 'CREATE_RESIDENT_COMMENT_BY_RESIDENT'

const detectTicketCommentEventTypes = async ({ operation, updatedItem, ticket }) => {
const detectTicketCommentEventTypes = async ({ operation, createdById, commentType, ticket }) => {
const isCreateOperation = operation === 'create'
const createdById = get(updatedItem, 'createdBy')
const canReadByResident = get(ticket, 'canReadByResident')
const commentType = get(updatedItem, 'type')
const isResidentComment = commentType === RESIDENT_COMMENT_TYPE
const isCreateResidentCommentOperation = isCreateOperation && isResidentComment

Expand All @@ -41,11 +39,11 @@ const detectTicketCommentEventTypes = async ({ operation, updatedItem, ticket })
/**
* Sends notifications after ticket comment created
*/
const sendTicketCommentNotifications = async ({ operation, updatedItem }) => {
const sendTicketCommentNotifications = async ({ operation, ticketId, createdById, commentId, commentType, sender }) => {
const { keystone: context } = await getSchemaCtx('TicketComment')

const ticket = await Ticket.getOne(context, { id: updatedItem.ticket })
const eventTypes = await detectTicketCommentEventTypes({ operation, updatedItem, ticket })
const ticket = await Ticket.getOne(context, { id: ticketId })
const eventTypes = await detectTicketCommentEventTypes({ operation, createdById, commentType, ticket })
const clientId = get(ticket, 'client.id')
const organizationId = get(ticket, 'organization.id')
const propertyId = get(ticket, 'property.id')
Expand Down Expand Up @@ -82,12 +80,13 @@ const sendTicketCommentNotifications = async ({ operation, updatedItem }) => {
ticketId: ticket.id,
ticketNumber: ticket.number,
userId: clientId,
commentId: updatedItem.id,
commentId,
url: `${conf.SERVER_URL}/ticket/${ticket.id}`,
residentId: get(resident, 'id', null),
organizationId: organization.id,
},
},
sender: updatedItem.sender,
sender,
organization: { id: organization.id },
})
}
Expand All @@ -108,12 +107,13 @@ const sendTicketCommentNotifications = async ({ operation, updatedItem }) => {
ticketId: ticket.id,
ticketNumber: ticket.number,
userId: userId,
commentId: updatedItem.id,
commentId,
url: `${conf.SERVER_URL}/ticket/${ticket.id}`,
residentId: get(resident, 'id', null),
organizationId: organization.id,
},
},
sender: updatedItem.sender,
sender,
organization: { id: organization.id },
})
}
Expand Down
9 changes: 8 additions & 1 deletion apps/condo/domains/ticket/utils/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,14 @@ const sendTicketNotifications = async (requestData) => {
const sendTicketCommentNotifications = async (requestData) => {
const { operation, updatedItem } = requestData

await sendTicketCommentNotificationsTask.delay({ operation, updatedItem })
await sendTicketCommentNotificationsTask.delay({
operation,
ticketId: get(updatedItem, 'ticket'),
createdById: get(updatedItem, 'createdBy'),
commentId: updatedItem.id,
commentType: get(updatedItem, 'type'),
sender: updatedItem.sender,
})
}

const createOrUpdateTicketCommentsTime = async (context, updatedItem, userType) => {
Expand Down
4 changes: 4 additions & 0 deletions apps/condo/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -73710,6 +73710,10 @@ type Mutation {
"residentId": {
"defaultValue": "",
"required": true
},
"organizationId": {
"defaultValue": "",
"required": true
}
}
},
Expand Down
4 changes: 4 additions & 0 deletions apps/condo/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34433,6 +34433,10 @@ export type Mutation = {
* "residentId": {
* "defaultValue": "",
* "required": true
* },
* "organizationId": {
* "defaultValue": "",
* "required": true
* }
* }
* },
Expand Down
Loading