-
Notifications
You must be signed in to change notification settings - Fork 13.3k
fix(calendar): address review comments and improve subject search #39236
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
Open
gauravsingh001-cyber
wants to merge
3
commits into
RocketChat:develop
Choose a base branch
from
gauravsingh001-cyber:fix-reminder-zero-bug
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+81
−4
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
0800e1a
fix(calendar): address review comments and improve subject search
gauravsingh001-cyber 63ae7d0
feat(calendar): add search endpoint validation and limit results to p…
gauravsingh001-cyber ebc9bed
chore: remove inline comment from route config
gauravsingh001-cyber 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -4,6 +4,10 @@ import type { FindCursor, IndexDescription, Collection, Db, UpdateResult } from | |
|
|
||
| import { BaseRaw } from './BaseRaw'; | ||
|
|
||
| function escapeRegExp(text: string): string { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: Duplicate escapeRegExp utility: should import from '@rocket.chat/string-helpers' Prompt for AI agents |
||
| return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); | ||
| } | ||
|
|
||
| export class CalendarEventRaw extends BaseRaw<ICalendarEvent> implements ICalendarEventModel { | ||
| constructor(db: Db, trash?: Collection<RocketChatRecordDeleted<ICalendarEvent>>) { | ||
| super(db, 'calendar_event', trash); | ||
|
|
@@ -48,6 +52,20 @@ export class CalendarEventRaw extends BaseRaw<ICalendarEvent> implements ICalend | |
| ); | ||
| } | ||
|
|
||
| public findBySubject(uid: IUser['_id'], text: string): FindCursor<ICalendarEvent> { | ||
| const escapedText = escapeRegExp(text); | ||
|
|
||
| return this.find( | ||
| { | ||
| uid, | ||
| subject: { $regex: escapedText, $options: 'i' }, | ||
| }, | ||
| { | ||
| sort: { startTime: 1 }, | ||
| }, | ||
| ); | ||
| } | ||
|
|
||
| public async updateEvent( | ||
| eventId: ICalendarEvent['_id'], | ||
| { | ||
|
|
@@ -257,4 +275,4 @@ export class CalendarEventRaw extends BaseRaw<ICalendarEvent> implements ICalend | |
| }, | ||
| ); | ||
| } | ||
| } | ||
| } | ||
20 changes: 20 additions & 0 deletions
20
packages/rest-typings/src/v1/calendar/CalendarEventSearchProps.ts
This file contains hidden or 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,20 @@ | ||
| import type { JSONSchemaType } from 'ajv'; | ||
| import { ajv } from '../../Ajv'; | ||
|
|
||
| export type CalendarEventSearchProps = { | ||
| text: string; | ||
| }; | ||
|
|
||
| const calendarEventSearchPropsSchema: JSONSchemaType<CalendarEventSearchProps> = { | ||
| type: 'object', | ||
| properties: { | ||
| text: { | ||
| type: 'string', | ||
| nullable: false, | ||
| }, | ||
| }, | ||
| required: ['text'], | ||
| additionalProperties: false, | ||
| }; | ||
|
|
||
| export const isCalendarEventSearchProps = ajv.compile(calendarEventSearchPropsSchema); |
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.