11import { Message } from '@rocket.chat/core-services' ;
2- import type { IMessage , IThreadMainMessage } from '@rocket.chat/core-typings' ;
2+ import type { IMessage , IRoom , IThreadMainMessage } from '@rocket.chat/core-typings' ;
33import { MessageTypes } from '@rocket.chat/message-types' ;
44import { Messages , Users , Rooms , Subscriptions } from '@rocket.chat/models' ;
55import {
@@ -12,7 +12,6 @@ import {
1212 isChatSyncMessagesProps ,
1313 isChatGetMessageProps ,
1414 isChatPostMessageProps ,
15- isChatSearchProps ,
1615 isChatSendMessageProps ,
1716 isChatIgnoreUserProps ,
1817 isChatGetPinnedMessagesProps ,
@@ -26,6 +25,7 @@ import {
2625 isChatGetDiscussionsProps ,
2726 validateBadRequestErrorResponse ,
2827 validateUnauthorizedErrorResponse ,
28+ type PaginatedRequest ,
2929} from '@rocket.chat/rest-typings' ;
3030import { escapeRegExp } from '@rocket.chat/string-helpers' ;
3131import { Meteor } from 'meteor/meteor' ;
@@ -119,6 +119,35 @@ const ChatUnfollowMessageLocalSchema = {
119119 additionalProperties : false ,
120120} ;
121121
122+ //chat.search starts
123+ type ChatSearch = PaginatedRequest < {
124+ roomId : IRoom [ '_id' ] ;
125+ searchText : string ;
126+ } > ;
127+
128+ const ChatSearchSchema = {
129+ type : 'object' ,
130+ properties : {
131+ roomId : {
132+ type : 'string' ,
133+ } ,
134+ searchText : {
135+ type : 'string' ,
136+ } ,
137+ count : {
138+ type : 'number' ,
139+ nullable : true ,
140+ } ,
141+ offset : {
142+ type : 'number' ,
143+ nullable : true ,
144+ } ,
145+ } ,
146+ required : [ 'roomId' , 'searchText' ] ,
147+ additionalProperties : false ,
148+ } ;
149+ //chat.search ends
150+
122151const isChatStarMessageLocalProps = ajv . compile < ChatStarMessageLocal > ( ChatStarMessageLocalSchema ) ;
123152
124153const isChatUnstarMessageLocalProps = ajv . compile < ChatUnstarMessageLocal > ( ChatUnstarMessageLocalSchema ) ;
@@ -127,6 +156,8 @@ const isChatFollowMessageLocalProps = ajv.compile<ChatFollowMessageLocal>(ChatFo
127156
128157const isChatUnfollowMessageLocalProps = ajv . compile < ChatUnfollowMessageLocal > ( ChatUnfollowMessageLocalSchema ) ;
129158
159+ const isChatSearchLocalProps = ajv . compile < ChatSearch > ( ChatSearchSchema ) ;
160+
130161API . v1 . addRoute (
131162 'chat.delete' ,
132163 { authRequired : true , validateParams : isChatDeleteProps } ,
@@ -563,7 +594,7 @@ const chatEndpoints = API.v1
563594 'chat.search' ,
564595 {
565596 authRequired : true ,
566- query : isChatSearchProps ,
597+ query : isChatSearchLocalProps ,
567598 response : {
568599 400 : validateBadRequestErrorResponse ,
569600 401 : validateUnauthorizedErrorResponse ,
0 commit comments