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

Remove dependency of RC namespace in rc-blockstack, bot-helpers and cas #13246

Merged
merged 63 commits into from
Jan 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
6f749bc
Move integrations models to rc-models
MarcosSpessatto Jan 21, 2019
5dec8ce
Move composeMessage function to rc-utils
MarcosSpessatto Jan 21, 2019
583cb87
Move PushNotifications class to push-notifications package
MarcosSpessatto Jan 21, 2019
039e7cd
Import variables to remove dependency of RC namespace
MarcosSpessatto Jan 21, 2019
d49540b
Import variables to remove RC namespace dependency inside rc-lib/serv…
MarcosSpessatto Jan 22, 2019
4cede2e
Import variables to remove RC namespace inside rc-lib/server/methods
MarcosSpessatto Jan 22, 2019
5ecc7b8
Import variables to remove dependency with RC namespace
MarcosSpessatto Jan 22, 2019
f3280a6
Remove duplicated server settings located in rc-lib
MarcosSpessatto Jan 22, 2019
f526680
Merge remote-tracking branch 'origin/depackaging' into globals/rc-lib…
rodrigok Jan 22, 2019
8d4c70f
Merge branch 'globals/rc-lib-wave-5' into globals/rc-lib-wave-6
MarcosSpessatto Jan 22, 2019
fb7666d
Merge branch 'globals/rc-lib-wave-6' into globals/lib-settings
MarcosSpessatto Jan 22, 2019
f457877
Export function and lib function of rc-lib but keep it inside RC name…
MarcosSpessatto Jan 22, 2019
3b6ffa6
Import variables from functions and lib to remove RC namespace depend…
MarcosSpessatto Jan 22, 2019
27043cb
Merge remote-tracking branch 'origin/depackaging' into globals/lib-fu…
rodrigok Jan 22, 2019
6ab7f28
Remove dependency of RC namespace in rc-sandstorm
MarcosSpessatto Jan 22, 2019
f00a322
Merge branch 'globals/lib-functions' into globals/lib-functions-import
MarcosSpessatto Jan 22, 2019
6043a3d
Merge branch 'globals/lib-functions-import' into globals/lib-x-sandstorm
MarcosSpessatto Jan 22, 2019
568ed1f
Remove dependency of RC namespace in chatpal-search
MarcosSpessatto Jan 23, 2019
36c17f2
Merge remote-tracking branch 'origin/depackaging' into globals/lib-fu…
rodrigok Jan 23, 2019
08d8bd1
Merge remote-tracking branch 'origin/globals/lib-functions-import' in…
rodrigok Jan 23, 2019
06a780f
Merge remote-tracking branch 'origin/depackaging' into globals/lib-x-…
rodrigok Jan 23, 2019
5d60447
Move CreadentialTokens model to rc-models
MarcosSpessatto Jan 23, 2019
dd9303f
Move getUsernameSuggestion function and method from server/ to rc-lib
MarcosSpessatto Jan 23, 2019
842a519
Remove dependency of RC namespace in meteor saml
MarcosSpessatto Jan 23, 2019
76b17c8
Merge branch 'globals/lib-x-sandstorm' into globals/lib-x-chatpal-search
rodrigok Jan 23, 2019
9645e02
Merge remote-tracking branch 'origin/depackaging' into globals/lib-x-…
rodrigok Jan 23, 2019
ba81c02
Remove dependency of RC namespace in rc-theme
MarcosSpessatto Jan 23, 2019
c32491e
Merge branch 'globals/lib-x-chatpal-search' into globals/rc-x-saml
rodrigok Jan 23, 2019
df3c3f8
Merge remote-tracking branch 'origin/depackaging' into globals/rc-x-saml
rodrigok Jan 23, 2019
1290be4
Move 2FA Users model to rc-models
MarcosSpessatto Jan 23, 2019
25b121e
Remove dependency of RC namespace in rc-2fa
MarcosSpessatto Jan 23, 2019
9a4ee66
Merge branch 'globals/rc-x-saml' into globals/rc-x-theme
MarcosSpessatto Jan 23, 2019
41de984
Merge branch 'globals/rc-x-theme' into globals/rc-x-2fa
MarcosSpessatto Jan 23, 2019
025eb99
Merge remote-tracking branch 'origin/depackaging' into globals/rc-x-t…
rodrigok Jan 23, 2019
a7bf7a9
Remove dependency of RC namespace in rc-action-links
MarcosSpessatto Jan 23, 2019
eff1176
Add action links in the RC namespace
MarcosSpessatto Jan 23, 2019
2503f08
Remove dependency of RC namespace in rc-analytics
MarcosSpessatto Jan 23, 2019
0c95868
Remove dependency of RC namespace in rc-assets
MarcosSpessatto Jan 23, 2019
2174cee
Add Assets in RC namespace
MarcosSpessatto Jan 23, 2019
e0cf4d6
Remove dependency of RC namespace in rc-autolinker
MarcosSpessatto Jan 23, 2019
fb28dea
Move autotranslate models to rc-models
MarcosSpessatto Jan 23, 2019
83c3373
Partial remove dependency of Rc namespace in rc-autotranslate
MarcosSpessatto Jan 23, 2019
e687a9b
Remove dependency of RC namespace in rc-markdown
MarcosSpessatto Jan 23, 2019
fe90277
Finish of remotion of RC namespace in rc-autotranslate
MarcosSpessatto Jan 23, 2019
05e7858
Import Autotranslate where it has been used
MarcosSpessatto Jan 23, 2019
f052849
Merge branch 'globals/rc-x-theme' into globals/rc-x-2fa
rodrigok Jan 23, 2019
d8bcac7
Merge remote-tracking branch 'origin/depackaging' into globals/rc-x-2fa
rodrigok Jan 23, 2019
4ec3a96
Fix lint
MarcosSpessatto Jan 23, 2019
5e4dfa8
Merge branch 'globals/rc-x-2fa' into globals/rc-x-action-links
rodrigok Jan 23, 2019
49b0372
Merge remote-tracking branch 'origin/depackaging' into globals/rc-x-a…
rodrigok Jan 23, 2019
ac592ae
Rename Assets variable to avoid conflicts
MarcosSpessatto Jan 23, 2019
9ea47dd
Merge branch 'globals/rc-x-action-links' into globals/lib-x-analytics…
rodrigok Jan 23, 2019
c16e5d9
Merge remote-tracking branch 'origin/depackaging' into globals/lib-x-…
rodrigok Jan 23, 2019
23922e5
Fix rename Assets
MarcosSpessatto Jan 24, 2019
b8f6905
Merge branch 'globals/lib-x-analytics-assets' into globals/lib-x-auto…
MarcosSpessatto Jan 24, 2019
9575227
Remove dependency of RC namespace in rc-blockstack
MarcosSpessatto Jan 24, 2019
85d0c1d
Remove RC dependency in bot-helpers
MarcosSpessatto Jan 24, 2019
4a3ebd6
Remove RC dependency in rc-cas
MarcosSpessatto Jan 24, 2019
ffcd36d
Merge remote-tracking branch 'origin/depackaging' into globals/lib-x-…
rodrigok Jan 24, 2019
5d3d0a5
Fix wrong imports
MarcosSpessatto Jan 24, 2019
2bbe5d8
Merge remote-tracking branch 'origin/globals/lib-x-autolinker-autotra…
MarcosSpessatto Jan 24, 2019
467ad3f
Merge branch 'globals/lib-x-autolinker-autotranslate' into globals/li…
MarcosSpessatto Jan 24, 2019
5d90f9b
Merge remote-tracking branch 'origin/depackaging' into globals/lib-x-…
rodrigok Jan 24, 2019
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
10 changes: 7 additions & 3 deletions packages/rocketchat-blockstack/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ Package.describe({
});

Package.onUse((api) => {
api.use('ecmascript');

api.use([
'ecmascript',
'rocketchat:settings',
'rocketchat:assets',
'rocketchat:models',
'rocketchat:lib',
]);
api.mainModule('server/main.js', 'server');

api.mainModule('client/main.js', 'client');
});
11 changes: 6 additions & 5 deletions packages/rocketchat-blockstack/server/loginHandler.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';
import { RocketChat } from 'meteor/rocketchat:lib';

import { settings } from 'meteor/rocketchat:settings';
import { Users } from 'meteor/rocketchat:models';
import { setUserAvatar } from 'meteor/rocketchat:lib';
import { updateOrCreateUser } from './userHandler';
import { handleAccessToken } from './tokenHandler';
import { logger } from './logger';
Expand All @@ -12,7 +13,7 @@ Accounts.registerLoginHandler('blockstack', (loginRequest) => {
return;
}

if (!RocketChat.settings.get('Blockstack_Enable')) {
if (!settings.get('Blockstack_Enable')) {
return;
}

Expand All @@ -35,10 +36,10 @@ Accounts.registerLoginHandler('blockstack', (loginRequest) => {

if (result.isNew) {
try {
const user = RocketChat.models.Users.findOneById(result.userId, { fields: { 'services.blockstack.image': 1, username: 1 } });
const user = Users.findOneById(result.userId, { fields: { 'services.blockstack.image': 1, username: 1 } });
if (user && user.services && user.services.blockstack && user.services.blockstack.image) {
Meteor.runAsUser(user._id, () => {
RocketChat.setUserAvatar(user, user.services.blockstack.image, undefined, 'url');
setUserAvatar(user, user.services.blockstack.image, undefined, 'url');
});
}
} catch (e) {
Expand Down
9 changes: 5 additions & 4 deletions packages/rocketchat-blockstack/server/routes.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { Meteor } from 'meteor/meteor';
import { WebApp } from 'meteor/webapp';
import { RocketChat } from 'meteor/rocketchat:lib';
import { settings } from 'meteor/rocketchat:settings';
import { RocketChatAssets } from 'meteor/rocketchat:assets';

WebApp.connectHandlers.use('/_blockstack/manifest', Meteor.bindEnvironment(function(req, res) {
const name = RocketChat.settings.get('Site_Name');
const name = settings.get('Site_Name');
const startUrl = Meteor.absoluteUrl();
const description = RocketChat.settings.get('Blockstack_Auth_Description');
const iconUrl = RocketChat.Assets.getURL('Assets_favicon_192');
const description = settings.get('Blockstack_Auth_Description');
const iconUrl = RocketChatAssets.getURL('Assets_favicon_192');

res.writeHead(200, {
'Content-Type': 'application/json',
Expand Down
15 changes: 7 additions & 8 deletions packages/rocketchat-blockstack/server/settings.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import _ from 'underscore';
import { Meteor } from 'meteor/meteor';
import { RocketChat } from 'meteor/rocketchat:lib';

import { settings } from 'meteor/rocketchat:settings';
import { ServiceConfiguration } from 'meteor/service-configuration';
import { logger } from './logger';

Expand All @@ -18,7 +17,7 @@ const defaults = {
};

Meteor.startup(() => {
RocketChat.settings.addGroup('Blockstack', function() {
settings.addGroup('Blockstack', function() {
this.add('Blockstack_Enable', defaults.enable, {
type: 'boolean',
i18nLabel: 'Enable',
Expand All @@ -37,10 +36,10 @@ Meteor.startup(() => {

// Helper to return all Blockstack settings
const getSettings = () => Object.assign({}, defaults, {
enable: RocketChat.settings.get('Blockstack_Enable'),
authDescription: RocketChat.settings.get('Blockstack_Auth_Description'),
buttonLabelText: RocketChat.settings.get('Blockstack_ButtonLabelText'),
generateUsername: RocketChat.settings.get('Blockstack_Generate_Username'),
enable: settings.get('Blockstack_Enable'),
authDescription: settings.get('Blockstack_Auth_Description'),
buttonLabelText: settings.get('Blockstack_ButtonLabelText'),
generateUsername: settings.get('Blockstack_Generate_Username'),
});

const configureService = _.debounce(Meteor.bindEnvironment(() => {
Expand All @@ -64,7 +63,7 @@ const configureService = _.debounce(Meteor.bindEnvironment(() => {

// Add settings to auth provider configs on startup
Meteor.startup(() => {
RocketChat.settings.get(/^Blockstack_.+/, () => {
settings.get(/^Blockstack_.+/, () => {
configureService();
});
});
1 change: 0 additions & 1 deletion packages/rocketchat-blockstack/server/tokenHandler.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { decodeToken } from 'blockstack';

import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';
import { Match, check } from 'meteor/check';
Expand Down
4 changes: 2 additions & 2 deletions packages/rocketchat-blockstack/server/userHandler.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';
import { ServiceConfiguration } from 'meteor/service-configuration';
import { RocketChat } from 'meteor/rocketchat:lib';
import { generateUsernameSuggestion } from 'meteor/rocketchat:lib';
import { logger } from './logger';

// Updates or creates a user after we authenticate with Blockstack
Expand Down Expand Up @@ -53,7 +53,7 @@ export const updateOrCreateUser = (serviceData, options) => {
if (profile.username && profile.username !== '') {
newUser.username = profile.username;
} else if (serviceConfig.generateUsername === true) {
newUser.username = RocketChat.generateUsernameSuggestion(newUser);
newUser.username = generateUsernameSuggestion(newUser);
}
// If no username at this point it will suggest one from the name

Expand Down
4 changes: 3 additions & 1 deletion packages/rocketchat-bot-helpers/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ Package.describe({
Package.onUse(function(api) {
api.use([
'ecmascript',
'rocketchat:lib',
'rocketchat:settings',
'rocketchat:models',
'rocketchat:authorization',
'accounts-base',
]);
api.mainModule('server/index.js', 'server');
Expand Down
16 changes: 9 additions & 7 deletions packages/rocketchat-bot-helpers/server/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import './settings';
import { Meteor } from 'meteor/meteor';
import { RocketChat } from 'meteor/rocketchat:lib';
import { Users, Rooms } from 'meteor/rocketchat:models';
import { settings } from 'meteor/rocketchat:settings';
import { hasRole } from 'meteor/rocketchat:authorization';
import _ from 'underscore';

/**
Expand All @@ -25,8 +27,8 @@ class BotHelpers {
fieldsSetting.forEach((n) => {
this.userFields[n.trim()] = 1;
});
this._allUsers = RocketChat.models.Users.find(this.queries.users, { fields: this.userFields });
this._onlineUsers = RocketChat.models.Users.find({ $and: [this.queries.users, this.queries.online] }, { fields: this.userFields });
this._allUsers = Users.find(this.queries.users, { fields: this.userFields });
this._onlineUsers = Users.find({ $and: [this.queries.users, this.queries.online] }, { fields: this.userFields });
}

// request methods or props as arguments to Meteor.call
Expand All @@ -49,7 +51,7 @@ class BotHelpers {
}

addUserToRoom(userName, room) {
const foundRoom = RocketChat.models.Rooms.findOneByIdOrName(room);
const foundRoom = Rooms.findOneByIdOrName(room);

if (!_.isObject(foundRoom)) {
throw new Meteor.Error('invalid-channel');
Expand All @@ -62,7 +64,7 @@ class BotHelpers {
}

removeUserFromRoom(userName, room) {
const foundRoom = RocketChat.models.Rooms.findOneByIdOrName(room);
const foundRoom = Rooms.findOneByIdOrName(room);

if (!_.isObject(foundRoom)) {
throw new Meteor.Error('invalid-channel');
Expand Down Expand Up @@ -150,14 +152,14 @@ class BotHelpers {
const botHelpers = new BotHelpers();

// init cursors with fields setting and update on setting change
RocketChat.settings.get('BotHelpers_userFields', function(settingKey, settingValue) {
settings.get('BotHelpers_userFields', function(settingKey, settingValue) {
botHelpers.setupCursors(settingValue);
});

Meteor.methods({
botRequest: (...args) => {
const userID = Meteor.userId();
if (userID && RocketChat.authz.hasRole(userID, 'bot')) {
if (userID && hasRole(userID, 'bot')) {
return botHelpers.request(...args);
} else {
throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'botRequest' });
Expand Down
4 changes: 2 additions & 2 deletions packages/rocketchat-bot-helpers/server/settings.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Meteor } from 'meteor/meteor';
import { RocketChat } from 'meteor/rocketchat:lib';
import { settings } from 'meteor/rocketchat:settings';

Meteor.startup(function() {
RocketChat.settings.addGroup('Bots', function() {
settings.addGroup('Bots', function() {
this.add('BotHelpers_userFields', '_id, name, username, emails, language, utcOffset', {
type: 'string',
section: 'Helpers',
Expand Down
8 changes: 4 additions & 4 deletions packages/rocketchat-cas/client/cas_client.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';
import { Random } from 'meteor/random';
import { RocketChat } from 'meteor/rocketchat:lib';
import { settings } from 'meteor/rocketchat:settings';

const openCenteredPopup = function(url, width, height) {

Expand Down Expand Up @@ -29,9 +29,9 @@ Meteor.loginWithCas = function(options, callback) {
options = options || {};

const credentialToken = Random.id();
const login_url = RocketChat.settings.get('CAS_login_url');
const popup_width = RocketChat.settings.get('CAS_popup_width');
const popup_height = RocketChat.settings.get('CAS_popup_height');
const login_url = settings.get('CAS_login_url');
const popup_width = settings.get('CAS_popup_width');
const popup_height = settings.get('CAS_popup_height');

if (!login_url) {
return;
Expand Down
2 changes: 2 additions & 0 deletions packages/rocketchat-cas/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Package.onUse(function(api) {
api.use([
'ecmascript',
'rocketchat:lib',
'rocketchat:models',
'rocketchat:settings',
'rocketchat:logger',
'service-configuration',
'routepolicy',
Expand Down
24 changes: 12 additions & 12 deletions packages/rocketchat-cas/server/cas_rocketchat.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Meteor } from 'meteor/meteor';
import { Logger } from 'meteor/rocketchat:logger';
import { RocketChat } from 'meteor/rocketchat:lib';
import { settings } from 'meteor/rocketchat:settings';
import { ServiceConfiguration } from 'meteor/service-configuration';
export const logger = new Logger('CAS', {});

Meteor.startup(function() {
RocketChat.settings.addGroup('CAS', function() {
settings.addGroup('CAS', function() {
this.add('CAS_enabled', false, { type: 'boolean', group: 'CAS', public: true });
this.add('CAS_base_url', '', { type: 'string', group: 'CAS', public: true });
this.add('CAS_login_url', '', { type: 'string', group: 'CAS', public: true });
Expand Down Expand Up @@ -39,16 +39,16 @@ function updateServices(/* record*/) {
timer = Meteor.setTimeout(function() {
const data = {
// These will pe passed to 'node-cas' as options
enabled: RocketChat.settings.get('CAS_enabled'),
base_url: RocketChat.settings.get('CAS_base_url'),
login_url: RocketChat.settings.get('CAS_login_url'),
enabled: settings.get('CAS_enabled'),
base_url: settings.get('CAS_base_url'),
login_url: settings.get('CAS_login_url'),
// Rocketchat Visuals
buttonLabelText: RocketChat.settings.get('CAS_button_label_text'),
buttonLabelColor: RocketChat.settings.get('CAS_button_label_color'),
buttonColor: RocketChat.settings.get('CAS_button_color'),
width: RocketChat.settings.get('CAS_popup_width'),
height: RocketChat.settings.get('CAS_popup_height'),
autoclose: RocketChat.settings.get('CAS_autoclose'),
buttonLabelText: settings.get('CAS_button_label_text'),
buttonLabelColor: settings.get('CAS_button_label_color'),
buttonColor: settings.get('CAS_button_color'),
width: settings.get('CAS_popup_width'),
height: settings.get('CAS_popup_height'),
autoclose: settings.get('CAS_autoclose'),
};

// Either register or deregister the CAS login service based upon its configuration
Expand All @@ -62,6 +62,6 @@ function updateServices(/* record*/) {
}, 2000);
}

RocketChat.settings.get(/^CAS_.+/, (key, value) => {
settings.get(/^CAS_.+/, (key, value) => {
updateServices(value);
});
31 changes: 16 additions & 15 deletions packages/rocketchat-cas/server/cas_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';
import { Random } from 'meteor/random';
import { WebApp } from 'meteor/webapp';
import { RocketChat } from 'meteor/rocketchat:lib';
import { settings } from 'meteor/rocketchat:settings';
import { RoutePolicy } from 'meteor/routepolicy';
import { Rooms, Subscriptions, CredentialTokens } from 'meteor/rocketchat:models';
import { _setRealName } from 'meteor/rocketchat:lib';
import { logger } from './cas_rocketchat';
import _ from 'underscore';

import fiber from 'fibers';
import url from 'url';
import CAS from 'cas';
Expand All @@ -22,16 +23,16 @@ const closePopup = function(res) {
const casTicket = function(req, token, callback) {

// get configuration
if (!RocketChat.settings.get('CAS_enabled')) {
if (!settings.get('CAS_enabled')) {
logger.error('Got ticket validation request, but CAS is not enabled');
callback();
}

// get ticket and validate.
const parsedUrl = url.parse(req.url, true);
const ticketId = parsedUrl.query.ticket;
const baseUrl = RocketChat.settings.get('CAS_base_url');
const cas_version = parseFloat(RocketChat.settings.get('CAS_version'));
const baseUrl = settings.get('CAS_base_url');
const cas_version = parseFloat(settings.get('CAS_version'));
const appUrl = Meteor.absoluteUrl().replace(/\/$/, '') + __meteor_runtime_config__.ROOT_URL_PATH_PREFIX;
logger.debug(`Using CAS_base_url: ${ baseUrl }`);

Expand All @@ -52,7 +53,7 @@ const casTicket = function(req, token, callback) {
if (details && details.attributes) {
_.extend(user_info, { attributes: details.attributes });
}
RocketChat.models.CredentialTokens.create(token, user_info);
CredentialTokens.create(token, user_info);
} else {
logger.error(`Unable to validate ticket: ${ ticketId }`);
}
Expand Down Expand Up @@ -116,16 +117,16 @@ Accounts.registerLoginHandler(function(options) {
return undefined;
}

const credentials = RocketChat.models.CredentialTokens.findOneById(options.cas.credentialToken);
const credentials = CredentialTokens.findOneById(options.cas.credentialToken);
if (credentials === undefined) {
throw new Meteor.Error(Accounts.LoginCancelledError.numericError,
'no matching login attempt found');
}

const result = credentials.userInfo;
const syncUserDataFieldMap = RocketChat.settings.get('CAS_Sync_User_Data_FieldMap').trim();
const cas_version = parseFloat(RocketChat.settings.get('CAS_version'));
const sync_enabled = RocketChat.settings.get('CAS_Sync_User_Data_Enabled');
const syncUserDataFieldMap = settings.get('CAS_Sync_User_Data_FieldMap').trim();
const cas_version = parseFloat(settings.get('CAS_version'));
const sync_enabled = settings.get('CAS_Sync_User_Data_Enabled');

// We have these
const ext_attrs = {
Expand Down Expand Up @@ -196,7 +197,7 @@ Accounts.registerLoginHandler(function(options) {
logger.debug('Syncing user attributes');
// Update name
if (int_attrs.name) {
RocketChat._setRealName(user._id, int_attrs.name);
_setRealName(user._id, int_attrs.name);
}

// Update email
Expand Down Expand Up @@ -248,13 +249,13 @@ Accounts.registerLoginHandler(function(options) {
if (int_attrs.rooms) {
_.each(int_attrs.rooms.split(','), function(room_name) {
if (room_name) {
let room = RocketChat.models.Rooms.findOneByNameAndType(room_name, 'c');
let room = Rooms.findOneByNameAndType(room_name, 'c');
if (!room) {
room = RocketChat.models.Rooms.createWithIdTypeAndName(Random.id(), 'c', room_name);
room = Rooms.createWithIdTypeAndName(Random.id(), 'c', room_name);
}

if (!RocketChat.models.Subscriptions.findOneByRoomIdAndUserId(room._id, userId)) {
RocketChat.models.Subscriptions.createWithRoomAndUser(room, user, {
if (!Subscriptions.findOneByRoomIdAndUserId(room._id, userId)) {
Subscriptions.createWithRoomAndUser(room, user, {
ts: new Date(),
open: true,
alert: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-lib/server/functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export { saveCustomFieldsWithoutValidation } from './saveCustomFieldsWithoutVali
export { saveUser } from './saveUser';
export { sendMessage } from './sendMessage';
export { setEmail } from './setEmail';
export { setRealName } from './setRealName';
export { setRealName, _setRealName } from './setRealName';
export { setUserAvatar } from './setUserAvatar';
export { setUsername } from './setUsername';
export { unarchiveRoom } from './unarchiveRoom';
Expand Down
Loading