fix: khách mời join vào tour thông qua link mời
This commit is contained in:
Vendored
+10
-9
@@ -1419,9 +1419,17 @@ let TourController = class TourController {
|
||||
this.cacheManager.del(`/api/v1/tours/${invitation.tourId}`),
|
||||
this.cacheManager.del(`/api/v1/tours/${invitation.tourId}/public`),
|
||||
this.cacheManager.del(`/api/v1/tours/explore`),
|
||||
this.cacheManager.del(`user-role:${userId}:${invitation.tourId}`),
|
||||
]);
|
||||
return { success: true, tourId: invitation.tourId, message: 'Bạn đã là thành viên của tour này.' };
|
||||
return { success: true, tourId: invitation.tourId, message: 'Bạn đã là thành viên của tour này.', shouldRefresh: true };
|
||||
}
|
||||
await Promise.all([
|
||||
this.cacheManager.del(`user-role:${userId}:${invitation.tourId}`),
|
||||
this.cacheManager.del(invitation.tourId),
|
||||
this.cacheManager.del(`/api/v1/tours/${invitation.tourId}`),
|
||||
this.cacheManager.del(`/api/v1/tours/${invitation.tourId}/public`),
|
||||
this.cacheManager.del(`/api/v1/tours/explore`),
|
||||
]);
|
||||
await this.prisma.$transaction([
|
||||
this.prisma.tourParticipant.create({
|
||||
data: {
|
||||
@@ -1434,14 +1442,7 @@ let TourController = class TourController {
|
||||
where: { id: invitation.id }
|
||||
})
|
||||
]);
|
||||
await Promise.all([
|
||||
this.cacheManager.del(invitation.tourId),
|
||||
this.cacheManager.del(`/api/v1/tours/${invitation.tourId}`),
|
||||
this.cacheManager.del(`/api/v1/tours/${invitation.tourId}/public`),
|
||||
this.cacheManager.del(`/api/v1/tours/explore`),
|
||||
this.cacheManager.del(`user-role:${userId}:${invitation.tourId}`),
|
||||
]);
|
||||
return { success: true, tourId: invitation.tourId, message: `Bạn đã gia nhập hành trình "${invitation.tour.title}"!` };
|
||||
return { success: true, tourId: invitation.tourId, message: `Bạn đã gia nhập hành trình "${invitation.tour.title}"!`, shouldRefresh: true };
|
||||
}
|
||||
async mergeMember(tourId, body, req) {
|
||||
const { manualParticipantId, systemUserId } = body;
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+12
-10
@@ -1585,10 +1585,20 @@ class TourController {
|
||||
this.cacheManager.del(`/api/v1/tours/${invitation.tourId}`),
|
||||
this.cacheManager.del(`/api/v1/tours/${invitation.tourId}/public`),
|
||||
this.cacheManager.del(`/api/v1/tours/explore`),
|
||||
this.cacheManager.del(`user-role:${userId}:${invitation.tourId}`),
|
||||
]);
|
||||
return { success: true, tourId: invitation.tourId, message: 'Bạn đã là thành viên của tour này.' };
|
||||
return { success: true, tourId: invitation.tourId, message: 'Bạn đã là thành viên của tour này.', shouldRefresh: true };
|
||||
}
|
||||
|
||||
// Xóa cache TRƯỚC để đảm bảo không có race condition
|
||||
await Promise.all([
|
||||
this.cacheManager.del(`user-role:${userId}:${invitation.tourId}`),
|
||||
this.cacheManager.del(invitation.tourId),
|
||||
this.cacheManager.del(`/api/v1/tours/${invitation.tourId}`),
|
||||
this.cacheManager.del(`/api/v1/tours/${invitation.tourId}/public`),
|
||||
this.cacheManager.del(`/api/v1/tours/explore`),
|
||||
]);
|
||||
|
||||
await this.prisma.$transaction([
|
||||
this.prisma.tourParticipant.create({
|
||||
data: {
|
||||
@@ -1602,15 +1612,7 @@ class TourController {
|
||||
})
|
||||
]);
|
||||
|
||||
await Promise.all([
|
||||
this.cacheManager.del(invitation.tourId),
|
||||
this.cacheManager.del(`/api/v1/tours/${invitation.tourId}`),
|
||||
this.cacheManager.del(`/api/v1/tours/${invitation.tourId}/public`),
|
||||
this.cacheManager.del(`/api/v1/tours/explore`),
|
||||
this.cacheManager.del(`user-role:${userId}:${invitation.tourId}`),
|
||||
]);
|
||||
|
||||
return { success: true, tourId: invitation.tourId, message: `Bạn đã gia nhập hành trình "${invitation.tour.title}"!` };
|
||||
return { success: true, tourId: invitation.tourId, message: `Bạn đã gia nhập hành trình "${invitation.tour.title}"!`, shouldRefresh: true };
|
||||
}
|
||||
|
||||
@Roles(ParticipantRole.OWNER, ParticipantRole.MANAGER)
|
||||
|
||||
Reference in New Issue
Block a user