Subscribe unarchiver to unarchived territory (#1839)
* enhance: subscribe unarchiver to unarchived territory * use upsert and fix #1517 --------- Co-authored-by: Keyan <34140557+huumn@users.noreply.github.com> Co-authored-by: k00b <k00b@stacker.news>
This commit is contained in:
		
							parent
							
								
									ca7726fda5
								
							
						
					
					
						commit
						47faef872d
					
				| @ -36,6 +36,7 @@ export async function perform ({ name, invoiceId, ...data }, { me, cost, tx }) { | ||||
| 
 | ||||
|   if (sub.userId !== me.id) { | ||||
|     await tx.territoryTransfer.create({ data: { subName: name, oldUserId: sub.userId, newUserId: me.id } }) | ||||
|     await tx.subSubscription.delete({ where: { userId_subName: { userId: sub.userId, subName: name } } }) | ||||
|   } | ||||
| 
 | ||||
|   await tx.subAct.create({ | ||||
| @ -47,6 +48,23 @@ export async function perform ({ name, invoiceId, ...data }, { me, cost, tx }) { | ||||
|     } | ||||
|   }) | ||||
| 
 | ||||
|   await tx.subSubscription.upsert({ | ||||
|     where: { | ||||
|       userId_subName: { | ||||
|         userId: me.id, | ||||
|         subName: name | ||||
|       } | ||||
|     }, | ||||
|     update: { | ||||
|       userId: me.id, | ||||
|       subName: name | ||||
|     }, | ||||
|     create: { | ||||
|       userId: me.id, | ||||
|       subName: name | ||||
|     } | ||||
|   }) | ||||
| 
 | ||||
|   return await tx.sub.update({ | ||||
|     data, | ||||
|     // optimistic concurrency control
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user