@@ -415,7 +415,10 @@ export default class EmbeddedChatApi implements IChatProvider {
415415
416416 if ( suggestedUsername . success ) {
417417 const response2 = await fetch ( `${ this . host } /api/v1/users.update` , {
418- body : `{"userId": "${ userid } ", "data": { "username": "${ suggestedUsername . result } " }}` ,
418+ body : JSON . stringify ( {
419+ userId : userid ,
420+ data : { username : suggestedUsername . result } ,
421+ } ) ,
419422 headers : {
420423 "Content-Type" : "application/json" ,
421424 "X-Auth-Token" : authToken ,
@@ -440,7 +443,10 @@ export default class EmbeddedChatApi implements IChatProvider {
440443 try {
441444 const { userId, authToken } = ( await this . auth . getCurrentUser ( ) ) || { } ;
442445 const response = await fetch ( `${ this . host } /api/v1/users.update` , {
443- body : `{"userId": "${ userid } ", "data": { "username": "${ newUserName } " }}` ,
446+ body : JSON . stringify ( {
447+ userId : userid ,
448+ data : { username : newUserName } ,
449+ } ) ,
444450 headers : {
445451 "Content-Type" : "application/json" ,
446452 "X-Auth-Token" : authToken ,
@@ -633,7 +639,7 @@ export default class EmbeddedChatApi implements IChatProvider {
633639 try {
634640 const { userId, authToken } = ( await this . auth . getCurrentUser ( ) ) || { } ;
635641 const messages = await fetch (
636- `${ this . host } /api/v1/chat.getThreadMessages?roomId= ${ this . rid } & tmid=${ tmid } ` ,
642+ `${ this . host } /api/v1/chat.getThreadMessages?tmid=${ tmid } ` ,
637643 {
638644 headers : {
639645 "Content-Type" : "application/json" ,
@@ -777,7 +783,7 @@ export default class EmbeddedChatApi implements IChatProvider {
777783 try {
778784 const { userId, authToken } = ( await this . auth . getCurrentUser ( ) ) || { } ;
779785 const response = await fetch ( `${ this . host } /api/v1/chat.delete` , {
780- body : `{" roomId": " ${ this . rid } ", " msgId": " ${ msgId } "}` ,
786+ body : JSON . stringify ( { roomId : this . rid , msgId } ) ,
781787 headers : {
782788 "Content-Type" : "application/json" ,
783789 "X-Auth-Token" : authToken ,
@@ -795,7 +801,7 @@ export default class EmbeddedChatApi implements IChatProvider {
795801 try {
796802 const { userId, authToken } = ( await this . auth . getCurrentUser ( ) ) || { } ;
797803 const response = await fetch ( `${ this . host } /api/v1/chat.update` , {
798- body : `{" roomId": " ${ this . rid } ", " msgId": " ${ msgId } ","text" : " ${ text } " }` ,
804+ body : JSON . stringify ( { roomId : this . rid , msgId, text } ) ,
799805 headers : {
800806 "Content-Type" : "application/json" ,
801807 "X-Auth-Token" : authToken ,
@@ -855,7 +861,7 @@ export default class EmbeddedChatApi implements IChatProvider {
855861 try {
856862 const { userId, authToken } = ( await this . auth . getCurrentUser ( ) ) || { } ;
857863 const response = await fetch ( `${ this . host } /api/v1/chat.starMessage` , {
858- body : `{" messageId": " ${ mid } "}` ,
864+ body : JSON . stringify ( { messageId : mid } ) ,
859865 headers : {
860866 "Content-Type" : "application/json" ,
861867 "X-Auth-Token" : authToken ,
@@ -873,7 +879,7 @@ export default class EmbeddedChatApi implements IChatProvider {
873879 try {
874880 const { userId, authToken } = ( await this . auth . getCurrentUser ( ) ) || { } ;
875881 const response = await fetch ( `${ this . host } /api/v1/chat.unStarMessage` , {
876- body : `{" messageId": " ${ mid } "}` ,
882+ body : JSON . stringify ( { messageId : mid } ) ,
877883 headers : {
878884 "Content-Type" : "application/json" ,
879885 "X-Auth-Token" : authToken ,
@@ -951,7 +957,7 @@ export default class EmbeddedChatApi implements IChatProvider {
951957 try {
952958 const { userId, authToken } = ( await this . auth . getCurrentUser ( ) ) || { } ;
953959 const response = await fetch ( `${ this . host } /api/v1/chat.pinMessage` , {
954- body : `{" messageId": " ${ mid } "}` ,
960+ body : JSON . stringify ( { messageId : mid } ) ,
955961 headers : {
956962 "Content-Type" : "application/json" ,
957963 "X-Auth-Token" : authToken ,
@@ -971,7 +977,7 @@ export default class EmbeddedChatApi implements IChatProvider {
971977 try {
972978 const { userId, authToken } = ( await this . auth . getCurrentUser ( ) ) || { } ;
973979 const response = await fetch ( `${ this . host } /api/v1/chat.unPinMessage` , {
974- body : `{" messageId": " ${ mid } "}` ,
980+ body : JSON . stringify ( { messageId : mid } ) ,
975981 headers : {
976982 "Content-Type" : "application/json" ,
977983 "X-Auth-Token" : authToken ,
@@ -989,7 +995,11 @@ export default class EmbeddedChatApi implements IChatProvider {
989995 try {
990996 const { userId, authToken } = ( await this . auth . getCurrentUser ( ) ) || { } ;
991997 const response = await fetch ( `${ this . host } /api/v1/chat.react` , {
992- body : `{"messageId": "${ messageId } ", "emoji": "${ emoji } ", "shouldReact": ${ shouldReact } }` ,
998+ body : JSON . stringify ( {
999+ messageId,
1000+ emoji,
1001+ shouldReact,
1002+ } ) ,
9931003 headers : {
9941004 "Content-Type" : "application/json" ,
9951005 "X-Auth-Token" : authToken ,
@@ -1007,7 +1017,7 @@ export default class EmbeddedChatApi implements IChatProvider {
10071017 try {
10081018 const { userId, authToken } = ( await this . auth . getCurrentUser ( ) ) || { } ;
10091019 const response = await fetch ( `${ this . host } /api/v1/chat.reportMessage` , {
1010- body : `{"messageId": " ${ messageId } ", " description": " ${ description } "}` ,
1020+ body : JSON . stringify ( { messageId, description } ) ,
10111021 headers : {
10121022 "Content-Type" : "application/json" ,
10131023 "X-Auth-Token" : authToken ,
@@ -1192,7 +1202,15 @@ export default class EmbeddedChatApi implements IChatProvider {
11921202 return data ;
11931203 }
11941204
1195- async execCommand ( { command, params } : { command : string ; params : string } ) {
1205+ async execCommand ( {
1206+ command,
1207+ params,
1208+ tmid,
1209+ } : {
1210+ command : string ;
1211+ params : string ;
1212+ tmid ?: string ;
1213+ } ) {
11961214 const { userId, authToken } = ( await this . auth . getCurrentUser ( ) ) || { } ;
11971215 const response = await fetch ( `${ this . host } /api/v1/commands.run` , {
11981216 headers : {
@@ -1204,6 +1222,7 @@ export default class EmbeddedChatApi implements IChatProvider {
12041222 body : JSON . stringify ( {
12051223 command,
12061224 params,
1225+ tmid,
12071226 roomId : this . rid ,
12081227 triggerId : Math . random ( ) . toString ( 32 ) . slice ( 2 , 20 ) ,
12091228 } ) ,
0 commit comments