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
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
16 changes: 0 additions & 16 deletions packages/rocketchat-lib/client/AdminBox.coffee

This file was deleted.

19 changes: 19 additions & 0 deletions packages/rocketchat-lib/client/AdminBox.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
RocketChat.AdminBox = new class {
constructor() {
this.options = new ReactiveVar([]);
}
addOption(option) {
return Tracker.nonreactive(() => {
const actual = this.options.get();
actual.push(option);
return this.options.set(actual);
});
}
getOptions() {
return _.filter(this.options.get(), function(option) {
if ((option.permissionGranted == null) || option.permissionGranted()) {
return true;
}
});
}
};
12 changes: 0 additions & 12 deletions packages/rocketchat-lib/lib/configLogger.coffee

This file was deleted.

17 changes: 17 additions & 0 deletions packages/rocketchat-lib/lib/configLogger.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* globals LoggerManager */
RocketChat.settings.get('Log_Package', function(key, value) {
return LoggerManager.showPackage = value;
});

RocketChat.settings.get('Log_File', function(key, value) {
return LoggerManager.showFileAndLine = value;
});

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

This file was deleted.

8 changes: 8 additions & 0 deletions packages/rocketchat-lib/lib/core.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

Copy link
Member

Choose a reason for hiding this comment

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

Where is the .coffee file?

/*
* Kick off the global namespace for RocketChat.
* @namespace RocketChat
*/
RocketChat = {
models: {}
};
18 changes: 9 additions & 9 deletions packages/rocketchat-lib/package.js
Original file line number Diff line number Diff line change
@@ -45,15 +45,15 @@ Package.onUse(function(api) {
api.use('templating', 'client');
api.use('kadira:flow-router');

api.addFiles('lib/core.coffee');
api.addFiles('lib/core.js');

// DEBUGGER
api.addFiles('server/lib/debug.js', 'server');

// COMMON LIB
api.addFiles('lib/getURL.js');
api.addFiles('lib/settings.coffee');
api.addFiles('lib/configLogger.coffee');
api.addFiles('lib/configLogger.js');
api.addFiles('lib/callbacks.coffee');
api.addFiles('lib/fileUploadRestrictions.js');
api.addFiles('lib/placeholders.js');
@@ -105,7 +105,7 @@ Package.onUse(function(api) {
// SERVER MODELS
api.addFiles('server/models/_Base.js', 'server');
api.addFiles('server/models/Messages.coffee', 'server');
api.addFiles('server/models/Reports.coffee', 'server');
api.addFiles('server/models/Reports.js', 'server');
api.addFiles('server/models/Rooms.coffee', 'server');
api.addFiles('server/models/Settings.coffee', 'server');
api.addFiles('server/models/Subscriptions.coffee', 'server');
@@ -122,7 +122,7 @@ Package.onUse(function(api) {
api.addFiles('server/startup/cache/CacheLoad.js', 'server');

// SERVER PUBLICATIONS
api.addFiles('server/publications/settings.coffee', 'server');
api.addFiles('server/publications/settings.js', 'server');

// SERVER METHODS
api.addFiles('server/methods/addOAuthService.js', 'server');
@@ -164,10 +164,10 @@ Package.onUse(function(api) {
api.addFiles('server/methods/updateMessage.js', 'server');

// SERVER STARTUP
api.addFiles('server/startup/settingsOnLoadCdnPrefix.coffee', 'server');
api.addFiles('server/startup/settingsOnLoadSMTP.coffee', 'server');
api.addFiles('server/startup/oAuthServicesUpdate.coffee', 'server');
api.addFiles('server/startup/settings.coffee', 'server');
api.addFiles('server/startup/settingsOnLoadCdnPrefix.js', 'server');
api.addFiles('server/startup/settingsOnLoadSMTP.js', 'server');
api.addFiles('server/startup/oAuthServicesUpdate.js', 'server');
api.addFiles('server/startup/settings.js', 'server');

// COMMON STARTUP
api.addFiles('lib/startup/settingsOnLoadSiteUrl.coffee');
@@ -187,7 +187,7 @@ Package.onUse(function(api) {

// CLIENT METHODS
api.addFiles('client/methods/sendMessage.coffee', 'client');
api.addFiles('client/AdminBox.coffee', 'client');
api.addFiles('client/AdminBox.js', 'client');
api.addFiles('client/MessageAction.coffee', 'client');

api.addFiles('client/defaultTabBars.js', 'client');
17 changes: 0 additions & 17 deletions packages/rocketchat-lib/server/models/Reports.coffee

This file was deleted.

16 changes: 16 additions & 0 deletions packages/rocketchat-lib/server/models/Reports.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
RocketChat.models.Reports = new class extends RocketChat.models._Base {
constructor() {
super('reports');
}
createWithMessageDescriptionAndUserId(message, description, userId, extraData) {
const record = {
message,
description,
ts: new Date(),
userId
};
_.extend(record, extraData);
record._id = this.insert(record);
return record;
}
};
50 changes: 0 additions & 50 deletions packages/rocketchat-lib/server/publications/settings.coffee

This file was deleted.

71 changes: 71 additions & 0 deletions packages/rocketchat-lib/server/publications/settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
Meteor.methods({
'public-settings/get'(updatedAt) {
this.unblock();
const records = RocketChat.models.Settings.find().fetch().filter(function(record) {
return record.hidden !== true && record['public'] === true;
});
if (updatedAt instanceof Date) {
return {
update: records.filter(function(record) {
return record._updatedAt > updatedAt;
}),
remove: RocketChat.models.Settings.trashFindDeletedAfter(updatedAt, {
hidden: {
$ne: true
},
'public': true
}, {
fields: {
_id: 1,
_deletedAt: 1
}
}).fetch()
};
}
return records;
},
'private-settings/get'(updatedAt) {
if (!Meteor.userId()) {
return [];
}
this.unblock();
if (!RocketChat.authz.hasPermission(Meteor.userId(), 'view-privileged-setting')) {
return [];
}
const records = RocketChat.models.Settings.find().fetch().filter(function(record) {
return record.hidden !== true;
});
if (updatedAt instanceof Date) {
return {
update: records.filter(function(record) {
return record._updatedAt > updatedAt;
}),
remove: RocketChat.models.Settings.trashFindDeletedAfter(updatedAt, {
hidden: {
$ne: true
}
}, {
fields: {
_id: 1,
_deletedAt: 1
}
}).fetch()
};
}
return records;
}
});

RocketChat.models.Settings.cache.on('changed', function(type, setting) {
if (setting['public'] === true) {
RocketChat.Notifications.notifyAllInThisInstance('public-settings-changed', type, _.pick(setting, '_id', 'value'));
}
return RocketChat.Notifications.notifyLoggedInThisInstance('private-settings-changed', type, setting);
});

RocketChat.Notifications.streamAll.allowRead('private-settings-changed', function() {
if (this.userId == null) {
return false;
}
return RocketChat.authz.hasPermission(this.userId, 'view-privileged-setting');
});
78 changes: 0 additions & 78 deletions packages/rocketchat-lib/server/startup/oAuthServicesUpdate.coffee

This file was deleted.

Loading