fix: khách mời join vào tour thông qua link mời

This commit is contained in:
2026-06-21 07:11:26 +07:00
parent 36157bd53b
commit 55fba75fda
5 changed files with 39 additions and 21 deletions
+10 -9
View File
@@ -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;
+1 -1
View File
File diff suppressed because one or more lines are too long
+12 -10
View File
@@ -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)