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-oauth2-server and message-star #13344

Merged
merged 84 commits into from
Feb 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
171754e
Remove some dependencies inside rocketchat-lib/client (#13210)
MarcosSpessatto Jan 21, 2019
f536345
Remove some dependencies inside rocketchat-lib/lib (#13212)
MarcosSpessatto Jan 21, 2019
118634c
Remove some dependencies inside rocketchat-lib/server/functions (#13214)
MarcosSpessatto Jan 22, 2019
2bf63fb
Remove some dependencies inside rocketchat-lib/server/lib (#13217)
MarcosSpessatto Jan 22, 2019
3f1451f
Remove some dependencies inside rocketchat-lib/server/methods (#13218)
MarcosSpessatto Jan 22, 2019
23388c4
Remove some dependencies inside rocketchat-lib/server/startup, public…
MarcosSpessatto Jan 22, 2019
23547e9
Remove duplicated server settings (#13223)
MarcosSpessatto Jan 22, 2019
45b5dd0
Export functions and lib function of rc-lib but keep it inside RC na…
MarcosSpessatto Jan 23, 2019
a233ad7
Import variables from functions and lib to remove RC namespace depen…
MarcosSpessatto Jan 23, 2019
96f6fa1
Remove dependency of RC namespace in rc-sandstorm (#13227)
MarcosSpessatto Jan 23, 2019
4a3c69a
Remove dependency of RC namespace in chatpal-search (#13231)
MarcosSpessatto Jan 23, 2019
54b152f
Remove dependency of RC namespace in meteor saml (#13233)
MarcosSpessatto Jan 23, 2019
b3906fa
Remove dependency of RC namespace in rc-theme (#13234)
MarcosSpessatto Jan 23, 2019
9bd766a
Remove dependency of RC namespace in rc-2fa (#13235)
MarcosSpessatto Jan 23, 2019
86ae7c8
Remove dependency of RC namespace in rc-action-links (#13236)
MarcosSpessatto Jan 23, 2019
ed81de8
Remove dependency of RC namespace in rc-analytics and rc-assets (#13…
MarcosSpessatto Jan 24, 2019
a5e4f43
Remove dependency of RC namespace in rc-markdown, rc-autolinker and …
MarcosSpessatto Jan 24, 2019
258d258
Remove dependency of RC namespace in rc-blockstack, bot-helpers and …
MarcosSpessatto Jan 24, 2019
b9e1538
Remove dependency of RC namespace in rc-channel-settings (#13251)
MarcosSpessatto Jan 24, 2019
aff4cfe
Remove dependency of RC namespace in rc-channel-mail-messages and cl…
MarcosSpessatto Jan 24, 2019
02436be
Remove dependency of RC namespace in rc-colors, cors, crowd and dolp…
MarcosSpessatto Jan 24, 2019
5528c0f
Remove dependency of RC namespace in rc-emoji-custom and drupal (#13…
MarcosSpessatto Jan 25, 2019
c70a809
Remove dependency of RC namespace in rc-emojione, error-handler, gh-e…
MarcosSpessatto Jan 25, 2019
ffa0945
Remove dependency of RC namespace in rc-google-natural-language, gran…
MarcosSpessatto Jan 25, 2019
9ea6306
Remove dependency of RC namespace in rc-iframe-login and all imports…
MarcosSpessatto Jan 25, 2019
801ed01
Move RestAPI client to rc-api package
MarcosSpessatto Jan 28, 2019
1238c2c
Remove dependency of RC namespace in rc-api/helpers and api.js
MarcosSpessatto Jan 28, 2019
dc8f615
Remove dependency of RC namespace on half of api files
MarcosSpessatto Jan 28, 2019
c6db2d5
Partial Remove dependency of RC namespace in rc-api
MarcosSpessatto Jan 28, 2019
06f62e6
import API where it was being used by the RC namespace
MarcosSpessatto Jan 28, 2019
cd1930c
Move processWebhookMessage function to rc-lib package
MarcosSpessatto Jan 28, 2019
d7eab39
Remove API from RC namespace and import missing function that was bei…
MarcosSpessatto Jan 28, 2019
59bbccc
Remove dependency of RC namespace in rc-graphql
MarcosSpessatto Jan 28, 2019
e90ab24
Fix import from wrong package
MarcosSpessatto Jan 28, 2019
fd4f74c
Remove dependency of RC namespace in rc-importer
MarcosSpessatto Jan 28, 2019
58ad493
Remove dependency of RC namespace in rc-issue-links
MarcosSpessatto Jan 28, 2019
5783786
Remove dependency of RC namespace in rc-katex
MarcosSpessatto Jan 28, 2019
e9be3a4
Move templateVarHandler fn to rc-utils
MarcosSpessatto Jan 28, 2019
406e037
Remove dependency of RC namespace in rc-ldap
MarcosSpessatto Jan 28, 2019
0206d28
Remove dependency of RC namespace in rc-livestream
MarcosSpessatto Feb 1, 2019
b6b980b
Remove dependency of RC namespace in rc-mail-messages
MarcosSpessatto Feb 1, 2019
7c7b063
Remove dependency of RC namespace in rc-mapview
MarcosSpessatto Feb 1, 2019
e08ad7e
Remove dependency of RC namespace in rc-mentions
MarcosSpessatto Feb 1, 2019
8bb2a96
Remove dependency of RC namespace in rc-mentions-flextab
MarcosSpessatto Feb 1, 2019
ea2b699
Remove depedency of RC namespace in rc-message-attachements
MarcosSpessatto Feb 1, 2019
4da85d9
Remove dependdency of RC namespace in rc-message-mark-as-unread
MarcosSpessatto Feb 1, 2019
1717135
Remove dependency of RC namespace in rc-message-pin
MarcosSpessatto Feb 1, 2019
6733112
Fix templateVarHandler that was in wrong folder
MarcosSpessatto Feb 1, 2019
bff0955
Merge branch 'develop' into depackaging
MarcosSpessatto Feb 4, 2019
b42676d
Merge branch 'depackaging' into globals/api-wave-1
MarcosSpessatto Feb 4, 2019
9db42c7
Merge branch 'globals/api-wave-1' into globals/api-wave-2
MarcosSpessatto Feb 4, 2019
d9635ae
Merge branch 'globals/api-wave-2' into globals/api-wave-3
MarcosSpessatto Feb 4, 2019
5560fb1
Merge branch 'globals/api-wave-3' into globals/api-wave-4
MarcosSpessatto Feb 4, 2019
765a43a
Merge branch 'globals/api-wave-4' into globals/graphql
MarcosSpessatto Feb 4, 2019
b567143
Merge branch 'globals/graphql' into globals/importer
MarcosSpessatto Feb 4, 2019
9fdf8a1
Merge branch 'globals/importer' into globals/issue-katex-ldap
MarcosSpessatto Feb 4, 2019
e9d857d
Merge branch 'globals/issue-katex-ldap' into globals/livestream-mail-…
MarcosSpessatto Feb 4, 2019
edf0e3d
Merge branch 'globals/livestream-mail-messages' into globals/mapview-…
MarcosSpessatto Feb 4, 2019
d39b6cd
Remove namespace in the new livechat endpoint
MarcosSpessatto Feb 4, 2019
e08efcd
Merge branch 'globals/api-wave-4' into globals/graphql
MarcosSpessatto Feb 4, 2019
20a71ff
Merge branch 'globals/graphql' into globals/importer
MarcosSpessatto Feb 4, 2019
77d0e2e
Merge branch 'globals/importer' into globals/issue-katex-ldap
MarcosSpessatto Feb 4, 2019
b588332
Merge branch 'globals/issue-katex-ldap' into globals/livestream-mail-…
MarcosSpessatto Feb 4, 2019
e9a51ab
Merge branch 'globals/livestream-mail-messages' into globals/mapview-…
MarcosSpessatto Feb 4, 2019
0d397c8
Merge branch 'globals/mapview-mentions' into globals/message
MarcosSpessatto Feb 4, 2019
1ae8bfd
Remove dependency of RC namespace in rc-message-snippet
MarcosSpessatto Feb 4, 2019
3bd702f
Remove dependency of RC namespace in rc-message-star
MarcosSpessatto Feb 4, 2019
0dbc8ed
Remove dependency of RC namespace in rc-oauth2
MarcosSpessatto Feb 4, 2019
767f35d
Remove dependency of RC namespace in rc-api/helpers and api.js (#13273)
MarcosSpessatto Feb 6, 2019
5228d2f
Remove dependency of RC namespace on half of api files (#13275)
MarcosSpessatto Feb 6, 2019
db160bf
Partial Remove dependency of RC namespace in rc-api (#13277)
MarcosSpessatto Feb 6, 2019
c977598
Remove dependency of RC namespace in rc-api (#13278)
MarcosSpessatto Feb 6, 2019
599f6f3
Remove dependency of RC namespace in rc-graphql (#13279)
MarcosSpessatto Feb 6, 2019
05bb4a6
Remove dependency of RC namespace in rc-importer (#13280)
MarcosSpessatto Feb 6, 2019
dc75e7d
Remove dependency of RC namespace in rc-ldap, katex and issue-links …
MarcosSpessatto Feb 6, 2019
412eb06
Remove dependency of RC namespace in rc-livestream and rc-mail-messa…
MarcosSpessatto Feb 6, 2019
3613dc5
Merge remote-tracking branch 'origin/depackaging' into globals/messag…
rodrigok Feb 13, 2019
da35a0b
Merge branch 'develop' into depackaging
MarcosSpessatto Feb 14, 2019
fbf2883
Merge remote-tracking branch 'origin/depackaging' into globals/messag…
rodrigok Feb 14, 2019
427692c
Merge remote-tracking branch 'origin/develop' into globals/message-pi…
rodrigok Feb 14, 2019
6150fd4
Merge remote-tracking branch 'origin/globals/message-pin-snippet' int…
rodrigok Feb 14, 2019
2ae5c47
Merge remote-tracking branch 'origin/develop' into globals/message-pi…
rodrigok Feb 14, 2019
32d2e62
Merge branch 'globals/message-pin-snippet' into globals/message-star-…
rodrigok Feb 14, 2019
4211b8e
Merge branch 'develop' into globals/message-star-oauth2-server
rodrigok Feb 14, 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
24 changes: 13 additions & 11 deletions packages/rocketchat-message-star/client/actionButton.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { Meteor } from 'meteor/meteor';
import { Template } from 'meteor/templating';
import { TAPi18n } from 'meteor/tap:i18n';
import { RocketChat, handleError } from 'meteor/rocketchat:lib';
import { RoomHistoryManager } from 'meteor/rocketchat:ui';
import { handleError } from 'meteor/rocketchat:utils';
import { Subscriptions } from 'meteor/rocketchat:models';
import { settings } from 'meteor/rocketchat:settings';
import { RoomHistoryManager, MessageAction } from 'meteor/rocketchat:ui-utils';
import toastr from 'toastr';

Meteor.startup(function() {
RocketChat.MessageAction.addButton({
MessageAction.addButton({
id: 'star-message',
icon: 'star',
label: 'Star_Message',
Expand All @@ -21,7 +23,7 @@ Meteor.startup(function() {
});
},
condition(message) {
if (RocketChat.models.Subscriptions.findOne({ rid: message.rid }) == null && RocketChat.settings.get('Message_AllowStarring')) {
if (Subscriptions.findOne({ rid: message.rid }) == null && settings.get('Message_AllowStarring')) {
return false;
}

Expand All @@ -31,7 +33,7 @@ Meteor.startup(function() {
group: 'menu',
});

RocketChat.MessageAction.addButton({
MessageAction.addButton({
id: 'unstar-message',
icon: 'star',
label: 'Unstar_Message',
Expand All @@ -46,7 +48,7 @@ Meteor.startup(function() {
});
},
condition(message) {
if (RocketChat.models.Subscriptions.findOne({ rid: message.rid }) == null && RocketChat.settings.get('Message_AllowStarring')) {
if (Subscriptions.findOne({ rid: message.rid }) == null && settings.get('Message_AllowStarring')) {
return false;
}

Expand All @@ -56,7 +58,7 @@ Meteor.startup(function() {
group: 'menu',
});

RocketChat.MessageAction.addButton({
MessageAction.addButton({
id: 'jump-to-star-message',
icon: 'jump',
label: 'Jump_to_message',
Expand All @@ -69,7 +71,7 @@ Meteor.startup(function() {
RoomHistoryManager.getSurroundingMessages(message, 50);
},
condition(message) {
if (RocketChat.models.Subscriptions.findOne({ rid: message.rid }) == null) {
if (Subscriptions.findOne({ rid: message.rid }) == null) {
return false;
}
return true;
Expand All @@ -78,19 +80,19 @@ Meteor.startup(function() {
group: 'menu',
});

RocketChat.MessageAction.addButton({
MessageAction.addButton({
id: 'permalink-star',
icon: 'permalink',
label: 'Permalink',
classes: 'clipboard',
context: ['starred'],
async action(event) {
const message = this._arguments[1];
$(event.currentTarget).attr('data-clipboard-text', await RocketChat.MessageAction.getPermaLink(message._id));
$(event.currentTarget).attr('data-clipboard-text', await MessageAction.getPermaLink(message._id));
toastr.success(TAPi18n.__('Copied'));
},
condition(message) {
if (RocketChat.models.Subscriptions.findOne({ rid: message.rid }) == null) {
if (Subscriptions.findOne({ rid: message.rid }) == null) {
return false;
}
return true;
Expand Down
8 changes: 4 additions & 4 deletions packages/rocketchat-message-star/client/starMessage.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { Meteor } from 'meteor/meteor';
import { RocketChat } from 'meteor/rocketchat:lib';
import { ChatMessage } from 'meteor/rocketchat:ui';
import { settings } from 'meteor/rocketchat:settings';
import { ChatMessage, Subscriptions } from 'meteor/rocketchat:models';

Meteor.methods({
starMessage(message) {
if (!Meteor.userId()) {
return false;
}
if (RocketChat.models.Subscriptions.findOne({ rid: message.rid }) == null) {
if (Subscriptions.findOne({ rid: message.rid }) == null) {
return false;
}
if (!RocketChat.settings.get('Message_AllowStarring')) {
if (!settings.get('Message_AllowStarring')) {
return false;
}
return ChatMessage.update({
Expand Down
4 changes: 2 additions & 2 deletions packages/rocketchat-message-star/client/tabBar.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 { TabBar } from 'meteor/rocketchat:ui-utils';

Meteor.startup(function() {
RocketChat.TabBar.addButton({
TabBar.addButton({
groups: ['channel', 'group', 'direct'],
id: 'starred-messages',
i18nTitle: 'Starred_Messages',
Expand Down
4 changes: 4 additions & 0 deletions packages/rocketchat-message-star/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ Package.onUse(function(api) {
'mongo',
'ecmascript',
'rocketchat:lib',
'rocketchat:utils',
'rocketchat:models',
'rocketchat:settings',
'rocketchat:ui-utils',
'templating',
]);
api.addFiles('client/views/stylesheets/messagestar.css', 'client');
Expand Down
1 change: 0 additions & 1 deletion packages/rocketchat-message-star/server/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import './models/Rooms';
import './settings';
import './starMessage';
import './publications/starredMessages';
Expand Down
23 changes: 0 additions & 23 deletions packages/rocketchat-message-star/server/models/Rooms.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { Meteor } from 'meteor/meteor';
import { RocketChat } from 'meteor/rocketchat:lib';
import { Users, Messages } from 'meteor/rocketchat:models';

Meteor.publish('starredMessages', function(rid, limit = 50) {
if (!this.userId) {
return this.ready();
}
const publication = this;
const user = RocketChat.models.Users.findOneById(this.userId);
const user = Users.findOneById(this.userId);
if (!user) {
return this.ready();
}
if (!Meteor.call('canAccessRoom', rid, this.userId)) {
return this.ready();
}
const cursorHandle = RocketChat.models.Messages.findStarredByUserAtRoom(this.userId, rid, {
const cursorHandle = Messages.findStarredByUserAtRoom(this.userId, rid, {
sort: {
ts: -1,
},
Expand Down
4 changes: 2 additions & 2 deletions packages/rocketchat-message-star/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() {
return RocketChat.settings.add('Message_AllowStarring', true, {
return settings.add('Message_AllowStarring', true, {
type: 'boolean',
group: 'Message',
public: true,
Expand Down
14 changes: 8 additions & 6 deletions packages/rocketchat-message-star/server/starMessage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Meteor } from 'meteor/meteor';
import { RocketChat } from 'meteor/rocketchat:lib';
import { settings } from 'meteor/rocketchat:settings';
import { isTheLastMessage } from 'meteor/rocketchat:lib';
import { Subscriptions, Rooms, Messages } from 'meteor/rocketchat:models';

Meteor.methods({
starMessage(message) {
Expand All @@ -9,22 +11,22 @@ Meteor.methods({
});
}

if (!RocketChat.settings.get('Message_AllowStarring')) {
if (!settings.get('Message_AllowStarring')) {
throw new Meteor.Error('error-action-not-allowed', 'Message starring not allowed', {
method: 'pinMessage',
action: 'Message_starring',
});
}

const subscription = RocketChat.models.Subscriptions.findOneByRoomIdAndUserId(message.rid, Meteor.userId(), { fields: { _id: 1 } });
const subscription = Subscriptions.findOneByRoomIdAndUserId(message.rid, Meteor.userId(), { fields: { _id: 1 } });
if (!subscription) {
return false;
}
const room = Meteor.call('canAccessRoom', message.rid, Meteor.userId());
if (RocketChat.isTheLastMessage(room, message)) {
RocketChat.models.Rooms.updateLastMessageStar(room._id, Meteor.userId(), message.starred);
if (isTheLastMessage(room, message)) {
Rooms.updateLastMessageStar(room._id, Meteor.userId(), message.starred);
}

return RocketChat.models.Messages.updateUserStarById(message._id, Meteor.userId(), message.starred);
return Messages.updateUserStarById(message._id, Meteor.userId(), message.starred);
},
});
4 changes: 2 additions & 2 deletions packages/rocketchat-message-star/server/startup/indexes.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Meteor } from 'meteor/meteor';
import { RocketChat } from 'meteor/rocketchat:lib';
import { Messages } from 'meteor/rocketchat:models';

Meteor.startup(function() {
return Meteor.defer(function() {
return RocketChat.models.Messages.tryEnsureIndex({
return Messages.tryEnsureIndex({
'starred._id': 1,
}, {
sparse: 1,
Expand Down
2 changes: 2 additions & 0 deletions packages/rocketchat-models/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import Integrations from './models/Integrations';
import IntegrationHistory from './models/IntegrationHistory';
import CredentialTokens from './models/CredentialTokens';
import EmojiCustom from './models/EmojiCustom';
import OAuthApps from './models/OAuthApps';

export {
Base,
Expand All @@ -42,4 +43,5 @@ export {
IntegrationHistory,
CredentialTokens,
EmojiCustom,
OAuthApps,
};
9 changes: 9 additions & 0 deletions packages/rocketchat-models/server/models/OAuthApps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Base } from './_Base';

export class OAuthApps extends Base {
constructor() {
super('oauth_apps');
}
}

export default new OAuthApps();
21 changes: 21 additions & 0 deletions packages/rocketchat-models/server/models/Rooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,27 @@ export class Rooms extends Base {
return this.findOne(query, options);
}

updateLastMessageStar(roomId, userId, starred) {
let update;
const query = { _id: roomId };

if (starred) {
update = {
$addToSet: {
'lastMessage.starred': { _id: userId },
},
};
} else {
update = {
$pull: {
'lastMessage.starred': { _id: userId },
},
};
}

return this.update(query, update);
}

setLastMessageSnippeted(roomId, message, snippetName, snippetedBy, snippeted, snippetedAt) {
const query = { _id: roomId };

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { RocketChat } from 'meteor/rocketchat:lib';
import { AdminBox } from 'meteor/rocketchat:ui-utils';
import { hasAllPermission } from 'meteor/rocketchat:authorization';

RocketChat.AdminBox.addOption({
AdminBox.addOption({
href: 'admin-oauth-apps',
i18nLabel: 'OAuth Apps',
icon: 'discover',
permissionGranted() {
return RocketChat.authz.hasAllPermission('manage-oauth-apps');
return hasAllPermission('manage-oauth-apps');
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { ReactiveVar } from 'meteor/reactive-var';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { Template } from 'meteor/templating';
import { TAPi18n } from 'meteor/tap:i18n';
import { RocketChat, handleError } from 'meteor/rocketchat:lib';
import { modal } from 'meteor/rocketchat:ui';
import { t } from 'meteor/rocketchat:utils';
import { hasAllPermission } from 'meteor/rocketchat:authorization';
import { modal } from 'meteor/rocketchat:ui-utils';
import { t, handleError } from 'meteor/rocketchat:utils';
import { ChatOAuthApps } from '../collection';
import toastr from 'toastr';

Expand All @@ -18,7 +18,7 @@ Template.oauthApp.onCreated(function() {

Template.oauthApp.helpers({
hasPermission() {
return RocketChat.authz.hasAllPermission('manage-oauth-apps');
return hasAllPermission('manage-oauth-apps');
},
data() {
const instance = Template.instance();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Template } from 'meteor/templating';
import { RocketChat } from 'meteor/rocketchat:lib';
import { hasAllPermission } from 'meteor/rocketchat:authorization';
import { ChatOAuthApps } from '../collection';
import moment from 'moment';

Expand All @@ -9,7 +9,7 @@ Template.oauthApps.onCreated(function() {

Template.oauthApps.helpers({
hasPermission() {
return RocketChat.authz.hasAllPermission('manage-oauth-apps');
return hasAllPermission('manage-oauth-apps');
},
applications() {
return ChatOAuthApps.find();
Expand Down
4 changes: 3 additions & 1 deletion packages/rocketchat-oauth2-server-config/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ Package.onUse(function(api) {
'webapp',
'mongo',
'rocketchat:utils',
'rocketchat:lib',
'rocketchat:models',
'rocketchat:ui-utils',
'rocketchat:authorization',
'rocketchat:api',
'rocketchat:theme',
'rocketchat:oauth2-server',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Meteor } from 'meteor/meteor';
import { Random } from 'meteor/random';
import { RocketChat } from 'meteor/rocketchat:lib';
import { hasPermission } from 'meteor/rocketchat:authorization';
import { Users, OAuthApps } from 'meteor/rocketchat:models';
import _ from 'underscore';

Meteor.methods({
addOAuthApp(application) {
if (!RocketChat.authz.hasPermission(this.userId, 'manage-oauth-apps')) {
if (!hasPermission(this.userId, 'manage-oauth-apps')) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'addOAuthApp' });
}
if (!_.isString(application.name) || application.name.trim() === '') {
Expand All @@ -20,8 +21,8 @@ Meteor.methods({
application.clientId = Random.id();
application.clientSecret = Random.secret();
application._createdAt = new Date;
application._createdBy = RocketChat.models.Users.findOne(this.userId, { fields: { username: 1 } });
application._id = RocketChat.models.OAuthApps.insert(application);
application._createdBy = Users.findOne(this.userId, { fields: { username: 1 } });
application._id = OAuthApps.insert(application);
return application;
},
});
Loading