(
payload:
| GitHubTypes.IssueCommentCreatedEvent
| GitHubTypes.IssuesReopenedEvent
| GitHubTypes.IssuesClosedEvent
| GitHubTypes.IssuesOpenedEvent
)
| 94 | |
| 95 | // reusable: helper to identify channel and build thread external id |
| 96 | async function handleCommon( |
| 97 | payload: |
| 98 | | GitHubTypes.IssueCommentCreatedEvent |
| 99 | | GitHubTypes.IssuesReopenedEvent |
| 100 | | GitHubTypes.IssuesClosedEvent |
| 101 | | GitHubTypes.IssuesOpenedEvent |
| 102 | ) { |
| 103 | if (isFromOurBot(payload.sender)) { |
| 104 | throw new Error('skip messages from our bot'); |
| 105 | } |
| 106 | |
| 107 | if (!payload.installation) { |
| 108 | throw new Error('Missing installation data'); |
| 109 | } |
| 110 | // identify channel |
| 111 | const channel = await linenSdk.getChannel({ |
| 112 | integrationId: String(payload.installation.id), |
| 113 | }); |
| 114 | if (!channel) { |
| 115 | throw new Error('channel not found'); |
| 116 | } |
| 117 | |
| 118 | const externalThreadId = Serializer.buildExternalId( |
| 119 | channel.id, |
| 120 | payload.repository.owner.login, |
| 121 | payload.repository.name, |
| 122 | payload.issue.number |
| 123 | ); |
| 124 | return { channel, externalThreadId }; |
| 125 | } |
| 126 | |
| 127 | async function handleUser( |
| 128 | user: GitHubTypes.User, |
no test coverage detected