(externalId: string[], botId: number)
| 50 | } |
| 51 | |
| 52 | export async function checkIntegrations(externalId: string[], botId: number) { |
| 53 | return await prisma.accounts |
| 54 | .findMany({ |
| 55 | select: { discordAuthorizations: true, discordServerId: true }, |
| 56 | where: { discordServerId: { in: externalId } }, |
| 57 | }) |
| 58 | .then((accounts) => { |
| 59 | return accounts.filter((account) => { |
| 60 | const sortByAsc = account.discordAuthorizations.sort( |
| 61 | (a, b) => a.createdAt.getTime() - b.createdAt.getTime() |
| 62 | ); |
| 63 | const lastAuth = sortByAsc.pop(); |
| 64 | if (lastAuth) { |
| 65 | if (lastAuth.scope === `linen-bot-${botId}`) { |
| 66 | return true; |
| 67 | } else if (botId === 1 && !lastAuth.customBot) { |
| 68 | return true; |
| 69 | } |
| 70 | } |
| 71 | }); |
| 72 | }); |
| 73 | } |
| 74 | |
| 75 | export async function findChannelById(id: string) { |
| 76 | return await prisma.channels.findUnique({ where: { id } }); |
no outgoing calls
no test coverage detected