Skip to content

Commit a419eef

Browse files
committed
fix unarchive throwing due to prior edge state
1 parent 4620160 commit a419eef

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

api/paidAction/territoryUnarchive.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,15 @@ export async function perform ({ name, invoiceId, ...data }, { me, cost, tx }) {
3636
data.userId = me.id
3737

3838
if (sub.userId !== me.id) {
39-
await tx.territoryTransfer.create({ data: { subName: name, oldUserId: sub.userId, newUserId: me.id } })
40-
await tx.subSubscription.delete({ where: { userId_subName: { userId: sub.userId, subName: name } } })
39+
try {
40+
// XXX this will throw if this transfer has already happened
41+
// TODO: upsert this
42+
await tx.territoryTransfer.create({ data: { subName: name, oldUserId: sub.userId, newUserId: me.id } })
43+
// this will throw if the prior user has already unsubscribed
44+
await tx.subSubscription.delete({ where: { userId_subName: { userId: sub.userId, subName: name } } })
45+
} catch (e) {
46+
console.error(e)
47+
}
4148
}
4249

4350
await tx.subAct.create({

0 commit comments

Comments
 (0)