(id: string)
| 18 | ].join('\n\n'); |
| 19 | |
| 20 | export async function notifyFeed(id: string) { |
| 21 | const newAccount = await prisma.accounts.findFirst({ |
| 22 | select: { slackDomain: true, description: true, name: true }, |
| 23 | where: { id }, |
| 24 | }); |
| 25 | if (!newAccount?.description) { |
| 26 | return; |
| 27 | } |
| 28 | |
| 29 | const linenBot = await findOrCreateLinenBot(); |
| 30 | const channel = await findOrCreateFeedChannel(); |
| 31 | const body = messageTemplate({ |
| 32 | name: newAccount.name, |
| 33 | description: newAccount.description, |
| 34 | slackDomain: newAccount.slackDomain, |
| 35 | }); |
| 36 | |
| 37 | await createThread({ |
| 38 | body, |
| 39 | channelId: channel.id, |
| 40 | linenBotId: linenBot.id, |
| 41 | }); |
| 42 | } |
| 43 | |
| 44 | async function findOrCreateFeedChannel() { |
| 45 | let channel = await prisma.channels.findUnique({ |
no test coverage detected