From 6d3bcfbd67658abeb33c70bc2eb8e8b9cc2119c6 Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Wed, 26 May 2021 16:32:30 -0300 Subject: [PATCH] [FIX] Method calls not sending date params as EJSON (#3159) --- app/lib/rocketchat.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/lib/rocketchat.js b/app/lib/rocketchat.js index 561e02c73..c1a7655f4 100644 --- a/app/lib/rocketchat.js +++ b/app/lib/rocketchat.js @@ -945,7 +945,13 @@ const RocketChat = { if (API_Use_REST_For_DDP_Calls) { return this.post(`method.call/${ method }`, { message: EJSON.stringify({ method, params }) }); } - return this.methodCall(method, ...params); + const parsedParams = params.map((param) => { + if (param instanceof Date) { + return { $date: new Date(param).getTime() }; + } + return param; + }); + return this.methodCall(method, ...parsedParams); }, getUserRoles() {