@@ -10,6 +10,7 @@ import {
1010 Put ,
1111 UnauthorizedException ,
1212 UseGuards ,
13+ Logger ,
1314} from "@nestjs/common" ;
1415import { EventService } from "./event.service" ;
1516import { TeamService } from "../team/team.service" ;
@@ -24,6 +25,8 @@ import { UserId } from "../guards/UserGuard";
2425
2526@Controller ( "event" )
2627export class EventController {
28+ private readonly logger = new Logger ( EventController . name ) ;
29+
2730 constructor (
2831 private readonly eventService : EventService ,
2932 private readonly teamService : TeamService ,
@@ -91,6 +94,12 @@ export class EventController {
9194 "You are not authorized to create events." ,
9295 ) ;
9396
97+ this . logger . log ( {
98+ action : "attempt_create_event" ,
99+ userId,
100+ eventName : createEventDto . name ,
101+ } ) ;
102+
94103 return this . eventService . createEvent (
95104 userId ,
96105 createEventDto . name ,
@@ -165,6 +174,8 @@ export class EventController {
165174 throw new BadRequestException ( "Event has not started yet." ) ;
166175 }
167176
177+ this . logger . log ( { action : "attempt_join_event" , userId, eventId } ) ;
178+
168179 return this . userService . joinEvent ( userId , eventId ) ;
169180 }
170181
@@ -179,6 +190,8 @@ export class EventController {
179190 "You are not authorized to lock this event." ,
180191 ) ;
181192
193+ this . logger . log ( { action : "attempt_lock_event" , userId, eventId } ) ;
194+
182195 return this . eventService . lockEvent ( eventId ) ;
183196 }
184197
@@ -193,6 +206,8 @@ export class EventController {
193206 "You are not authorized to unlock teams for this event." ,
194207 ) ;
195208
209+ this . logger . log ( { action : "attempt_unlock_event" , userId, eventId } ) ;
210+
196211 return this . eventService . unlockEvent ( eventId ) ;
197212 }
198213
@@ -208,6 +223,13 @@ export class EventController {
208223 "You are not authorized to lock teams for this event." ,
209224 ) ;
210225
226+ this . logger . log ( {
227+ action : "attempt_set_lock_teams_date" ,
228+ userId,
229+ eventId,
230+ repoLockDate : body . repoLockDate ,
231+ } ) ;
232+
211233 if ( ! body . repoLockDate )
212234 return this . eventService . setTeamsLockedDate ( eventId , null ) ;
213235 return this . eventService . setTeamsLockedDate (
@@ -228,6 +250,12 @@ export class EventController {
228250 "You are not authorized to update settings for this event." ,
229251 ) ;
230252
253+ this . logger . log ( {
254+ action : "attempt_update_event_settings" ,
255+ userId,
256+ eventId,
257+ } ) ;
258+
231259 return this . eventService . updateEventSettings ( eventId , body ) ;
232260 }
233261
@@ -253,6 +281,13 @@ export class EventController {
253281 if ( ! ( await this . eventService . isEventAdmin ( eventId , userId ) ) ) {
254282 throw new UnauthorizedException ( "You are not an admin of this event" ) ;
255283 }
284+
285+ this . logger . log ( {
286+ action : "attempt_add_event_admin" ,
287+ userId,
288+ eventId,
289+ newAdminId,
290+ } ) ;
256291 return this . eventService . addEventAdmin ( eventId , newAdminId ) ;
257292 }
258293
@@ -266,6 +301,13 @@ export class EventController {
266301 if ( ! ( await this . eventService . isEventAdmin ( eventId , userId ) ) ) {
267302 throw new UnauthorizedException ( "You are not an admin of this event" ) ;
268303 }
304+
305+ this . logger . log ( {
306+ action : "attempt_remove_event_admin" ,
307+ userId,
308+ eventId,
309+ removedAdminId : adminIdToRemove ,
310+ } ) ;
269311 return this . eventService . removeEventAdmin ( eventId , adminIdToRemove ) ;
270312 }
271313
@@ -285,6 +327,13 @@ export class EventController {
285327 if ( ! ( await this . eventService . isEventAdmin ( eventId , userId ) ) ) {
286328 throw new UnauthorizedException ( "You are not an admin of this event" ) ;
287329 }
330+
331+ this . logger . log ( {
332+ action : "attempt_create_starter_template" ,
333+ userId,
334+ eventId,
335+ templateName : body . name ,
336+ } ) ;
288337 return this . eventService . createStarterTemplate (
289338 eventId ,
290339 body . name ,
@@ -304,6 +353,13 @@ export class EventController {
304353 if ( ! ( await this . eventService . isEventAdmin ( eventId , userId ) ) ) {
305354 throw new UnauthorizedException ( "You are not an admin of this event" ) ;
306355 }
356+
357+ this . logger . log ( {
358+ action : "attempt_update_starter_template" ,
359+ userId,
360+ eventId,
361+ templateId,
362+ } ) ;
307363 return this . eventService . updateStarterTemplate ( eventId , templateId , body ) ;
308364 }
309365
@@ -317,6 +373,13 @@ export class EventController {
317373 if ( ! ( await this . eventService . isEventAdmin ( eventId , userId ) ) ) {
318374 throw new UnauthorizedException ( "You are not an admin of this event" ) ;
319375 }
376+
377+ this . logger . log ( {
378+ action : "attempt_delete_starter_template" ,
379+ userId,
380+ eventId,
381+ templateId,
382+ } ) ;
320383 return this . eventService . deleteStarterTemplate ( eventId , templateId ) ;
321384 }
322385}
0 commit comments