Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'wrapper-call-meteor-methods-over-rest' of github.com:Ro…
…cketChat/Rocket.Chat into wrapper-call-meteor-methods-over-rest * 'wrapper-call-meteor-methods-over-rest' of github.com:RocketChat/Rocket.Chat: Use EJSON to transport data Fix design review (#17133) Regression: Direct message creation by REST (#17109) Overwrite rate limiter Add setting to turn it off
- Loading branch information
Showing
13 changed files
with
113 additions
and
85 deletions.
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
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 |
---|---|---|
@@ -1,26 +1,32 @@ | ||
import { Meteor } from 'meteor/meteor'; | ||
import { Tracker } from 'meteor/tracker'; | ||
import { EJSON } from 'meteor/ejson'; | ||
|
||
import { APIClient } from '../../app/utils/client'; | ||
|
||
Meteor.call = function _meteorCallOverREST(method: string, ...params: any): void { | ||
const endpoint = Tracker.nonreactive(() => (!Meteor.userId() ? 'method.callAnon' : 'method.call')); | ||
((): void => { | ||
if (!window.USE_REST_FOR_DDP_CALLS) { | ||
return; | ||
} | ||
Meteor.call = function _meteorCallOverREST(method: string, ...params: any): void { | ||
const endpoint = Tracker.nonreactive(() => (!Meteor.userId() ? 'method.callAnon' : 'method.call')); | ||
|
||
const restParams = { | ||
method, | ||
params, | ||
}; | ||
let callback = params.pop(); | ||
if (typeof callback !== 'function') { | ||
params.push(callback); | ||
callback = (): void => { | ||
// empty | ||
}; | ||
} | ||
|
||
let callback = params.pop(); | ||
if (typeof callback !== 'function') { | ||
params.push(callback); | ||
callback = (): void => { | ||
// empty | ||
const restParams = { | ||
method, | ||
params: params && EJSON.stringify(params), | ||
}; | ||
} | ||
|
||
// not using async to not change Meteor.call return type | ||
APIClient.v1.post(endpoint, restParams) | ||
.then(({ result }) => callback(null, result)) | ||
.catch((error) => callback(error)); | ||
}; | ||
// not using async to not change Meteor.call return type | ||
APIClient.v1.post(endpoint, restParams) | ||
.then(({ result }) => callback(null, EJSON.parse(result))) | ||
.catch((error) => callback(error)); | ||
}; | ||
})(); |
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,8 @@ | ||
export {}; | ||
|
||
declare global { | ||
// eslint-disable-next-line @typescript-eslint/interface-name-prefix | ||
interface Window { | ||
USE_REST_FOR_DDP_CALLS?: boolean; | ||
} | ||
} |
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