Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rocketchat-lib part1 #6553

Merged
merged 4 commits into from
Apr 4, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 8 additions & 6 deletions packages/rocketchat-lib/lib/configLogger.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
/* globals LoggerManager */
function log(fn = () => {}) {
return typeof LoggerManager !== 'undefined' && fn(LoggerManager);
}

RocketChat.settings.get('Log_Package', function(key, value) {
return (typeof LoggerManager !== 'undefined') && LoggerManager !== null && (LoggerManager.showPackage = value);
return log(LoggerManager => LoggerManager.showPackage = value);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not LoggerManager && LoggerManager.showPackage = value?

});

RocketChat.settings.get('Log_File', function(key, value) {
return typeof LoggerManager !== 'undefined' && LoggerManager !== null && (LoggerManager.showFileAndLine = value);
return log(LoggerManager => LoggerManager.showFileAndLine = value);
});

RocketChat.settings.get('Log_Level', function(key, value) {
if (value != null) {
if (typeof LoggerManager !== 'undefined' && LoggerManager !== null) {
LoggerManager.logLevel = parseInt(value);
}
log(LoggerManager => LoggerManager.logLevel = parseInt(value));
Meteor.setTimeout(() => {
return typeof LoggerManager !== 'undefined' && LoggerManager !== null && LoggerManager.enable(true);
return log(LoggerManager => LoggerManager.enable(true));
}, 200);
}
});
7 changes: 0 additions & 7 deletions packages/rocketchat-lib/lib/core.coffee

This file was deleted.

3 changes: 0 additions & 3 deletions packages/rocketchat-lib/server/models/Reports.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
// hasProp = {}.hasOwnProperty;

RocketChat.models.Reports = new class extends RocketChat.models._Base {
constructor() {
super('reports');
Expand Down
9 changes: 4 additions & 5 deletions packages/rocketchat-lib/server/startup/oAuthServicesUpdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ function debounce(fn, delay) {

function _OAuthServicesUpdate() {
const services = RocketChat.settings.get(/^(Accounts_OAuth_|Accounts_OAuth_Custom-)[a-z0-9_]+$/i);
const results = [];
services.forEach((service) => {
logger.oauth_updated(service.key);
let serviceName = service.key.replace('Accounts_OAuth_', '');
Expand Down Expand Up @@ -70,15 +69,15 @@ function _OAuthServicesUpdate() {
data.consumerKey = data.clientId;
delete data.clientId;
}
results.push(ServiceConfiguration.configurations.upsert({
ServiceConfiguration.configurations.upsert({
service: serviceName.toLowerCase()
}, {
$set: data
}));
});
} else {
results.push(ServiceConfiguration.configurations.remove({
ServiceConfiguration.configurations.remove({
service: serviceName.toLowerCase()
}));
});
}
});
}
Expand Down
4 changes: 4 additions & 0 deletions packages/rocketchat-lib/server/startup/settings.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
// Insert server unique id if it doesn't exist
RocketChat.settings.add('uniqueID', process.env.DEPLOYMENT_ID || Random.id(), {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you keep the comments?

'public': true,
hidden: true
});

// When you define a setting and want to add a description, you don't need to automatically define the i18nDescription
// if you add a node to the i18n.json with the same setting name but with `_Description` it will automatically work.

RocketChat.settings.addGroup('Accounts', function() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you keep the comments?

this.add('Accounts_AllowDeleteOwnAccount', false, {
type: 'boolean',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
/* globals WebAppInternals*/
function testWebAppInternals(fn) {
typeof WebAppInternals !== 'undefined' && fn(WebAppInternals);
}
RocketChat.settings.onload('CDN_PREFIX', function(key, value) {
if (_.isString(value || false)) {
return typeof WebAppInternals !== 'undefined' && WebAppInternals !== null && WebAppInternals.setBundledJsCssPrefix(value);
return testWebAppInternals(WebAppInternals => WebAppInternals.setBundledJsCssPrefix(value));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not WebAppInternals && WebAppInternals.setBundledJsCssPrefix(value)?

}
});

Meteor.startup(function() {
const value = RocketChat.settings.get('CDN_PREFIX');
if (_.isString(value || false)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any string value will be considered true?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My wish was testing if the variable is a string or it is not an empty string.

"asda"||false - > "asda"
""||false - > false

because _.isString("") === true

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, but that looks strange and will allow spaces. What about if (_.isString(value) && value.trim()) just to be more clear?

return typeof WebAppInternals !== 'undefined' && WebAppInternals !== null && WebAppInternals.setBundledJsCssPrefix(value);
return testWebAppInternals(WebAppInternals => WebAppInternals.setBundledJsCssPrefix(value));
}
});