|
| 1 | +import * as listener from '../listeners' |
1 | 2 | import { Handler } from './typings'
|
2 | 3 |
|
3 |
| -export const handleNewIssue: Handler<'github:issueOpened'> = async ({ client, ctx }, event): Promise<void> => { |
| 4 | +export const handleNewIssue: Handler<'github:issueOpened'> = async (props, event): Promise<void> => { |
4 | 5 | const githubIssue = event.payload
|
5 | 6 |
|
6 | 7 | console.info('Received GitHub issue', githubIssue)
|
7 | 8 |
|
8 |
| - const { output } = await client.callAction({ |
9 |
| - type: 'linear:createIssue', |
10 |
| - input: { |
11 |
| - title: githubIssue.title, |
12 |
| - description: githubIssue.content ?? 'No content...', |
13 |
| - teamName: 'Cloud Services', |
14 |
| - labels: ['origin/github'], |
15 |
| - }, |
16 |
| - }) |
17 |
| - |
18 |
| - const { issue } = output |
19 |
| - |
20 |
| - const { conversation } = await client.getOrCreateConversation({ |
21 |
| - integrationName: 'linear', |
22 |
| - channel: 'issue', |
23 |
| - tags: { |
24 |
| - ['linear:id']: issue.id, |
25 |
| - }, |
26 |
| - }) |
27 |
| - |
28 |
| - const issueUrl = `https://github.com/${githubIssue.repositoryOwner}/${githubIssue.repositoryName}/issues/${githubIssue.number}` |
| 9 | + const message = ['The following issue was just created in GitHub:', githubIssue.title, githubIssue.content].join('\n') |
29 | 10 |
|
30 |
| - await client.createMessage({ |
| 11 | + await listener.notifyListeners(props, { |
31 | 12 | type: 'text',
|
32 |
| - conversationId: conversation.id, |
33 |
| - userId: ctx.botId, |
34 |
| - tags: {}, |
35 | 13 | payload: {
|
36 |
| - text: `Automatically created from GitHub issue: ${issueUrl}`, |
| 14 | + text: message, |
37 | 15 | },
|
38 | 16 | })
|
39 | 17 | }
|
0 commit comments