@@ -18,8 +18,6 @@ import {
1818 isChatUnstarMessageProps ,
1919 isChatIgnoreUserProps ,
2020 isChatGetPinnedMessagesProps ,
21- isChatFollowMessageProps ,
22- isChatUnfollowMessageProps ,
2321 isChatGetMentionedMessagesProps ,
2422 isChatReactProps ,
2523 isChatGetDeletedMessagesProps ,
@@ -59,6 +57,42 @@ import { API } from '../api';
5957import { getPaginationItems } from '../helpers/getPaginationItems' ;
6058import { findDiscussionsFromRoom , findMentionedMessages , findStarredMessages } from '../lib/messages' ;
6159
60+ type ChatFollowMessageLocal = {
61+ mid : string ;
62+ } ;
63+
64+ const ChatFollowMessageLocalSchema = {
65+ type : 'object' ,
66+ properties : {
67+ mid : {
68+ type : 'string' ,
69+ minLength : 1 ,
70+ } ,
71+ } ,
72+ required : [ 'mid' ] ,
73+ additionalProperties : false ,
74+ } ;
75+
76+ const isChatFollowMessageLocalProps = ajv . compile < ChatFollowMessageLocal > ( ChatFollowMessageLocalSchema ) ;
77+
78+ type ChatUnfollowMessageLocal = {
79+ mid : string ;
80+ } ;
81+
82+ const ChatUnfollowMessageLocalSchema = {
83+ type : 'object' ,
84+ properties : {
85+ mid : {
86+ type : 'string' ,
87+ minLength : 1 ,
88+ } ,
89+ } ,
90+ required : [ 'mid' ] ,
91+ additionalProperties : false ,
92+ } ;
93+
94+ const isChatUnfollowMessageLocalProps = ajv . compile < ChatUnfollowMessageLocal > ( ChatUnfollowMessageLocalSchema ) ;
95+
6296API . v1 . addRoute (
6397 'chat.delete' ,
6498 { authRequired : true , validateParams : isChatDeleteProps } ,
@@ -350,6 +384,72 @@ const chatEndpoints = API.v1
350384 message,
351385 } ) ;
352386 } ,
387+ )
388+ . post (
389+ 'chat.followMessage' ,
390+ {
391+ authRequired : true ,
392+ body : isChatFollowMessageLocalProps ,
393+ response : {
394+ 400 : validateBadRequestErrorResponse ,
395+ 401 : validateUnauthorizedErrorResponse ,
396+ 200 : ajv . compile < void > ( {
397+ type : 'object' ,
398+ properties : {
399+ success : {
400+ type : 'boolean' ,
401+ enum : [ true ] ,
402+ } ,
403+ } ,
404+ required : [ 'success' ] ,
405+ additionalProperties : false ,
406+ } ) ,
407+ } ,
408+ } ,
409+ async function action ( ) {
410+ const { mid } = this . bodyParams ;
411+
412+ if ( ! mid ) {
413+ throw new Meteor . Error ( 'The required "mid" body param is missing.' ) ;
414+ }
415+
416+ await followMessage ( this . user , { mid } ) ;
417+
418+ return API . v1 . success ( ) ;
419+ } ,
420+ )
421+ . post (
422+ 'chat.unfollowMessage' ,
423+ {
424+ authRequired : true ,
425+ body : isChatUnfollowMessageLocalProps ,
426+ response : {
427+ 400 : validateBadRequestErrorResponse ,
428+ 401 : validateUnauthorizedErrorResponse ,
429+ 200 : ajv . compile < void > ( {
430+ type : 'object' ,
431+ properties : {
432+ success : {
433+ type : 'boolean' ,
434+ enum : [ true ] ,
435+ } ,
436+ } ,
437+ required : [ 'success' ] ,
438+ additionalProperties : false ,
439+ } ) ,
440+ } ,
441+ } ,
442+ async function action ( ) {
443+ const { mid } = this . bodyParams ;
444+
445+ if ( ! mid ) {
446+ throw new Meteor . Error ( 'The required "mid" body param is missing.' ) ;
447+ }
448+
449+ await unfollowMessage ( this . user , { mid } ) ;
450+
451+ return API . v1 . success ( ) ;
452+ } ,
353453 ) ;
354454
355455API . v1 . addRoute (
@@ -793,42 +893,6 @@ API.v1.addRoute(
793893 } ,
794894) ;
795895
796- API . v1 . addRoute (
797- 'chat.followMessage' ,
798- { authRequired : true , validateParams : isChatFollowMessageProps } ,
799- {
800- async post ( ) {
801- const { mid } = this . bodyParams ;
802-
803- if ( ! mid ) {
804- throw new Meteor . Error ( 'The required "mid" body param is missing.' ) ;
805- }
806-
807- await followMessage ( this . user , { mid } ) ;
808-
809- return API . v1 . success ( ) ;
810- } ,
811- } ,
812- ) ;
813-
814- API . v1 . addRoute (
815- 'chat.unfollowMessage' ,
816- { authRequired : true , validateParams : isChatUnfollowMessageProps } ,
817- {
818- async post ( ) {
819- const { mid } = this . bodyParams ;
820-
821- if ( ! mid ) {
822- throw new Meteor . Error ( 'The required "mid" body param is missing.' ) ;
823- }
824-
825- await unfollowMessage ( this . user , { mid } ) ;
826-
827- return API . v1 . success ( ) ;
828- } ,
829- } ,
830- ) ;
831-
832896API . v1 . addRoute (
833897 'chat.getMentionedMessages' ,
834898 { authRequired : true , validateParams : isChatGetMentionedMessagesProps } ,
0 commit comments