Skip to content

Commit

Permalink
Merge pull request #54 from Xitija/main2
Browse files Browse the repository at this point in the history
PS-2903 : Metadata changes for zoom attendance
  • Loading branch information
snehal0904 authored Jan 15, 2025
2 parents 955e1af + a8c966b commit 360870a
Show file tree
Hide file tree
Showing 9 changed files with 382 additions and 156 deletions.
10 changes: 9 additions & 1 deletion src/common/utils/constants.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ export const ERROR_MESSAGES = {
USERID_INVALID: 'Invalid UserId',
USERID_REQUIRED: 'UserId Required',
PROVIDE_ONE_USERID_IN_QUERY: 'Please provide userId in query params',
ENVIRONMENT_VARIABLES_MISSING: 'Environment variables missing!',
USERS_NOT_FOUND_IN_SERVICE: 'Users not found in user service',
SERVICE_NOT_FOUND: 'Service not found',
NO_PARTICIPANTS_FOUND: 'No participants found for the meeting',
MEETING_NOT_FOUND: 'Meeting not found',
NO_USERS_FOUND: 'No users found in system',
EVENT_DOES_NOT_EXIST: 'Event does not exist',
API_REQ_FAILURE: (url: string) => `Error occurred on API Request: ${url}`,
DB_QUERY_FAILURE: (url: string) => `Database Query Failed on API: ${url}`,
API_FAILURE: (url: string) => `API Failure: ${url}`,
Expand All @@ -111,6 +118,7 @@ export const SUCCESS_MESSAGES = {
EVENT_CREATED_LOG: (url: string) => `Event created with ID: ${url}`,
EVENTS_FETCHED_LOG: 'Successfully fetched events',
EVENT_UPDATED_LOG: 'Successfully updated events',
ATTENDANCE_MARKED_FOR_MEETING: 'Attendance marked for meeting',
};

export const API_ID = {
Expand All @@ -129,5 +137,5 @@ export const API_ID = {
CREATE_EVENT_ATTENDEE_HISTORY_ITEM: 'api.event.attendee.history.item.create',
UPDATE_EVENT_ATTENDEE_HISTORY_ITEM: 'api.event.attendee.history.item.update',
DELETE_EVENT_ATTENDEE_HISTORY_ITEM: 'api.event.attendee.history.item.delete',
MARK_ZOOM_ATTENDANCE: 'mark.zoom.event.attendance',
MARK_EVENT_ATTENDANCE: 'api.event.mark.attendance',
};
47 changes: 47 additions & 0 deletions src/common/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,50 @@ export type RecurrencePattern = {
value: string;
};
};

export type ZoomParticipant = {
id: string;
user_id: string;
name: string;
user_email: string;
join_time: string;
leave_time: string;
duration: number;
registrant_id: string;
failover: boolean;
status: string;
groupId: string;
internal_user: boolean;
};

export type UserDetails = {
userId: string;
username: string;
email: string;
name: string;
role: string;
mobile: string;
createdBy: string;
updatedBy: string;
createdAt: string;
updatedAt: string;
status: string;
total_count: string;
};

export interface AttendanceRecord {
userId: string;
attendance: 'present' | 'absent';
metaData: {
duration: number;
joinTime: string;
leaveTime: string;
};
}

export interface InZoomMeetingUserDetails {
user_email: string;
duration: number;
join_time: string;
leave_time: string;
}
22 changes: 16 additions & 6 deletions src/modules/attendance/attendance.controller.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import { Body, Controller, Post, Res, Req, UseFilters } from '@nestjs/common';
import {
Body,
Controller,
Post,
Res,
Req,
UseFilters,
UsePipes,
ValidationPipe,
} from '@nestjs/common';
import { Response, Request } from 'express';
import { ApiBody, ApiQuery, ApiTags } from '@nestjs/swagger';
import { AttendanceService } from './attendance.service';
import { AllExceptionsFilter } from 'src/common/filters/exception.filter';
import { MarkZoomAttendanceDto } from './dto/MarkZoomAttendance.dto';
import { MarkMeetingAttendanceDto } from './dto/MarkAttendance.dto';
import { checkValidUserId } from 'src/common/utils/functions.util';
import { API_ID, ERROR_MESSAGES } from 'src/common/utils/constants.util';

Expand All @@ -12,22 +21,23 @@ import { API_ID, ERROR_MESSAGES } from 'src/common/utils/constants.util';
export class EventAttendance {
constructor(private readonly attendanceService: AttendanceService) {}

@UseFilters(new AllExceptionsFilter(API_ID.MARK_ZOOM_ATTENDANCE))
@UseFilters(new AllExceptionsFilter(API_ID.MARK_EVENT_ATTENDANCE))
@Post('/markeventattendance')
@ApiBody({ type: MarkZoomAttendanceDto })
@ApiBody({ type: MarkMeetingAttendanceDto })
@ApiQuery({
name: 'userId',
required: true,
description: ERROR_MESSAGES.USERID_REQUIRED,
example: '123e4567-e89b-12d3-a456-426614174000',
})
@UsePipes(new ValidationPipe({ transform: true }))
async markEventAttendance(
@Body() markZoomAttendanceDto: MarkZoomAttendanceDto,
@Body() markZoomAttendanceDto: MarkMeetingAttendanceDto,
@Res() response: Response,
@Req() request: Request,
): Promise<Response> {
const userId: string = checkValidUserId(request.query?.userId);
return this.attendanceService.markAttendanceForZoomMeetingParticipants(
return this.attendanceService.markAttendanceForMeetingParticipants(
markZoomAttendanceDto,
userId,
response,
Expand Down
13 changes: 11 additions & 2 deletions src/modules/attendance/attendance.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,19 @@ import { EventAttendance } from './attendance.controller';
import { AttendanceService } from './attendance.service';
import { HttpModule } from '@nestjs/axios';
import { ConfigService } from '@nestjs/config';
import { OnlineMeetingAdapter } from 'src/online-meeting-adapters/onlineMeeting.adapter';
import { ZoomService } from 'src/online-meeting-adapters/zoom/zoom.adapter';
import { TypeOrmModule } from '@nestjs/typeorm';
import { EventRepetition } from '../event/entities/eventRepetition.entity';

@Module({
imports: [HttpModule],
imports: [HttpModule, TypeOrmModule.forFeature([EventRepetition])],
controllers: [EventAttendance],
providers: [AttendanceService, ConfigService],
providers: [
AttendanceService,
ConfigService,
OnlineMeetingAdapter,
ZoomService,
],
})
export class AttendanceModule {}
Loading

0 comments on commit 360870a

Please sign in to comment.