-
Notifications
You must be signed in to change notification settings - Fork 7.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: ics-feed calendar api-v2 #16735
Merged
Merged
Changes from 8 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
1a4a156
feat: ics-feed calendar api-v2
ThyMinimalDev a1cc2ee
Merge branch 'main' into feat-ics-feed-api-v2
ThyMinimalDev e0b576e
fixup! feat: ics-feed calendar api-v2
ThyMinimalDev 776fea4
Merge branch 'main' into feat-ics-feed-api-v2
ThyMinimalDev 751dff7
Merge branch 'main' into feat-ics-feed-api-v2
ThyMinimalDev 2296b64
Merge branch 'main' into feat-ics-feed-api-v2
keithwillcode 1735473
Merge branch 'main' into feat-ics-feed-api-v2
ThyMinimalDev f4daf26
Merge branch 'main' into feat-ics-feed-api-v2
ThyMinimalDev 8954c6c
Merge branch 'main' into feat-ics-feed-api-v2
ThyMinimalDev 3c1adb7
chore: bump platform libraries
ThyMinimalDev 1085580
Merge branch 'main' into feat-ics-feed-api-v2
ThyMinimalDev 66b6b1f
fixup! Merge branch 'main' into feat-ics-feed-api-v2
ThyMinimalDev a64fa88
fixup! fixup! Merge branch 'main' into feat-ics-feed-api-v2
ThyMinimalDev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { ApiProperty } from "@nestjs/swagger"; | ||
import { | ||
ArrayNotEmpty, | ||
IsBoolean, | ||
IsOptional, | ||
Validate, | ||
ValidatorConstraint, | ||
ValidatorConstraintInterface, | ||
} from "class-validator"; | ||
import { IsNotEmpty, IsArray } from "class-validator"; | ||
|
||
// Custom constraint to validate ICS URLs | ||
@ValidatorConstraint({ async: false }) | ||
export class IsICSUrlConstraint implements ValidatorConstraintInterface { | ||
validate(url: unknown) { | ||
if (typeof url !== "string") return false; | ||
|
||
// Check if it's a valid URL and ends with .ics | ||
try { | ||
const urlObject = new URL(url); | ||
return ( | ||
(urlObject.protocol === "http:" || urlObject.protocol === "https:") && | ||
urlObject.pathname.endsWith(".ics") | ||
); | ||
} catch (error) { | ||
return false; | ||
} | ||
} | ||
|
||
defaultMessage() { | ||
return "The URL must be a valid ICS URL (ending with .ics)"; | ||
} | ||
} | ||
|
||
export class CreateIcsFeedInputDto { | ||
@ApiProperty({ | ||
example: ["https://cal.com/ics/feed.ics", "http://cal.com/ics/feed.ics"], | ||
description: "An array of ICS URLs", | ||
type: "array", | ||
items: { | ||
type: "string", | ||
example: "https://cal.com/ics/feed.ics", | ||
}, | ||
required: true, | ||
}) | ||
@IsArray() | ||
@ArrayNotEmpty() | ||
@IsNotEmpty({ each: true }) | ||
@Validate(IsICSUrlConstraint, { each: true }) // Apply the custom validator to each element in the array | ||
ThyMinimalDev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
urls!: string[]; | ||
|
||
@IsBoolean() | ||
@ApiProperty({ | ||
example: false, | ||
description: "Whether to allowing writing to the calendar or not", | ||
type: "boolean", | ||
required: false, | ||
default: true, | ||
}) | ||
@IsOptional() | ||
readOnly?: boolean = true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { ApiProperty } from "@nestjs/swagger"; | ||
import { Expose, Type } from "class-transformer"; | ||
import { IsString, ValidateNested, IsEnum, IsInt, IsBoolean } from "class-validator"; | ||
|
||
import { ERROR_STATUS, SUCCESS_STATUS } from "@calcom/platform-constants"; | ||
|
||
export class CreateIcsFeedOutput { | ||
@IsInt() | ||
@Expose() | ||
ThyMinimalDev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
@ApiProperty({ example: 1234567890, description: "The id of the calendar credential" }) | ||
readonly id!: number; | ||
|
||
@IsString() | ||
@Expose() | ||
@ApiProperty({ example: "ics-feed_calendar", description: "The type of the calendar" }) | ||
readonly type!: string; | ||
|
||
@IsInt() | ||
@Expose() | ||
@ApiProperty({ | ||
example: 1234567890, | ||
description: "The user id of the user that created the calendar", | ||
type: "integer", | ||
}) | ||
readonly userId!: number | null; | ||
|
||
@IsInt() | ||
@Expose() | ||
@ApiProperty({ | ||
example: 1234567890, | ||
nullable: true, | ||
description: "The team id of the user that created the calendar", | ||
type: "integer", | ||
}) | ||
readonly teamId!: number | null; | ||
|
||
@IsString() | ||
@Expose() | ||
@ApiProperty({ example: "ics-feed", description: "The slug of the calendar" }) | ||
readonly appId!: string | null; | ||
|
||
@IsBoolean() | ||
@Expose() | ||
@ApiProperty({ example: false, description: "Whether the calendar credentials are valid or not" }) | ||
readonly invalid!: boolean | null; | ||
} | ||
|
||
export class CreateIcsFeedOutputResponseDto { | ||
@ApiProperty({ example: SUCCESS_STATUS, enum: [SUCCESS_STATUS, ERROR_STATUS] }) | ||
@IsEnum([SUCCESS_STATUS, ERROR_STATUS]) | ||
status!: typeof SUCCESS_STATUS | typeof ERROR_STATUS; | ||
|
||
@Expose() | ||
@ValidateNested() | ||
@Type(() => CreateIcsFeedOutput) | ||
data!: CreateIcsFeedOutput; | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this under DTO so file reads top to bottom?