2023-10-02 10:51:04 +00:00
|
|
|
import type { Credential, SelectedCalendar, DestinationCalendar } from "@prisma/client";
|
2023-09-30 13:28:52 +00:00
|
|
|
|
2023-10-02 10:51:04 +00:00
|
|
|
import type { EventType } from "@calcom/prisma/client";
|
2023-09-28 13:01:24 +00:00
|
|
|
import type { CalendarEvent } from "@calcom/types/Calendar";
|
|
|
|
|
|
|
|
export function getPiiFreeCalendarEvent(calEvent: CalendarEvent) {
|
|
|
|
return {
|
|
|
|
eventTypeId: calEvent.eventTypeId,
|
|
|
|
type: calEvent.type,
|
|
|
|
startTime: calEvent.startTime,
|
|
|
|
endTime: calEvent.endTime,
|
|
|
|
schedulingType: calEvent.schedulingType,
|
|
|
|
seatsPerTimeSlot: calEvent.seatsPerTimeSlot,
|
|
|
|
appsStatus: calEvent.appsStatus,
|
|
|
|
recurringEvent: calEvent.recurringEvent,
|
|
|
|
recurrence: calEvent.recurrence,
|
|
|
|
requiresConfirmation: calEvent.requiresConfirmation,
|
|
|
|
uid: calEvent.uid,
|
2023-10-02 10:51:04 +00:00
|
|
|
iCalUID: calEvent.iCalUID,
|
2023-09-28 13:01:24 +00:00
|
|
|
/**
|
|
|
|
* Let's just get a boolean value for PII sensitive fields so that we atleast know if it's present or not
|
|
|
|
*/
|
|
|
|
// Not okay to have title which can have Booker and Organizer names
|
|
|
|
title: !!calEvent.title,
|
|
|
|
// .... Add all other props here that we don't want to be logged. It prevents those properties from being logged accidentally
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getPiiFreeBooking(booking: {
|
|
|
|
id: number;
|
|
|
|
uid: string;
|
|
|
|
userId: number | null;
|
|
|
|
startTime: Date;
|
|
|
|
endTime: Date;
|
|
|
|
title: string;
|
|
|
|
}) {
|
|
|
|
return {
|
|
|
|
id: booking.id,
|
|
|
|
uid: booking.uid,
|
|
|
|
userId: booking.userId,
|
|
|
|
startTime: booking.startTime,
|
|
|
|
endTime: booking.endTime,
|
|
|
|
/**
|
|
|
|
* Let's just get a boolean value for PII sensitive fields so that we atleast know if it's present or not
|
|
|
|
*/
|
|
|
|
// Not okay to have title which can have Booker and Organizer names
|
|
|
|
title: !!booking.title,
|
|
|
|
// .... Add all other props here that we don't want to be logged. It prevents those properties from being logged accidentally
|
|
|
|
};
|
|
|
|
}
|
2023-09-30 13:28:52 +00:00
|
|
|
|
|
|
|
export function getPiiFreeCredential(credential: Partial<Credential>) {
|
|
|
|
return {
|
|
|
|
id: credential.id,
|
|
|
|
invalid: credential.invalid,
|
|
|
|
appId: credential.appId,
|
|
|
|
userId: credential.userId,
|
|
|
|
type: credential.type,
|
|
|
|
teamId: credential.teamId,
|
|
|
|
/**
|
|
|
|
* Let's just get a boolean value for PII sensitive fields so that we atleast know if it's present or not
|
|
|
|
*/
|
|
|
|
key: !!credential.key,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getPiiFreeSelectedCalendar(selectedCalendar: Partial<SelectedCalendar>) {
|
|
|
|
return {
|
|
|
|
integration: selectedCalendar.integration,
|
|
|
|
userId: selectedCalendar.userId,
|
2023-10-02 10:51:04 +00:00
|
|
|
// Get first 3 characters of externalId, so that we know what it could be but not the full value
|
|
|
|
externalId: selectedCalendar.externalId?.slice(0, 3),
|
|
|
|
credentialId: !!selectedCalendar.credentialId,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getPiiFreeDestinationCalendar(destinationCalendar: Partial<DestinationCalendar>) {
|
|
|
|
return {
|
|
|
|
integration: destinationCalendar.integration,
|
|
|
|
userId: destinationCalendar.userId,
|
2023-09-30 13:28:52 +00:00
|
|
|
/**
|
|
|
|
* Let's just get a boolean value for PII sensitive fields so that we atleast know if it's present or not
|
|
|
|
*/
|
2023-10-02 10:51:04 +00:00
|
|
|
externalId: !!destinationCalendar.externalId,
|
|
|
|
credentialId: !!destinationCalendar.credentialId,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getPiiFreeEventType(eventType: Partial<Omit<EventType, "recurringEvent">>) {
|
|
|
|
return {
|
|
|
|
id: eventType.id,
|
|
|
|
schedulingType: eventType.schedulingType,
|
|
|
|
seatsPerTimeSlot: eventType.seatsPerTimeSlot,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function getPiiFreeUser(user: {
|
|
|
|
id?: number;
|
|
|
|
username?: string | null;
|
|
|
|
isFixed?: boolean;
|
|
|
|
timeZone?: string;
|
|
|
|
allowDynamicBooking?: boolean | null;
|
|
|
|
defaultScheduleId?: number | null;
|
|
|
|
organizationId?: number | null;
|
|
|
|
credentials?: Credential[];
|
|
|
|
destinationCalendar?: DestinationCalendar | null;
|
|
|
|
}) {
|
|
|
|
return {
|
|
|
|
id: user.id,
|
|
|
|
username: user.username,
|
|
|
|
isFixed: user.isFixed,
|
|
|
|
timeZone: user.timeZone,
|
|
|
|
allowDynamicBooking: user.allowDynamicBooking,
|
|
|
|
defaultScheduleId: user.defaultScheduleId,
|
|
|
|
organizationId: user.organizationId,
|
|
|
|
credentials: user.credentials?.map(getPiiFreeCredential),
|
|
|
|
destinationCalendar: user.destinationCalendar
|
|
|
|
? getPiiFreeDestinationCalendar(user.destinationCalendar)
|
|
|
|
: user.destinationCalendar,
|
2023-09-30 13:28:52 +00:00
|
|
|
};
|
|
|
|
}
|