Chore: Hide deprecation query log on production (#26188)

Co-authored-by: Diego Sampaio <chinello@gmail.com>
pull/26264/head
Guilherme Gazzo 4 years ago committed by GitHub
parent 1731078d25
commit 37fa59c820
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      apps/meteor/app/api/server/helpers/parseJsonQuery.ts
  2. 7
      apps/meteor/app/api/server/v1/commands.ts
  3. 13
      apps/meteor/app/lib/server/startup/settingsOnLoadDirectReply.ts
  4. 2
      apps/meteor/server/models/raw/BaseRaw.ts

@ -11,6 +11,13 @@ const pathAllowConf = {
'def': ['$or', '$and', '$regex'],
};
const warnFields =
process.env.NODE_ENV !== 'production' || process.env.SHOW_WARNINGS === 'true'
? (...rest: any): void => {
console.warn(...rest, new Error().stack);
}
: new Function();
API.helperMethods.set(
'parseJsonQuery',
function _parseJsonQuery(this: {
@ -48,6 +55,7 @@ API.helperMethods.set(
let fields: Record<string, 0 | 1> | undefined;
if (this.queryParams.fields) {
warnFields('attribute fields is deprecated');
try {
fields = JSON.parse(this.queryParams.fields) as Record<string, 0 | 1>;
@ -98,7 +106,8 @@ API.helperMethods.set(
let query: Record<string, any> = {};
if (this.queryParams.query) {
this.logger.warn('attribute query is deprecated');
warnFields('attribute query is deprecated');
try {
query = EJSON.parse(this.queryParams.query);
query = clean(query, pathAllowConf.def);

@ -141,7 +141,7 @@ API.v1.addRoute(
{
get() {
const { offset, count } = this.getPaginationItems();
const { sort, fields, query } = this.parseJsonQuery();
const { sort, query } = this.parseJsonQuery();
let commands = Object.values(slashCommands.commands);
@ -151,16 +151,11 @@ API.v1.addRoute(
const totalCount = commands.length;
if (fields) {
console.warn('commands.list -> fields is deprecated and will be removed in 5.0.0');
}
return API.v1.success({
commands: processQueryOptionsOnResult(commands, {
sort: sort || { name: 1 },
skip: offset,
limit: count,
fields,
}),
offset,
count: commands.length,

@ -2,10 +2,11 @@ import _ from 'underscore';
import { settings } from '../../../settings/server';
import { DirectReplyIMAPInterceptor, POP3Helper } from '../lib/interceptDirectReplyEmails.js';
import { logger } from '../../../../server/features/EmailInbox/logger';
let client: DirectReplyIMAPInterceptor | POP3Helper | undefined;
const startEmailIntercepter = _.debounce(async function () {
console.log('Email Intercepter...');
const startEmailInterceptor = _.debounce(async function () {
logger.info('Email Interceptor...');
const protocol = settings.get('Direct_Reply_Protocol');
const isEnabled =
@ -21,10 +22,10 @@ const startEmailIntercepter = _.debounce(async function () {
}
if (!isEnabled) {
console.log('Email Intercepter Stopped...');
logger.info('Email Interceptor Stopped...');
return;
}
console.log('Starting Email Intercepter...');
logger.info('Starting Email Interceptor...');
if (protocol === 'IMAP') {
client = new DirectReplyIMAPInterceptor();
@ -37,6 +38,6 @@ const startEmailIntercepter = _.debounce(async function () {
}
}, 1000);
settings.watchByRegex(/^Direct_Reply_.+/, startEmailIntercepter);
settings.watchByRegex(/^Direct_Reply_.+/, startEmailInterceptor);
startEmailIntercepter();
startEmailInterceptor();

@ -30,7 +30,7 @@ import { getCollectionName } from '@rocket.chat/models';
import { setUpdatedAt } from '../../../app/models/server/lib/setUpdatedAt';
const warnFields =
process.env.NODE_ENV !== 'production'
process.env.NODE_ENV !== 'production' || process.env.SHOW_WARNINGS === 'true'
? (...rest: any): void => {
console.warn(...rest, new Error().stack);
}

Loading…
Cancel
Save