Skip to content

Commit

Permalink
Fixed event service issues
Browse files Browse the repository at this point in the history
  • Loading branch information
AydanPirani committed Oct 29, 2023
1 parent 968ff96 commit bd5fd72
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/database/event-db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export class PublicEvent extends BaseEvent {
@prop({ required: true })
public displayOnStaffCheckIn: boolean;

@prop({ required: true })
@prop()
public sponsor: string;

@prop({ required: true })
Expand All @@ -101,7 +101,7 @@ export class PublicEvent extends BaseEvent {
this.eventType = baseEvent.publicEventType ?? "OTHER";
this.isPrivate = baseEvent.isPrivate ?? false;
this.displayOnStaffCheckIn = baseEvent.displayOnStaffCheckIn ?? false;
this.sponsor = baseEvent.sponsor ?? "None";
this.sponsor = baseEvent.sponsor ?? "";
this.points = baseEvent.points ?? Constants.DEFAULT_POINT_VALUE;
}
}
Expand Down
6 changes: 0 additions & 6 deletions src/services/auth/auth-models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ export interface ProfileData {
name?: string;
}

export interface RoleData {
id: string;
provider: Provider | string;
roles: Role[];
}

export interface JwtPayload {
id: string;
email: string;
Expand Down
5 changes: 4 additions & 1 deletion src/services/event/event-formats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,11 @@ export function isValidPublicFormat(baseEvent: BaseEventFormat): boolean {
// Cast the object to AttendeeEventFormat
const obj: PublicEventFormat = baseEvent as PublicEventFormat;

if (obj.sponsor && typeof obj.sponsor !== "string") {
return false;
}

if (
typeof obj.sponsor !== "string" ||
typeof obj.publicEventType !== "string" ||
!Object.values(PUBLIC_EVENT_TYPE).includes(obj.publicEventType) ||
typeof obj.points !== "number" ||
Expand Down
2 changes: 1 addition & 1 deletion src/services/event/event-lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { PublicEvent } from "../../database/event-db.js";
*/
export function createFilteredEventView(baseEvent: PublicEvent): FilteredEventView {
const publicEvent: FilteredEventView = {
id: baseEvent.eventId,
eventId: baseEvent.eventId,
name: baseEvent.name,
description: baseEvent.description,
startTime: baseEvent.startTime,
Expand Down
4 changes: 2 additions & 2 deletions src/services/event/event-models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ export enum STAFF_EVENT_TYPE {
}

export interface FilteredEventView {
id: string;
eventId: string;
name: string;
description: string;
startTime: number;
endTime: number;
locations: Location[];
sponsor: string;
sponsor?: string;
eventType: PUBLIC_EVENT_TYPE;
points: number;
isAsync: boolean;
Expand Down
6 changes: 5 additions & 1 deletion src/services/event/event-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,11 @@ eventsRouter.get("/", weakJwtVerification, async (_: Request, res: Response) =>
if (hasStaffPerms(payload)) {
return res.status(StatusCode.SuccessOK).send({ events: publicEvents });
} else {
const filteredEvents: FilteredEventView[] = publicEvents.map(createFilteredEventView);
const filteredEvents: FilteredEventView[] = publicEvents
.filter((event: PublicEvent) => {
return !event.isPrivate;
})
.map(createFilteredEventView);
return res.status(StatusCode.SuccessOK).send({ events: filteredEvents });
}
});
Expand Down

0 comments on commit bd5fd72

Please sign in to comment.