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/green-dragons-boil.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@rocket.chat/rest-typings': patch
'@rocket.chat/meteor': patch
---

Fixes an issue where web clients could remain with a stale slashcommand list during a rolling workspace update
1 change: 0 additions & 1 deletion apps/meteor/.meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ rocketchat:version

accounts-base@3.1.2
accounts-facebook@1.3.4
accounts-github@1.5.1
accounts-google@1.4.1
accounts-meteor-developer@1.5.1
accounts-oauth@1.4.6
Expand Down
2 changes: 0 additions & 2 deletions apps/meteor/.meteor/versions
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
accounts-base@3.1.2
accounts-facebook@1.3.4
accounts-github@1.5.1
accounts-google@1.4.1
accounts-meteor-developer@1.5.1
accounts-oauth@1.4.6
Expand Down Expand Up @@ -35,7 +34,6 @@ facebook-oauth@1.11.6
facts-base@1.0.2
fetch@0.1.6
geojson-utils@1.0.12
github-oauth@1.4.2
google-oauth@1.4.5
hot-code-push@1.0.5
http@3.0.0
Expand Down
15 changes: 15 additions & 0 deletions apps/meteor/app/api/server/v1/commands.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Apps } from '@rocket.chat/apps';
import { Messages } from '@rocket.chat/models';
import { Random } from '@rocket.chat/random';
import objectPath from 'object-path';
Expand Down Expand Up @@ -143,6 +144,19 @@ API.v1.addRoute(
{ authRequired: true },
{
async get() {
if (!Apps.self?.isLoaded()) {
return {
statusCode: 202, // Accepted - apps are not ready, so the list is incomplete. Retry later
body: {
commands: [],
appsLoaded: false,
offset: 0,
count: 0,
total: 0,
},
};
}

const params = this.queryParams as Record<string, any>;
const { offset, count } = await getPaginationItems(params);
const { sort, query } = await this.parseJsonQuery();
Expand All @@ -161,6 +175,7 @@ API.v1.addRoute(
skip: offset,
limit: count,
}),
appsLoaded: true,
offset,
count: commands.length,
total: totalCount,
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/app/api/server/v1/emoji-custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ API.v1.addRoute(
});

await uploadEmojiCustomWithBuffer(this.userId, fileBuffer, mimetype, emojiData);
} catch (e) {
SystemLogger.error(e);
} catch (err) {
SystemLogger.error({ err });
return API.v1.failure();
}

Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/app/api/server/v1/ldap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ API.v1.addRoute(

try {
await LDAP.testConnection();
} catch (error) {
SystemLogger.error(error);
} catch (err) {
SystemLogger.error({ err });
throw new Error('Connection_failed');
}

Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/app/api/server/v1/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ API.v1.addRoute(
return API.v1.success(mountResult({ id, result }));
} catch (err) {
if (!(err as any).isClientSafe && !(err as any).meteorError) {
SystemLogger.error({ msg: `Exception while invoking method ${method}`, err });
SystemLogger.error({ msg: 'Exception while invoking method', err, method });
}

if (settings.get('Log_Level') === '2') {
Expand Down Expand Up @@ -576,7 +576,7 @@ API.v1.addRoute(
return API.v1.success(mountResult({ id, result }));
} catch (err) {
if (!(err as any).isClientSafe && !(err as any).meteorError) {
SystemLogger.error({ msg: `Exception while invoking method ${method}`, err });
SystemLogger.error({ msg: 'Exception while invoking method', err, method });
}
if (settings.get('Log_Level') === '2') {
Meteor._debug(`Exception while invoking method ${method}`, err);
Expand Down
11 changes: 8 additions & 3 deletions apps/meteor/app/authentication/server/lib/logLoginAttempts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ export const logFailedLoginAttempts = (login: ILoginAttempt): void => {
if (!settings.get('Login_Logs_UserAgent')) {
userAgent = '-';
}
SystemLogger.info(
`Failed login detected - Username[${user}] ClientAddress[${clientAddress}] ForwardedFor[${forwardedFor}] XRealIp[${realIp}] UserAgent[${userAgent}]`,
);
SystemLogger.info({
msg: 'Failed login detected',
user,
clientAddress,
forwardedFor,
realIp,
userAgent,
});
};
20 changes: 10 additions & 10 deletions apps/meteor/app/cloud/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,36 +23,36 @@ Meteor.startup(async () => {
}

console.log('Successfully registered with token provided by REG_TOKEN!');
} catch (e: any) {
SystemLogger.error('An error occurred registering with token.', e.message);
} catch (err: any) {
SystemLogger.error({ msg: 'An error occurred registering with token.', err });
}
}

setImmediate(async () => {
try {
await syncWorkspace();
} catch (e: any) {
if (e instanceof CloudWorkspaceAccessTokenEmptyError) {
} catch (err: any) {
if (err instanceof CloudWorkspaceAccessTokenEmptyError) {
return;
}
if (e.type && e.type === 'AbortError') {
if (err.type && err.type === 'AbortError') {
return;
}
SystemLogger.error('An error occurred syncing workspace.', e.message);
SystemLogger.error({ msg: 'An error occurred syncing workspace.', err });
}
});
const minute = Math.floor(Math.random() * 60);
await cronJobs.add(licenseCronName, `${minute} */12 * * *`, async () => {
try {
await syncWorkspace();
} catch (e: any) {
if (e instanceof CloudWorkspaceAccessTokenEmptyError) {
} catch (err: any) {
if (err instanceof CloudWorkspaceAccessTokenEmptyError) {
return;
}
if (e.type && e.type === 'AbortError') {
if (err.type && err.type === 'AbortError') {
return;
}
SystemLogger.error('An error occurred syncing workspace.', e.message);
SystemLogger.error({ msg: 'An error occurred syncing workspace.', err });
}
});
});
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/app/crowd/server/crowd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,8 @@ Accounts.registerLoginHandler('crowd', async function (this: typeof Accounts, lo

return result;
} catch (err: any) {
logger.debug({ err });
logger.error('Crowd user not authenticated due to an error');
logger.error({ msg: 'Crowd user not authenticated due to an error', err });

throw new Meteor.Error('user-not-found', err.message);
}
});
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/app/file-upload/server/methods/sendFileMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ export const parseFileIntoMessageAttachments = async (
typeGroup: thumbnail.typeGroup || '',
});
}
} catch (e) {
SystemLogger.error(e);
} catch (err) {
SystemLogger.error({ err });
}
attachments.push(attachment);
} else if (/^audio\/.+/.test(file.type as string)) {
Expand Down
8 changes: 4 additions & 4 deletions apps/meteor/app/file-upload/ufs/AmazonS3/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class AmazonS3Store extends UploadFS.Store {
try {
return s3.deleteObject(params).promise();
} catch (err: any) {
SystemLogger.error(err);
SystemLogger.error({ err });
}
};

Expand Down Expand Up @@ -184,9 +184,9 @@ class AmazonS3Store extends UploadFS.Store {
ContentType: file.type,
Bucket: classOptions.connection.params.Bucket,
},
(error) => {
if (error) {
SystemLogger.error(error);
(err) => {
if (err) {
SystemLogger.error({ err });
}

writeStream.emit('real_finish');
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/file-upload/ufs/GoogleStorage/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class GoogleStorageStore extends UploadFS.Store {
try {
return bucket.file(this.getPath(file)).delete();
} catch (err: any) {
SystemLogger.error(err);
SystemLogger.error({ err });
}
};

Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/file-upload/ufs/Webdav/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class WebdavStore extends UploadFS.Store {
try {
return client.deleteFile(this.getPath(file));
} catch (err: any) {
SystemLogger.error(err);
SystemLogger.error({ err });
}
};

Expand Down
1 change: 1 addition & 0 deletions apps/meteor/app/github/server/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './lib';
19 changes: 19 additions & 0 deletions apps/meteor/app/github/server/lib.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { OauthConfig } from '@rocket.chat/core-typings';

import { CustomOAuth } from '../../custom-oauth/server/custom_oauth_server';

const config: OauthConfig = {
serverURL: 'https://github.com',
identityPath: 'https://api.github.com/user',
tokenPath: 'https://github.com/login/oauth/access_token',
scope: 'user:email',
mergeUsers: false,
addAutopublishFields: {
forLoggedInUser: ['services.github'],
forOtherUsers: ['services.github.username'],
},
accessTokenParam: 'access_token',
identityTokenSentVia: 'header',
};

export const Github = new CustomOAuth('github', config);
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ export class MessageConverter extends RecordConverter<IImportMessageRecord> {
for await (const rid of this.rids) {
try {
await Rooms.resetLastMessageById(rid, null);
} catch (e) {
this._logger.warn({ msg: 'Failed to update last message of room', roomId: rid });
this._logger.error(e);
} catch (err) {
this._logger.error({ msg: 'Failed to update last message of room', roomId: rid, err });
}
}
}
Expand All @@ -70,9 +69,8 @@ export class MessageConverter extends RecordConverter<IImportMessageRecord> {

try {
await insertMessage(creator, msgObj as unknown as IDBMessage, rid, true);
} catch (e) {
this._logger.warn({ msg: 'Failed to import message', timestamp: msgObj.ts, roomId: rid });
this._logger.error(e);
} catch (err) {
this._logger.error({ msg: 'Failed to import message', timestamp: msgObj.ts, roomId: rid, err });
}
}

Expand Down Expand Up @@ -167,7 +165,7 @@ export class MessageConverter extends RecordConverter<IImportMessageRecord> {
}

if (!data.username) {
this._logger.debug(importId);
this._logger.debug({ msg: 'Mentioned user has no username', importId });
throw new Error('importer-message-mentioned-username-not-found');
}

Expand Down
7 changes: 4 additions & 3 deletions apps/meteor/app/integrations/server/lib/triggerHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,10 @@ class RocketChatIntegrationHandler {

// If no room could be found, we won't be sending any messages but we'll warn in the logs
if (!tmpRoom) {
outgoingLogger.warn(
`The Integration "${trigger.name}" doesn't have a room configured nor did it provide a room to send the message to.`,
);
outgoingLogger.warn({
msg: 'The Integration doesnt have a room configured nor did it provide a room to send the message to.',
integrationName: trigger.name,
});
return;
}

Expand Down
8 changes: 4 additions & 4 deletions apps/meteor/app/settings/server/CachedSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class CachedSettings
*/
public override has(_id: ISetting['_id']): boolean {
if (!this.ready && warn) {
SystemLogger.warn(`Settings not initialized yet. getting: ${_id}`);
SystemLogger.warn({ msg: 'Settings not initialized yet. getting', _id });
}
return this.store.has(_id);
}
Expand All @@ -120,7 +120,7 @@ export class CachedSettings
*/
public getSetting(_id: ISetting['_id']): ISetting | undefined {
if (!this.ready && warn) {
SystemLogger.warn(`Settings not initialized yet. getting: ${_id}`);
SystemLogger.warn({ msg: 'Settings not initialized yet. getting', _id });
}
return this.store.get(_id);
}
Expand All @@ -134,7 +134,7 @@ export class CachedSettings
*/
public get<T extends SettingValue = SettingValue>(_id: ISetting['_id']): T {
if (!this.ready && warn) {
SystemLogger.warn(`Settings not initialized yet. getting: ${_id}`);
SystemLogger.warn({ msg: 'Settings not initialized yet. getting', _id });
}
return this.store.get(_id)?.value as T;
}
Expand All @@ -148,7 +148,7 @@ export class CachedSettings
*/
public getByRegexp<T extends SettingValue = SettingValue>(_id: RegExp): [string, T][] {
if (!this.ready && warn) {
SystemLogger.warn(`Settings not initialized yet. getting: ${_id}`);
SystemLogger.warn({ msg: 'Settings not initialized yet. getting', _id });
}

return [...this.store.entries()].filter(([key]) => _id.test(key)).map(([key, setting]) => [key, setting.value]) as [string, T][];
Expand Down
6 changes: 3 additions & 3 deletions apps/meteor/app/settings/server/SettingsRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export class SettingsRegistry {
);

if (isSettingEnterprise(settingFromCode) && !('invalidValue' in settingFromCode)) {
SystemLogger.error(`Enterprise setting ${_id} is missing the invalidValue option`);
SystemLogger.error({ msg: 'Enterprise setting is missing the invalidValue option', _id });
throw new Error(`Enterprise setting ${_id} is missing the invalidValue option`);
}

Expand All @@ -145,7 +145,7 @@ export class SettingsRegistry {
try {
validateSetting(settingFromCode._id, settingFromCode.type, settingFromCode.value);
} catch (e) {
IS_DEVELOPMENT && SystemLogger.error(`Invalid setting code ${_id}: ${(e as Error).message}`);
IS_DEVELOPMENT && SystemLogger.error({ msg: 'Invalid setting code', _id, err: e as Error });
}

const isOverwritten = settingFromCode !== settingFromCodeOverwritten || (settingStored && settingStored !== settingStoredOverwritten);
Expand Down Expand Up @@ -189,7 +189,7 @@ export class SettingsRegistry {
try {
validateSetting(settingFromCode._id, settingFromCode.type, settingStored?.value);
} catch (e) {
IS_DEVELOPMENT && SystemLogger.error(`Invalid setting stored ${_id}: ${(e as Error).message}`);
IS_DEVELOPMENT && SystemLogger.error({ msg: 'Invalid setting stored', _id, err: e as Error });
}
return;
}
Expand Down
Loading
Loading