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
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export async function updatePriority(_id: string, data: Pick<ILivechatPriority,
const createdResult = await LivechatPriority.updatePriority(_id, data.reset || false, data.name);

if (!createdResult) {
logger.error(`Error updating priority: ${_id}. Unsuccessful result from mongodb. Result`, createdResult);
logger.error({ msg: 'Error updating priority: unsuccessful result from MongoDB', priorityId: _id, result: createdResult });
throw Error('error-unable-to-update-priority');
}

Expand Down
18 changes: 9 additions & 9 deletions apps/meteor/ee/server/lib/ldap/Manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,21 +360,21 @@ export class LDAPEEManager extends LDAPManager {
}

private static async createRoomForSync(channel: string): Promise<IRoom | undefined> {
logger.debug(`Channel '${channel}' doesn't exist, creating it.`);
logger.debug({ msg: "Channel doesn't exist, creating it", channel });

const roomOwner = settings.get<string>('LDAP_Sync_User_Data_Channels_Admin') || '';

const user = await Users.findOneByUsernameIgnoringCase(roomOwner);
if (!user) {
logger.error(`Unable to find user '${roomOwner}' to be the owner of the channel '${channel}'.`);
logger.error({ msg: 'Unable to find user to own channel', roomOwner, channel });
return;
}

const room = await createRoom('c', channel, user, [], false, false, {
customFields: { ldap: true },
});
if (!room?.rid) {
logger.error(`Unable to auto-create channel '${channel}' during ldap sync.`);
logger.error({ msg: 'Unable to auto-create channel during LDAP sync', channel });
return;
}

Expand Down Expand Up @@ -438,14 +438,14 @@ export class LDAPEEManager extends LDAPManager {
}

if (room.teamMain) {
logger.error(`Can't add user to channel ${userChannelName} because it is a team.`);
logger.error({ msg: "Can't add user to channel because it is a team", userChannelName });
} else {
channelsToAdd.add(room._id);
await addUserToRoom(room._id, user);
logger.debug(`Synced user channel ${room._id} from LDAP for ${username}`);
logger.debug({ msg: 'Synced user channel from LDAP', roomId: room._id, username });
}
} catch (e) {
logger.debug(`Failed to sync user room, user = ${username}, channel = ${userChannelName}`);
logger.debug({ msg: 'Failed to sync user room', username, userChannelName });
logger.error(e);
}
}
Expand Down Expand Up @@ -539,7 +539,7 @@ export class LDAPEEManager extends LDAPManager {

if (filteredMappedLdapGroups.length < ldapGroups.length) {
const unmappedLdapGroups = ldapGroups.filter((ldapGroup) => !mappedLdapGroups.includes(ldapGroup));
logger.error(`The following LDAP groups are not mapped in Rocket.Chat: "${unmappedLdapGroups.join(', ')}".`);
logger.error({ msg: 'The following LDAP groups are not mapped in Rocket.Chat', unmappedLdapGroups });
}

if (!filteredMappedLdapGroups.length) {
Expand Down Expand Up @@ -664,7 +664,7 @@ export class LDAPEEManager extends LDAPManager {
}

userData.deleted = deleted;
logger.info(`${deleted ? 'Deactivating' : 'Activating'} user ${userData.name} (${userData.username})`);
logger.info({ msg: 'Switching user status', name: userData.name, username: userData.username, active: !deleted });
}

public static copyCustomFields(ldapUser: ILDAPEntry, userData: IImportUser): void {
Expand Down Expand Up @@ -700,7 +700,7 @@ export class LDAPEEManager extends LDAPManager {
return;
}

logger.info('LDAP finished loading users. Users added to importer: ', count);
logger.info({ msg: 'LDAP finished loading users. Users added to importer', count });
resolve();
},
});
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/ee/server/patches/mergeContacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const runMergeContacts = async (
return originalContact;
}

logger.debug({ msg: `Found ${similarContacts.length} contacts to merge`, contactId });
logger.debug({ msg: 'Found contacts to merge', contactId, count: similarContacts.length });
for await (const similarContact of similarContacts) {
const fields = ContactMerger.getAllFieldsFromContact(similarContact);
await ContactMerger.mergeFieldsIntoContact({ fields, contact: originalContact, session });
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/ee/server/startup/federation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ const configureFederation = async () => {
processEDUTyping: settings.get('Federation_Service_EDU_Process_Typing'),
processEDUPresence: settings.get('Federation_Service_EDU_Process_Presence'),
});
} catch (error) {
logger.error('Failed to start federation-matrix service:', error);
} catch (err) {
logger.error({ msg: 'Failed to start federation-matrix service', err });
}
};

Expand Down
16 changes: 8 additions & 8 deletions apps/meteor/server/email/IMAPInterceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ export class IMAPInterceptor extends EventEmitter {
// On successfully connected.
this.imap.on('ready', async () => {
if (this.isActive()) {
logger.info(`IMAP connected to ${this.config.user}`);
logger.info({ msg: 'IMAP connected', user: this.config.user });
clearTimeout(this.backoff);
this.retries = 0;
this.backoffDurationMS = 3000;
await this.openInbox();
this.imap.on('mail', () => this.getEmails().catch((err: Error) => logger.debug('Error on getEmails: ', err.message)));
this.imap.on('mail', () => this.getEmails().catch((err: Error) => logger.debug({ msg: 'Error on getEmails', err })));
} else {
logger.error("Can't connect to IMAP server");
}
Expand Down Expand Up @@ -130,7 +130,7 @@ export class IMAPInterceptor extends EventEmitter {

async reconnect(): Promise<void> {
if (!this.isActive() && !this.canRetry()) {
logger.info(`Max retries reached for ${this.config.user}`);
logger.info({ msg: 'Max retries reached', user: this.config.user });
this.stop();
return this.selfDisable();
}
Expand Down Expand Up @@ -183,14 +183,14 @@ export class IMAPInterceptor extends EventEmitter {
const bodycb = (stream: NodeJS.ReadableStream, _info: ImapMessageBodyInfo): void => {
simpleParser(new Readable().wrap(stream), (_err, email) => {
if (this.options.rejectBeforeTS && email.date && email.date < this.options.rejectBeforeTS) {
logger.error({ msg: `Rejecting email on inbox ${this.config.user}`, subject: email.subject });
logger.error({ msg: 'Rejecting email on inbox', user: this.config.user, subject: email.subject });
return;
}
this.emit('email', email);
if (this.options.deleteAfterRead) {
this.imap.seq.addFlags(email, 'Deleted', (err) => {
if (err) {
logger.warn(`Mark deleted error: ${err}`);
logger.warn({ msg: 'Mark deleted error', err });
}
});
}
Expand All @@ -199,7 +199,7 @@ export class IMAPInterceptor extends EventEmitter {
msg.once('body', bodycb);
};
const errorcb = (err: Error): void => {
logger.warn(`Fetch error: ${err}`);
logger.warn({ msg: 'Fetch error', err });
reject(err);
};
const endcb = (): void => {
Expand Down Expand Up @@ -228,7 +228,7 @@ export class IMAPInterceptor extends EventEmitter {
}

async selfDisable(): Promise<void> {
logger.info(`Disabling inbox ${this.inboxId}`);
logger.info({ msg: 'Disabling inbox', inboxId: this.inboxId });

// Again, if there's 2 inboxes with the same email, this will prevent looping over the already disabled one
// Active filter is just in case :)
Expand All @@ -238,6 +238,6 @@ export class IMAPInterceptor extends EventEmitter {
void notifyOnEmailInboxChanged(value, 'updated');
}

logger.info(`IMAP inbox ${this.inboxId} automatically disabled`);
logger.info({ msg: 'IMAP inbox automatically disabled', inboxId: this.inboxId });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ export class BeforeSaveBadWords {

try {
this.badWordsRegex = new RegExp(`(?<=^|[\\p{P}\\p{Z}])(${badWords.join('|')})(?=$|[\\p{P}\\p{Z}])`, 'gmiu');
} catch (error) {
} catch (err) {
this.badWordsRegex = null;
this.logger.error('Erorr when initializing bad words filter', error);
this.logger.error({ msg: 'Error when initializing bad words filter', err });
}

if (goodWordsList?.length) {
Expand Down
6 changes: 3 additions & 3 deletions apps/meteor/server/settings/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const verifyFingerPrint = async function (emit = true) {
const fingerprint = generateFingerprint();

if (!DeploymentFingerPrintRecordHash) {
logger.info('Generating fingerprint for the first time', fingerprint);
logger.info({ msg: 'Generating fingerprint for the first time', fingerprint });
await updateFingerprint(fingerprint, true, emit);
return;
}
Expand All @@ -50,12 +50,12 @@ export const verifyFingerPrint = async function (emit = true) {
}

if (process.env.AUTO_ACCEPT_FINGERPRINT === 'true') {
logger.info('Updating fingerprint as AUTO_ACCEPT_FINGERPRINT is true', fingerprint);
logger.info({ msg: 'Updating fingerprint as AUTO_ACCEPT_FINGERPRINT is true', fingerprint });
await updateFingerprint(fingerprint, true, emit);
return;
}

logger.warn('Updating fingerprint as pending for admin verification', fingerprint);
logger.warn({ msg: 'Updating fingerprint as pending for admin verification', fingerprint });
await updateFingerprint(fingerprint, false, emit);
};

Expand Down
Loading
Loading