Skip to content

Commit

Permalink
Merge pull request #364 from code4romania/fix/348_join-public-events
Browse files Browse the repository at this point in the history
fix: 348 - join public events by active or archived users regardless if they have a volunteer profile or not
  • Loading branch information
birloiflorian authored Aug 20, 2024
2 parents 319b2c3 + dff7e34 commit 5d883af
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const EventRSVPExceptionMessages: Record<
},
[EventsRSVPExceptionCodes.EVENT_RSVP_003]: {
code_error: EventsRSVPExceptionCodes.EVENT_RSVP_003,
message: 'Only ACTIVE volunteers can join events.',
message: 'Only ACTIVE or ARCHIVED volunteers can join events.',
},
[EventsRSVPExceptionCodes.EVENT_RSVP_004]: {
code_error: EventsRSVPExceptionCodes.EVENT_RSVP_004,
Expand Down
26 changes: 13 additions & 13 deletions backend/src/usecases/event/RSVP/create-rsvp.usecase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,27 @@ export class CreateEventRSVPUseCase
organizationId: event.organization.id,
});

if (volunteer) {
// 4. Only ACTIVE volunteers can join events. In case the user is already a volunteer and is BLOCKED or ARCHIVED. Non-volunteers will pass this validation for public events
if (volunteer.status !== VolunteerStatus.ACTIVE) {
this.exceptionsService.badRequestException(
EventRSVPExceptionMessages.EVENT_RSVP_003,
);
} else if (!volunteer.volunteerProfile) {
// 5. Volunteers must have the profile completed to RSVP.
this.exceptionsService.badRequestException(
EventRSVPExceptionMessages.EVENT_RSVP_005,
);
}
// 4. If the volunteer is blocked the user should not be able to join the event
if (volunteer?.status === VolunteerStatus.BLOCKED) {
this.exceptionsService.badRequestException(
EventRSVPExceptionMessages.EVENT_RSVP_003,
);
}

// 6. For "private" events, check if the USER is VOLUNTEER in the ORGANIZATION of the EVENT
// 5. For "private" events, check if the USER is VOLUNTEER in the ORGANIZATION of the EVENT
if (!event.isPublic && !volunteer) {
this.exceptionsService.badRequestException(
EventRSVPExceptionMessages.EVENT_RSVP_002,
);
}

// 6. For private events volunteers must have the profile completed to RSVP.
if (!event.isPublic && volunteer && !volunteer.volunteerProfile) {
this.exceptionsService.badRequestException(
EventRSVPExceptionMessages.EVENT_RSVP_005,
);
}

// 7. Check if userId and eventId is unique in RSVP, if exists, update only the "going" response
const existingRSVP = await this.eventFacade.findRSVP({
userId: data.userId,
Expand Down

0 comments on commit 5d883af

Please sign in to comment.