Function
handleDiscord
({
accountId,
syncFrom,
}: {
accountId: string;
syncFrom: Date;
})
Source from the content-addressed store, hash-verified
| 135 | } |
| 136 | |
| 137 | async function handleDiscord({ |
| 138 | accountId, |
| 139 | syncFrom, |
| 140 | }: { |
| 141 | accountId: string; |
| 142 | syncFrom: Date; |
| 143 | }) { |
| 144 | const auths = await prisma.discordAuthorizations.findFirst({ |
| 145 | where: { accountsId: accountId }, |
| 146 | orderBy: { createdAt: 'desc' }, |
| 147 | }); |
| 148 | if (auths) { |
| 149 | await prisma.discordAuthorizations.update({ |
| 150 | data: { |
| 151 | syncFrom, |
| 152 | }, |
| 153 | where: { id: auths.id }, |
| 154 | }); |
| 155 | } else { |
| 156 | await prisma.discordAuthorizations.create({ |
| 157 | data: { |
| 158 | accountsId: accountId, |
| 159 | accessToken: 'pending', |
| 160 | scope: 'pending', |
| 161 | syncFrom, |
| 162 | }, |
| 163 | }); |
| 164 | } |
| 165 | } |
Tested by
no test coverage detected