({
messageId,
integration,
}: {
messageId: string;
integration: channelsIntegration;
})
| 31 | } |
| 32 | |
| 33 | async function processNewMessage({ |
| 34 | messageId, |
| 35 | integration, |
| 36 | }: { |
| 37 | messageId: string; |
| 38 | integration: channelsIntegration; |
| 39 | }) { |
| 40 | const message = await linenSdk.getMessage({ |
| 41 | messageId, |
| 42 | }); |
| 43 | |
| 44 | if (!message) { |
| 45 | return 'MessageNotFound'; |
| 46 | } |
| 47 | |
| 48 | if (!message.threadId) { |
| 49 | return 'ThreadNotFound'; |
| 50 | } |
| 51 | |
| 52 | const thread = await linenSdk.getThread({ |
| 53 | channelId: message.channelId, |
| 54 | threadId: message.threadId, |
| 55 | }); |
| 56 | |
| 57 | if (!thread || !thread.externalThreadId) { |
| 58 | return 'thread not found'; |
| 59 | } |
| 60 | |
| 61 | if (message.externalMessageId) { |
| 62 | return 'skip two-way sync due message is not from linen'; |
| 63 | } |
| 64 | |
| 65 | // create comment |
| 66 | await createMessage({ |
| 67 | accessToken: integration.data.access_token, |
| 68 | body: message.body, |
| 69 | createAsUser: message.author?.displayName || 'linen-user', |
| 70 | issueId: thread.externalThreadId, |
| 71 | displayIconUrl: message.author?.profileImageUrl || undefined, |
| 72 | }); |
| 73 | |
| 74 | return `issue commented`; |
| 75 | } |
| 76 | |
| 77 | async function processNewThread({ |
| 78 | threadId, |
nothing calls this directly
no test coverage detected