Skip to content

Commit

Permalink
Merge pull request #48 from Xitija/main2
Browse files Browse the repository at this point in the history
PS-2254 Online meeting link validation
  • Loading branch information
snehal0904 authored Oct 18, 2024
2 parents 965a381 + 3ee0031 commit 0817769
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
11 changes: 10 additions & 1 deletion src/common/filters/exception.filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,16 @@ export class AllExceptionsFilter implements ExceptionFilter {
let errorMessage =
exception?.message || ERROR_MESSAGES.INTERNAL_SERVER_ERROR;

if (exception instanceof QueryFailedError) {
if (exception instanceof HttpException) {
const statusCode = exception.getStatus();
const errorResponse = APIResponse.error(
this.apiId,
(exception.getResponse() as any)?.message,
ERROR_MESSAGES.BAD_REQUEST,
statusCode.toString(),
);
return response.status(statusCode).json(errorResponse);
} else if (exception instanceof QueryFailedError) {
const statusCode = HttpStatus.UNPROCESSABLE_ENTITY;
const errorResponse = APIResponse.error(
this.apiId,
Expand Down
2 changes: 1 addition & 1 deletion src/common/utils/transformer/date.transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ValueTransformer } from 'typeorm';
export class TimeZoneTransformer implements ValueTransformer {
// private timeZone: string;

constructor(private configService: ConfigService) {}
constructor(private readonly configService: ConfigService) {}

// To DB: Convert the date to UTC before saving
to(entityValue: Date): Date {
Expand Down
5 changes: 3 additions & 2 deletions src/common/utils/validation.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import {

function validateMeetingUrl(url, provider) {
const providerPatterns = {
zoom: /^https:\/\/[\w-]*\.?zoom.us\/(j|my)\/[-\w?=]+$/,
googlemeet: /^(https:\/\/)?meet\.google\.com\/[a-zA-Z0-9-]+$/,
zoom: /^https?:\/\/[\w-]*\.?zoom\.(com|us)\/(j|my)\/[\w-]+(\?[\w=&-]*)?$/,
googlemeet:
/^https?:\/\/meet\.(google\.com|[a-zA-Z0-9-]+\.com)\/[a-z]{3,}-[a-z]{3,}-[a-z]{3}(\?[\w=&-]*)?$/,
// microsoftteams: /^(https:\/\/)?teams\.microsoft\.com\/[a-zA-Z0-9?&=]+$/,
// Add other supported providers as needed
};
Expand Down
2 changes: 1 addition & 1 deletion src/modules/event/dto/update-event.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class UpdateEventDto {
example: {
url: 'https://example.com/meeting',
id: '123-456-789',
password: 'xxxxxxx',
// password: 'xxxxxxx', // This will be hidden from API response docs
},
})
@IsObject()
Expand Down
4 changes: 2 additions & 2 deletions src/modules/event/event.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ import { compareArrays } from 'src/common/utils/functions.util';
import * as moment from 'moment-timezone';
@Injectable()
export class EventService {
private eventCreationLimit: number;
private timezone: string;
private readonly eventCreationLimit: number;
private readonly timezone: string;

constructor(
@InjectRepository(Events)
Expand Down

0 comments on commit 0817769

Please sign in to comment.