Skip to content

Commit 83a51a9

Browse files
fix(condo): DOMA-6834 added organizationId to ticket comment pushes (#3724)
1 parent 4efdc43 commit 83a51a9

File tree

5 files changed

+27
-11
lines changed

5 files changed

+27
-11
lines changed

apps/condo/domains/notification/constants/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ const MESSAGE_META = {
251251
commentId: { defaultValue: '', required: true },
252252
url: { defaultValue: '', required: true },
253253
residentId: { defaultValue: '', required: true },
254+
organizationId: { defaultValue: '', required: true },
254255
},
255256
},
256257
[METER_VERIFICATION_DATE_REMINDER_TYPE]: {

apps/condo/domains/ticket/tasks/sendTicketCommentNotifications.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ const { RESIDENT, STAFF } = require('@condo/domains/user/constants/common')
1717
const CREATE_RESIDENT_VISIBLE_COMMENT_BY_STAFF_TYPE = 'CREATE_RESIDENT_VISIBLE_COMMENT_BY_STAFF'
1818
const CREATE_RESIDENT_COMMENT_BY_RESIDENT_TYPE = 'CREATE_RESIDENT_COMMENT_BY_RESIDENT'
1919

20-
const detectTicketCommentEventTypes = async ({ operation, updatedItem, ticket }) => {
20+
const detectTicketCommentEventTypes = async ({ operation, createdById, commentType, ticket }) => {
2121
const isCreateOperation = operation === 'create'
22-
const createdById = get(updatedItem, 'createdBy')
2322
const canReadByResident = get(ticket, 'canReadByResident')
24-
const commentType = get(updatedItem, 'type')
2523
const isResidentComment = commentType === RESIDENT_COMMENT_TYPE
2624
const isCreateResidentCommentOperation = isCreateOperation && isResidentComment
2725

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

47-
const ticket = await Ticket.getOne(context, { id: updatedItem.ticket })
48-
const eventTypes = await detectTicketCommentEventTypes({ operation, updatedItem, ticket })
45+
const ticket = await Ticket.getOne(context, { id: ticketId })
46+
const eventTypes = await detectTicketCommentEventTypes({ operation, createdById, commentType, ticket })
4947
const clientId = get(ticket, 'client.id')
5048
const organizationId = get(ticket, 'organization.id')
5149
const propertyId = get(ticket, 'property.id')
@@ -82,12 +80,13 @@ const sendTicketCommentNotifications = async ({ operation, updatedItem }) => {
8280
ticketId: ticket.id,
8381
ticketNumber: ticket.number,
8482
userId: clientId,
85-
commentId: updatedItem.id,
83+
commentId,
8684
url: `${conf.SERVER_URL}/ticket/${ticket.id}`,
8785
residentId: get(resident, 'id', null),
86+
organizationId: organization.id,
8887
},
8988
},
90-
sender: updatedItem.sender,
89+
sender,
9190
organization: { id: organization.id },
9291
})
9392
}
@@ -108,12 +107,13 @@ const sendTicketCommentNotifications = async ({ operation, updatedItem }) => {
108107
ticketId: ticket.id,
109108
ticketNumber: ticket.number,
110109
userId: userId,
111-
commentId: updatedItem.id,
110+
commentId,
112111
url: `${conf.SERVER_URL}/ticket/${ticket.id}`,
113112
residentId: get(resident, 'id', null),
113+
organizationId: organization.id,
114114
},
115115
},
116-
sender: updatedItem.sender,
116+
sender,
117117
organization: { id: organization.id },
118118
})
119119
}

apps/condo/domains/ticket/utils/handlers.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,14 @@ const sendTicketNotifications = async (requestData) => {
267267
const sendTicketCommentNotifications = async (requestData) => {
268268
const { operation, updatedItem } = requestData
269269

270-
await sendTicketCommentNotificationsTask.delay({ operation, updatedItem })
270+
await sendTicketCommentNotificationsTask.delay({
271+
operation,
272+
ticketId: get(updatedItem, 'ticket'),
273+
createdById: get(updatedItem, 'createdBy'),
274+
commentId: updatedItem.id,
275+
commentType: get(updatedItem, 'type'),
276+
sender: updatedItem.sender,
277+
})
271278
}
272279

273280
const createOrUpdateTicketCommentsTime = async (context, updatedItem, userType) => {

apps/condo/schema.graphql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73710,6 +73710,10 @@ type Mutation {
7371073710
"residentId": {
7371173711
"defaultValue": "",
7371273712
"required": true
73713+
},
73714+
"organizationId": {
73715+
"defaultValue": "",
73716+
"required": true
7371373717
}
7371473718
}
7371573719
},

apps/condo/schema.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34433,6 +34433,10 @@ export type Mutation = {
3443334433
* "residentId": {
3443434434
* "defaultValue": "",
3443534435
* "required": true
34436+
* },
34437+
* "organizationId": {
34438+
* "defaultValue": "",
34439+
* "required": true
3443634440
* }
3443734441
* }
3443834442
* },

0 commit comments

Comments
 (0)