({
channelId,
messageId,
threadId,
imitationId,
mentions = [],
mentionNodes = [],
communityId,
message,
userId,
isLinenMessage,
}: NewMessageEvent)
| 29 | }; |
| 30 | |
| 31 | export async function eventNewMessage({ |
| 32 | channelId, |
| 33 | messageId, |
| 34 | threadId, |
| 35 | imitationId, |
| 36 | mentions = [], |
| 37 | mentionNodes = [], |
| 38 | communityId, |
| 39 | message, |
| 40 | userId, |
| 41 | isLinenMessage, |
| 42 | }: NewMessageEvent) { |
| 43 | const event = { |
| 44 | channelId, |
| 45 | messageId, |
| 46 | threadId, |
| 47 | imitationId, |
| 48 | isThread: false, |
| 49 | isReply: true, |
| 50 | message, |
| 51 | }; |
| 52 | |
| 53 | const channel = await ChannelsService.getChannelAndMembersWithAuth(channelId); |
| 54 | |
| 55 | const promises: Promise<any>[] = [ |
| 56 | eventNewMentions({ |
| 57 | mentions, |
| 58 | mentionNodes, |
| 59 | channelId, |
| 60 | threadId, |
| 61 | authorId: userId, |
| 62 | }), |
| 63 | ...resolvePush({ channel, userId, event, communityId }), |
| 64 | ]; |
| 65 | |
| 66 | if (isLinenMessage) { |
| 67 | promises.push( |
| 68 | ...[ |
| 69 | createNotificationJob(messageId, { |
| 70 | ...event, |
| 71 | communityId, |
| 72 | mentions, |
| 73 | mentionNodes, |
| 74 | }), |
| 75 | createTwoWaySyncJob({ ...event, event: 'newMessage', id: messageId }), |
| 76 | matrixNewMessage(event), |
| 77 | ThreadsServices.updateMetrics({ messageId, threadId }), |
| 78 | UserThreadStatusService.markAsUnread(threadId, userId), |
| 79 | UserThreadStatusService.markAsUnmutedForMentionedUsers( |
| 80 | threadId, |
| 81 | mentions.map((mention) => mention.usersId) |
| 82 | ), |
| 83 | ] |
| 84 | ); |
| 85 | if (channel?.type === ChannelType.DM) { |
| 86 | promises.push( |
| 87 | ChannelsService.unarchiveChannel({ channelId: channel.id }) |
| 88 | ); |
no test coverage detected