Skip to content

Commit 47faef8

Browse files
Soxasorahuumn
andauthored
Subscribe unarchiver to unarchived territory (#1839)
* enhance: subscribe unarchiver to unarchived territory * use upsert and fix #1517 --------- Co-authored-by: Keyan <[email protected]> Co-authored-by: k00b <[email protected]>
1 parent ca7726f commit 47faef8

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

api/paidAction/territoryUnarchive.js

+18
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export async function perform ({ name, invoiceId, ...data }, { me, cost, tx }) {
3636

3737
if (sub.userId !== me.id) {
3838
await tx.territoryTransfer.create({ data: { subName: name, oldUserId: sub.userId, newUserId: me.id } })
39+
await tx.subSubscription.delete({ where: { userId_subName: { userId: sub.userId, subName: name } } })
3940
}
4041

4142
await tx.subAct.create({
@@ -47,6 +48,23 @@ export async function perform ({ name, invoiceId, ...data }, { me, cost, tx }) {
4748
}
4849
})
4950

51+
await tx.subSubscription.upsert({
52+
where: {
53+
userId_subName: {
54+
userId: me.id,
55+
subName: name
56+
}
57+
},
58+
update: {
59+
userId: me.id,
60+
subName: name
61+
},
62+
create: {
63+
userId: me.id,
64+
subName: name
65+
}
66+
})
67+
5068
return await tx.sub.update({
5169
data,
5270
// optimistic concurrency control

0 commit comments

Comments
 (0)