| 65 | } |
| 66 | |
| 67 | async function findOrCreateLinenBot() { |
| 68 | let linenBot = await prisma.users.findUnique({ |
| 69 | where: { |
| 70 | externalUserId_accountsId: { |
| 71 | accountsId: config.linen.communityId, |
| 72 | externalUserId: config.linen.bot.externalId, |
| 73 | }, |
| 74 | }, |
| 75 | }); |
| 76 | if (!linenBot) { |
| 77 | linenBot = await prisma.users.create({ |
| 78 | data: { |
| 79 | isAdmin: false, |
| 80 | isBot: true, |
| 81 | accountsId: config.linen.communityId, |
| 82 | externalUserId: config.linen.bot.externalId, |
| 83 | displayName: config.linen.bot.displayName, |
| 84 | profileImageUrl: config.linen.squareLogo, |
| 85 | }, |
| 86 | }); |
| 87 | } |
| 88 | return linenBot; |
| 89 | } |
| 90 | |
| 91 | async function createThread({ |
| 92 | body, |