({
threadId,
integration,
}: {
threadId: string;
integration: channelsIntegration;
})
| 75 | } |
| 76 | |
| 77 | async function processNewThread({ |
| 78 | threadId, |
| 79 | integration, |
| 80 | }: { |
| 81 | threadId: string; |
| 82 | integration: channelsIntegration; |
| 83 | }) { |
| 84 | const thread = await linenSdk.getThread({ |
| 85 | channelId: integration.channelId, |
| 86 | threadId, |
| 87 | }); |
| 88 | |
| 89 | if (!thread) { |
| 90 | return 'ThreadNotFound'; |
| 91 | } |
| 92 | |
| 93 | if (!thread.messages.length) { |
| 94 | return 'ThreadNotFound'; |
| 95 | } |
| 96 | |
| 97 | if (thread.externalThreadId) { |
| 98 | return 'skip two-way sync due thread is not from linen'; |
| 99 | } |
| 100 | |
| 101 | // create issue |
| 102 | const newThread = await createThread({ |
| 103 | accessToken: integration.data.access_token, |
| 104 | description: thread.messages[0].body, |
| 105 | createAsUser: thread.messages[0].author?.displayName || 'linen-user', |
| 106 | displayIconUrl: thread.messages[0].author?.profileImageUrl || undefined, |
| 107 | title: thread.messages[0].body, |
| 108 | teamId: integration.externalId, |
| 109 | }); |
| 110 | |
| 111 | if (newThread?.id) { |
| 112 | await linenSdk.updateThread({ |
| 113 | externalThreadId: newThread.id, |
| 114 | threadId, |
| 115 | channelId: integration.channelId, |
| 116 | }); |
| 117 | } |
| 118 | |
| 119 | return `issue created`; |
| 120 | } |
| 121 | |
| 122 | async function processThreadUpdate({ |
| 123 | threadId, |
nothing calls this directly
no test coverage detected