(
{ channelId, messageId, threadId, id, event }: TwoWaySyncType,
logger: Logger
)
| 16 | } |
| 17 | |
| 18 | async function twoWaySyncJob( |
| 19 | { channelId, messageId, threadId, id, event }: TwoWaySyncType, |
| 20 | logger: Logger |
| 21 | ) { |
| 22 | logger.info({ event }); |
| 23 | |
| 24 | const channel = await prisma.channels.findFirst({ |
| 25 | where: { |
| 26 | id: channelId, |
| 27 | }, |
| 28 | include: { |
| 29 | account: { |
| 30 | include: { slackAuthorizations: true, discordAuthorizations: true }, |
| 31 | }, |
| 32 | channelsIntegration: true, |
| 33 | }, |
| 34 | }); |
| 35 | |
| 36 | if (!channel) { |
| 37 | return 'channel not found'; |
| 38 | } |
| 39 | if (!channel.account) { |
| 40 | return 'account not found'; |
| 41 | } |
| 42 | |
| 43 | // integration by channel |
| 44 | if (channel.channelsIntegration.length) { |
| 45 | for (const integration of channel.channelsIntegration) { |
| 46 | if (integration.type === 'GITHUB') { |
| 47 | return await processGithubIntegration({ |
| 48 | channelId, |
| 49 | messageId, |
| 50 | threadId, |
| 51 | event, |
| 52 | integration, |
| 53 | id, |
| 54 | }); |
| 55 | } |
| 56 | if (integration.type === 'EMAIL') { |
| 57 | return await processEmailIntegration({ |
| 58 | channelId, |
| 59 | messageId, |
| 60 | threadId, |
| 61 | event, |
| 62 | integration, |
| 63 | id, |
| 64 | }); |
| 65 | } |
| 66 | if (integration.type === 'LINEAR') { |
| 67 | return await processLinearIntegration({ |
| 68 | channelId, |
| 69 | messageId, |
| 70 | threadId, |
| 71 | event, |
| 72 | integration, |
| 73 | id, |
| 74 | }); |
| 75 | } |
no test coverage detected