Skip to content

Commit

Permalink
Merge branch 'develop' into fix/keycloak_oauth_channels_map
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusbsilva137 authored Nov 3, 2022
2 parents 930c2cd + a9a1aae commit ae193fc
Show file tree
Hide file tree
Showing 36 changed files with 123 additions and 127 deletions.
18 changes: 8 additions & 10 deletions apps/meteor/app/api/server/v1/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -553,14 +553,13 @@ API.v1.addRoute(

const result = Meteor.call(method, ...params);
return API.v1.success(mountResult({ id, result }));
} catch (error) {
if (error instanceof Error) SystemLogger.error(`Exception while invoking method ${method}`, error.message);
else SystemLogger.error(`Exception while invoking method ${method}`, error);
} catch (err) {
SystemLogger.error({ msg: `Exception while invoking method ${method}`, err });

if (settings.get('Log_Level') === '2') {
Meteor._debug(`Exception while invoking method ${method}`, error);
Meteor._debug(`Exception while invoking method ${method}`, err);
}
return API.v1.success(mountResult({ id, error }));
return API.v1.success(mountResult({ id, error: err }));
}
},
},
Expand Down Expand Up @@ -612,14 +611,13 @@ API.v1.addRoute(

const result = Meteor.call(method, ...params);
return API.v1.success(mountResult({ id, result }));
} catch (error) {
if (error instanceof Error) SystemLogger.error(`Exception while invoking method ${method}`, error.message);
else SystemLogger.error(`Exception while invoking method ${method}`, error);
} catch (err) {
SystemLogger.error({ msg: `Exception while invoking method ${method}`, err });

if (settings.get('Log_Level') === '2') {
Meteor._debug(`Exception while invoking method ${method}`, error);
Meteor._debug(`Exception while invoking method ${method}`, err);
}
return API.v1.success(mountResult({ id, error }));
return API.v1.success(mountResult({ id, error: err }));
}
},
},
Expand Down
8 changes: 4 additions & 4 deletions apps/meteor/app/autotranslate/server/deeplTranslate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ class DeeplAutoTranslate extends AutoTranslate {
.join('\n');
translations[language] = this.deTokenize(Object.assign({}, message, { msg: translatedText }));
}
} catch (e) {
SystemLogger.error('Error translating message', e);
} catch (err) {
SystemLogger.error({ msg: 'Error translating message', err });
}
});
return translations;
Expand Down Expand Up @@ -272,8 +272,8 @@ class DeeplAutoTranslate extends AutoTranslate {
translations[language] = result.data.translations.map((translation: IDeepLTranslation) => translation.text);
}
}
} catch (e) {
SystemLogger.error('Error translating message attachment', e);
} catch (err) {
SystemLogger.error({ msg: 'Error translating message attachment', err });
}
});
return translations;
Expand Down
8 changes: 4 additions & 4 deletions apps/meteor/app/autotranslate/server/googleTranslate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ class GoogleAutoTranslate extends AutoTranslate {
const txt = result.data.data.translations.map((translation: IGoogleTranslation) => translation.translatedText).join('\n');
translations[language] = this.deTokenize(Object.assign({}, message, { msg: txt }));
}
} catch (e) {
SystemLogger.error('Error translating message', e);
} catch (err) {
SystemLogger.error({ msg: 'Error translating message', err });
}
});
return translations;
Expand Down Expand Up @@ -206,8 +206,8 @@ class GoogleAutoTranslate extends AutoTranslate {
.map((translation: IGoogleTranslation) => translation.translatedText)
.join('\n');
}
} catch (e) {
SystemLogger.error('Error translating message', e);
} catch (err) {
SystemLogger.error({ msg: 'Error translating message', err });
}
});
return translations;
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/cas/server/cas_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const middleware = function (req, res, next) {
closePopup(res);
});
} catch (err) {
logger.error(`Unexpected error : ${err.message}`);
logger.error({ msg: 'Unexpected error', err });
closePopup(res);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export async function getWorkspaceLicense(): Promise<{ updated: boolean; license
} catch (err: any) {
SystemLogger.error({
msg: 'Failed to update license from Rocket.Chat Cloud',
url: '/license',
...(err.response?.data && { cloudError: err.response.data }),
err,
});
Expand Down
1 change: 1 addition & 0 deletions apps/meteor/app/cloud/server/functions/syncWorkspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export async function syncWorkspace(reconnectCheck = false) {
} catch (err: any) {
SystemLogger.error({
msg: 'Failed to sync with Rocket.Chat Cloud',
url: '/client',
...(err.response?.data && { cloudError: err.response.data }),
err,
});
Expand Down
27 changes: 14 additions & 13 deletions apps/meteor/app/crowd/server/crowd.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ export class CROWD {

try {
crowdUser = self.fetchCrowdUser(crowd_username);
} catch (error) {
logger.debug(error);
logger.error('Could not sync user with username', crowd_username);
} catch (err) {
logger.debug({ err });
logger.error({ msg: 'Could not sync user with username', crowd_username });

const email = user.emails[0].address;
logger.info('Attempting to find for user by email', email);
Expand Down Expand Up @@ -272,8 +272,8 @@ export class CROWD {
return {
userId: crowdUser._id,
};
} catch (error) {
logger.error('Error creating new crowd user.', error.message);
} catch (err) {
logger.error({ msg: 'Error creating new crowd user.', err });
}
}
}
Expand Down Expand Up @@ -304,8 +304,8 @@ Accounts.registerLoginHandler('crowd', function (loginRequest) {
}

return crowd.updateUserCollection(user);
} catch (error) {
logger.debug(error);
} catch (err) {
logger.debug({ err });
logger.error('Crowd user not authenticated due to an error');
}
});
Expand Down Expand Up @@ -362,10 +362,11 @@ Meteor.methods({
message: 'Connection success',
params: [],
};
} catch (error) {
logger.error(
'Invalid crowd connection details, check the url and application username/password and make sure this server is allowed to speak to crowd',
);
} catch (err) {
logger.error({
msg: 'Invalid crowd connection details, check the url and application username/password and make sure this server is allowed to speak to crowd',
err,
});
throw new Meteor.Error('Invalid connection details', '', { method: 'crowd_test_connection' });
}
},
Expand All @@ -392,8 +393,8 @@ Meteor.methods({
message: `User data synced in ${actual} seconds`,
params: [],
};
} catch (error) {
logger.error('Error syncing user data. ', error.message);
} catch (err) {
logger.error({ msg: 'Error syncing user data. ', err });
throw new Meteor.Error('Error syncing user data', '', { method: 'crowd_sync_users' });
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ Meteor.methods({
const rs = RocketChatFile.bufferToStream(file);
RocketChatFileCustomSoundsInstance.deleteFile(`${soundData._id}.${soundData.extension}`);
const ws = RocketChatFileCustomSoundsInstance.createWriteStream(`${soundData._id}.${soundData.extension}`, contentType);
ws.on(
'end',
setTimeout(() => api.broadcast('notify.updateCustomSound', { soundData }), 500),
);
ws.on('end', () => setTimeout(() => api.broadcast('notify.updateCustomSound', { soundData }), 500));

rs.pipe(ws);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ export class MatrixBridge implements IFederationBridge {
await this.bridgeInstance.run(this.bridgePort);
this.isRunning = true;
}
} catch (e) {
federationBridgeLogger.error('Failed to initialize the matrix-appservice-bridge.', e);
} catch (err) {
federationBridgeLogger.error({ msg: 'Failed to initialize the matrix-appservice-bridge.', err });
} finally {
this.isUpdatingBridgeStatus = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export class HipChatEnterpriseImporter extends Base {
} else if (m.GuestAccessMessage) {
this.logger.warn('Guess Access Notification was ignored.');
} else {
this.logger.error("HipChat Enterprise importer isn't configured to handle this message:", m);
this.logger.error({ msg: "HipChat Enterprise importer isn't configured to handle this message:", file: m });
}
}

Expand Down Expand Up @@ -327,7 +327,7 @@ export class HipChatEnterpriseImporter extends Base {
);

this.extract.on('error', (err) => {
this.logger.error('extract error:', err);
this.logger.error({ msg: 'extract error:', err });
reject(new Meteor.Error('error-import-file-extract-error'));
});

Expand All @@ -342,7 +342,7 @@ export class HipChatEnterpriseImporter extends Base {
const gunzip = this.zlib.createGunzip();

gunzip.on('error', (err) => {
this.logger.error('extract error:', err);
this.logger.error({ msg: 'extract error:', err });
reject(new Meteor.Error('error-import-file-extract-error'));
});
this.logger.debug('start extracting import file');
Expand Down
12 changes: 6 additions & 6 deletions apps/meteor/app/lib/server/methods/sendMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,19 @@ export function executeSendMessage(uid, message) {

metrics.messagesSent.inc(); // TODO This line needs to be moved to it's proper place. See the comments on: https://github.com/RocketChat/Rocket.Chat/pull/5736
return sendMessage(user, message, room, false);
} catch (error) {
SystemLogger.error('Error sending message:', error);
} catch (err) {
SystemLogger.error({ msg: 'Error sending message:', err });

const errorMessage = typeof error === 'string' ? error : error.error || error.message;
const errorMessage = typeof err === 'string' ? err : err.error || err.message;
api.broadcast('notify.ephemeralMessage', uid, message.rid, {
msg: TAPi18n.__(errorMessage, {}, user.language),
});

if (typeof error === 'string') {
throw new Error(error);
if (typeof err === 'string') {
throw new Error(err);
}

throw error;
throw err;
}
}

Expand Down
6 changes: 3 additions & 3 deletions apps/meteor/app/livechat/imports/server/rest/facebook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ API.v1.addRoute(
// @ts-expect-error - Typings on Livechat.sendMessage are wrong
message: await Livechat.sendMessage(sendMessage),
});
} catch (e) {
Livechat.logger.error('Error using Facebook ->', e);
return API.v1.failure(e);
} catch (err) {
Livechat.logger.error({ msg: 'Error using Facebook ->', err });
return API.v1.failure(err);
}
},
},
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/app/livechat/imports/server/rest/sms.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ API.v1.addRoute('livechat/sms-incoming/:service', {
} else {
attachment.title_link_download = true;
}
} catch (e) {
Livechat.logger.error(`Attachment upload failed: ${e.message}`);
} catch (err) {
Livechat.logger.error({ msg: 'Attachment upload failed', err });
attachment = {
fields: [
{
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/app/livechat/server/lib/Livechat.js
Original file line number Diff line number Diff line change
Expand Up @@ -819,8 +819,8 @@ export const Livechat = {
};
try {
return HTTP.post(settings.get('Livechat_webhookUrl'), options);
} catch (e) {
Livechat.webhookLogger.error(`Response error on ${11 - attempts} try ->`, e);
} catch (err) {
Livechat.webhookLogger.error({ msg: `Response error on ${11 - attempts} try ->`, err });
// try 10 times after 10 seconds each
attempts - 1 && Livechat.webhookLogger.warn('Will try again in 10 seconds ...');
setTimeout(
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/app/livechat/server/lib/routing/External.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class ExternalQueue {
};
}
}
} catch (e) {
SystemLogger.error('Error requesting agent from external queue.', e);
} catch (err) {
SystemLogger.error({ msg: 'Error requesting agent from external queue.', err });
break;
}
}
Expand Down
20 changes: 10 additions & 10 deletions apps/meteor/app/livechat/server/methods/facebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,20 @@ Meteor.methods({
return OmniChannel.unsubscribe(options.page);
}
}
} catch (e) {
if (e.response && e.response.data && e.response.data.error) {
if (e.response.data.error.error) {
throw new Meteor.Error(e.response.data.error.error, e.response.data.error.message);
} catch (err) {
if (err.response && err.response.data && err.response.data.error) {
if (err.response.data.error.error) {
throw new Meteor.Error(err.response.data.error.error, err.response.data.error.message);
}
if (e.response.data.error.response) {
throw new Meteor.Error('integration-error', e.response.data.error.response.error.message);
if (err.response.data.error.response) {
throw new Meteor.Error('integration-error', err.response.data.error.response.error.message);
}
if (e.response.data.error.message) {
throw new Meteor.Error('integration-error', e.response.data.error.message);
if (err.response.data.error.message) {
throw new Meteor.Error('integration-error', err.response.data.error.message);
}
}
SystemLogger.error('Error contacting omni.rocket.chat:', e);
throw new Meteor.Error('integration-error', e.error);
SystemLogger.error({ msg: 'Error contacting omni.rocket.chat:', err });
throw new Meteor.Error('integration-error', err.error);
}
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ class NotificationClass {
setTimeout(() => {
try {
this.worker();
} catch (e) {
SystemLogger.error('Error sending notification', e);
} catch (err) {
SystemLogger.error({ msg: 'Error sending notification', err });
this.executeWorkerLater();
}
}, this.cyclePause);
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/app/oembed/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ const getUrlMeta = async function (
let content: OEmbedUrlContentResult | undefined;
try {
content = await getUrlContent(urlObj, 5);
} catch (e) {
log.error('Error fetching url content', e);
} catch (err) {
log.error({ msg: 'Error fetching url content', err });
}

if (!content) {
Expand Down
5 changes: 2 additions & 3 deletions apps/meteor/app/push/server/apn.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ export const initAPN = ({ options, absoluteUrl }) => {
// Rig apn connection
try {
apnConnection = new apn.Provider(options.apn);
} catch (e) {
logger.error('Error trying to initialize APN');
logger.error(e);
} catch (err) {
logger.error({ msg: 'Error trying to initialize APN', err });
}
};
2 changes: 1 addition & 1 deletion apps/meteor/app/push/server/push.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export class PushClass {
return;
}

logger.error(`Error sending push to gateway (${tries} try) ->`, error);
logger.error({ msg: `Error sending push to gateway (${tries} try) ->`, err: error });

if (tries <= 4) {
// [1, 2, 4, 8, 16] minutes (total 31)
Expand Down
Loading

0 comments on commit ae193fc

Please sign in to comment.