Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/polite-turkeys-fetch.md
Original file line number Diff line number Diff line change
@@ -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 `{}`
13 changes: 10 additions & 3 deletions apps/meteor/server/services/meteor/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void | any> {
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)),
};
}

Expand Down
9 changes: 8 additions & 1 deletion packages/core-services/src/types/IMeteor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,14 @@ export type AutoUpdateRecord = {
export interface IMeteor extends IServiceClass {
getAutoUpdateClientVersions(): Promise<Record<string, AutoUpdateRecord>>;
getLoginServiceConfiguration(): Promise<LoginServiceConfiguration[]>;
callMethodWithToken(userId: string | undefined, token: string | undefined, method: string, args: any[]): Promise<void | any>;
callMethodWithToken(
userId: string | undefined,
token: string | undefined,
method: string,
args: any[],
): Promise<{
result: unknown;
}>;
notifyGuestStatusChanged(token: string, status: string): Promise<void>;
getURL(path: string, params?: Record<string, any>, cloudDeepLinkUrl?: string): Promise<string>;
}
Loading