MCPcopy Index your code
hub / github.com/Linen-dev/linen.dev / handleCommon

Function handleCommon

packages/integration-github/src/inbound.ts:96–125  ·  view source on GitHub ↗
(
  payload:
    | GitHubTypes.IssueCommentCreatedEvent
    | GitHubTypes.IssuesReopenedEvent
    | GitHubTypes.IssuesClosedEvent
    | GitHubTypes.IssuesOpenedEvent
)

Source from the content-addressed store, hash-verified

94
95// reusable: helper to identify channel and build thread external id
96async 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
127async function handleUser(
128 user: GitHubTypes.User,

Callers 2

handleIssueFunction · 0.85

Calls 3

isFromOurBotFunction · 0.85
getChannelMethod · 0.80
buildExternalIdMethod · 0.80

Tested by

no test coverage detected