diff --git a/.changeset/polite-turkeys-fetch.md b/.changeset/polite-turkeys-fetch.md new file mode 100644 index 0000000000000..b442a2e682426 --- /dev/null +++ b/.changeset/polite-turkeys-fetch.md @@ -0,0 +1,6 @@ +--- +"@rocket.chat/meteor": patch +"@rocket.chat/core-services": patch +--- + +Fixes an issue where the bypass to call methods over microservices always returns to `{}` diff --git a/apps/meteor/server/services/meteor/service.ts b/apps/meteor/server/services/meteor/service.ts index a3653f2c36356..1378e9d41466d 100644 --- a/apps/meteor/server/services/meteor/service.ts +++ b/apps/meteor/server/services/meteor/service.ts @@ -262,18 +262,25 @@ export class MeteorService extends ServiceClassInternal implements IMeteor { return LoginServiceConfigurationModel.find({}, { projection: { secret: 0 } }).toArray(); } - async callMethodWithToken(userId: string, token: string, method: string, args: any[]): Promise { + async callMethodWithToken( + userId: string, + token: string, + method: string, + args: any[], + ): Promise<{ + result: unknown; + }> { const user = await Users.findOneByIdAndLoginHashedToken(userId, token, { projection: { _id: 1 }, }); if (!user) { return { - result: Meteor.callAsync(method, ...args), + result: await Meteor.callAsync(method, ...args), }; } return { - result: Meteor.runAsUser(userId, () => Meteor.callAsync(method, ...args)), + result: await Meteor.runAsUser(userId, () => Meteor.callAsync(method, ...args)), }; } diff --git a/packages/core-services/src/types/IMeteor.ts b/packages/core-services/src/types/IMeteor.ts index f905f7d7cddce..09f4e4470a20c 100644 --- a/packages/core-services/src/types/IMeteor.ts +++ b/packages/core-services/src/types/IMeteor.ts @@ -17,7 +17,14 @@ export type AutoUpdateRecord = { export interface IMeteor extends IServiceClass { getAutoUpdateClientVersions(): Promise>; getLoginServiceConfiguration(): Promise; - callMethodWithToken(userId: string | undefined, token: string | undefined, method: string, args: any[]): Promise; + callMethodWithToken( + userId: string | undefined, + token: string | undefined, + method: string, + args: any[], + ): Promise<{ + result: unknown; + }>; notifyGuestStatusChanged(token: string, status: string): Promise; getURL(path: string, params?: Record, cloudDeepLinkUrl?: string): Promise; }