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-livechat/server/publications #13383

Merged
merged 175 commits into from
Feb 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
175 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
584d087
Remove dependency of RC namespace in rc-oembed
MarcosSpessatto Feb 4, 2019
c06f9e1
Remove dependency of RC namespace in rc-otr
MarcosSpessatto Feb 4, 2019
b807e99
Remove dependency of RC namespace in rc-reactions
MarcosSpessatto Feb 4, 2019
87a39cf
Remove dependency of RC namespace in rc-retention-policy
MarcosSpessatto Feb 4, 2019
923b584
Remove dependency of RC namespace in rc-earch
MarcosSpessatto Feb 4, 2019
b2db169
Remove dependency of RC namespace in rc-setup-wizard
MarcosSpessatto Feb 4, 2019
b7174f8
Remove dependency of RC namespace in rc-slackbridge
MarcosSpessatto Feb 4, 2019
9cbf738
Remove dependency of Rc namespace in slashcommands-asciiarts
MarcosSpessatto Feb 4, 2019
3dd76ba
Remove depedency of RC namespace in rc-slash-archiveroom
MarcosSpessatto Feb 4, 2019
ca9c074
Remove dependency of RC namespace in rc-slash-create
MarcosSpessatto Feb 4, 2019
c4354d0
Remove dependency of RC namespace in rc-slash-help
MarcosSpessatto Feb 4, 2019
c0ede55
Remove dependency of RC namespace in rc-slash-hide
MarcosSpessatto Feb 4, 2019
b6fd2d5
Remove dependency of RC namespace in rc-slash-invite
MarcosSpessatto Feb 4, 2019
c532fad
Remove dependency of RC namespace in rc-slash-inviteall
MarcosSpessatto Feb 4, 2019
40fb545
Remove dependency of RC namespace in rc-slash-join
MarcosSpessatto Feb 5, 2019
e24096b
Remove dependency of RC namespace in rc-slash-kick
MarcosSpessatto Feb 5, 2019
1aa0f73
Remove dependency of RC namespace in rc-slash-leave
MarcosSpessatto Feb 5, 2019
74fc80c
Remove dependency of RC namespace in rc-slash-me
MarcosSpessatto Feb 5, 2019
5180629
Remove dependency of RC namespace in rc-slash-msg
MarcosSpessatto Feb 5, 2019
b3c4be2
Remove dependency of RC namespace in rc-slash-mute
MarcosSpessatto Feb 5, 2019
baa9aec
Remove dependency of RC namespace in rc-slash-open
MarcosSpessatto Feb 5, 2019
d75940e
Remove dependency of RC namespace in rc-slash-topic
MarcosSpessatto Feb 5, 2019
8687f9e
Remove dependency of RC namespace in rc-slash-unarchiveroom
MarcosSpessatto Feb 5, 2019
90adc29
Remove dependency of RC namespace in rc-smarsh-connector
MarcosSpessatto Feb 5, 2019
76a7209
Remove dependency of RC namespace in rc-sms
MarcosSpessatto Feb 5, 2019
73c2704
Remove dependency of RC namespace in rc-spotify
MarcosSpessatto Feb 5, 2019
56d9d99
Remove dependency of RC namespace in rc-statistics
MarcosSpessatto Feb 5, 2019
ad49a78
Move tokenpass models methods to rc-models
MarcosSpessatto Feb 5, 2019
8169e2c
Remove dependency of RC namespace in rc-tokenpass
MarcosSpessatto Feb 5, 2019
dfeab9f
import tokenpass inside rc-lib
MarcosSpessatto Feb 5, 2019
7e7752c
Remove dependency of RC namespace in rc-ui
MarcosSpessatto Feb 5, 2019
c9e2c01
Move webdavAccounts models to rc-model
MarcosSpessatto Feb 5, 2019
62e6542
Remove dependency of RC namespace in rc-ui-account
MarcosSpessatto Feb 5, 2019
2432e9a
Remove dependency of RC namespace in rc-ui-admin
MarcosSpessatto Feb 5, 2019
3c063a5
Remove dependency of RC namespace in rc-ui-clean-history
MarcosSpessatto Feb 5, 2019
18724d6
Remove dependency of RC namespace in rc-ui-flextab
MarcosSpessatto Feb 5, 2019
e877444
Remove dependency of RC namespace in rc-ui-login
MarcosSpessatto Feb 5, 2019
995f51a
Remove dependency of RC namespace in rc-ui-master
MarcosSpessatto Feb 5, 2019
060d85a
Remove dependency of RC namespace in rc-ui-message
MarcosSpessatto Feb 5, 2019
00b33ca
REmove dependency of RC namespace in rc-user-data-download
MarcosSpessatto Feb 5, 2019
ba43cc0
Remove dependency of RC namespace in rc-version-check
MarcosSpessatto Feb 5, 2019
ebe6d01
Remove dependency of RC namespace in rc-videobridge
MarcosSpessatto Feb 5, 2019
896070b
Remove dependency of RC namespace in rc-webdav
MarcosSpessatto Feb 5, 2019
112638c
Remove dependency of RC namespace in rc-wordpress
MarcosSpessatto Feb 5, 2019
79d7200
Remove some RC namespace use in chatpal-search
MarcosSpessatto Feb 5, 2019
869c40d
Remove dependency of RC namespace in rc-irc
MarcosSpessatto Feb 5, 2019
ce4f107
Remove dependency of RC namespace in livechat/client
MarcosSpessatto Feb 5, 2019
2e7cb78
Move methods in common livechat models to rc-models
MarcosSpessatto Feb 6, 2019
6a4f363
Remove dependency of RC namespace in rc-livechat/server/models
MarcosSpessatto Feb 6, 2019
2df8424
Remove LIvechat global variable from RC namespace
MarcosSpessatto Feb 6, 2019
42c8419
Remove dependency of RC namespace in rc-livechat/imports, lib, server…
MarcosSpessatto Feb 6, 2019
099527b
Remove dependency of RC namespace in rc-livechat/server/methods
MarcosSpessatto Feb 6, 2019
1f29533
Fix duplicated import
MarcosSpessatto Feb 6, 2019
0a5281d
Remove unused import
MarcosSpessatto Feb 6, 2019
2effa03
Remove dependency of RC namespace in rc-livechat/server/publications
MarcosSpessatto Feb 6, 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
f0d8a0c
Import missed functions in rc-irc
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
61a7534
Merge branch 'globals/message-star-oauth2-server' into globals/oembed…
rodrigok Feb 14, 2019
4211b8e
Merge branch 'develop' into globals/message-star-oauth2-server
rodrigok Feb 14, 2019
ec940cb
Merge branch 'globals/message-star-oauth2-server' into globals/oembed…
rodrigok Feb 14, 2019
45f6a1e
Merge branch 'globals/oembed-otr' into globals/reactions-rp-search
rodrigok Feb 14, 2019
0495b53
Merge branch 'globals/reactions-rp-search' into globals/setup-slackbr…
rodrigok Feb 14, 2019
b5278f7
Merge branch 'globals/setup-slackbridge-asciiarts' into globals/slash
rodrigok Feb 14, 2019
fc6bcf8
Merge branch 'globals/slash' into globals/slash-wave-2
rodrigok Feb 14, 2019
2bd8afd
Merge remote-tracking branch 'origin/develop' into globals/reactions-…
rodrigok Feb 14, 2019
47a145d
Merge branch 'globals/reactions-rp-search' into globals/setup-slackbr…
rodrigok Feb 14, 2019
9f29f12
Merge branch 'globals/setup-slackbridge-asciiarts' into globals/slash
rodrigok Feb 14, 2019
4a23834
Merge branch 'globals/slash' into globals/slash-wave-2
rodrigok Feb 14, 2019
03e17cb
Merge branch 'develop' into globals/slash
rodrigok Feb 14, 2019
07b435b
Merge remote-tracking branch 'origin/globals/slash' into globals/slas…
rodrigok Feb 14, 2019
9f3d69c
Merge remote-tracking branch 'origin/develop' into globals/slash-wave-2
rodrigok Feb 14, 2019
867f05a
Merge branch 'globals/slash-wave-2' into globals/smarsh-sms-spotify
rodrigok Feb 14, 2019
2cea2ef
Merge branch 'globals/smarsh-sms-spotify' into globals/statistics-tok…
rodrigok Feb 14, 2019
4fe5462
Merge branch 'globals/statistics-tokenpass' into globals/ui-account-a…
rodrigok Feb 14, 2019
a348050
Merge branch 'develop' into globals/ui-account-admin
rodrigok Feb 14, 2019
7005d3c
Merge branch 'globals/ui-account-admin' into globals/ui-clean-history…
rodrigok Feb 14, 2019
dd9939b
Merge branch 'globals/ui-clean-history-flextab-login' into globals/ui…
rodrigok Feb 14, 2019
135f635
Merge branch 'globals/ui-master-message' into globals/videobridge
rodrigok Feb 14, 2019
8768bb0
Merge branch 'globals/videobridge' into globals/wordpress
rodrigok Feb 14, 2019
3d63bd8
Merge remote-tracking branch 'origin/develop' into globals/videobridge
rodrigok Feb 15, 2019
adc906c
Merge branch 'globals/videobridge' into globals/wordpress
rodrigok Feb 15, 2019
5af135e
Merge branch 'globals/wordpress' into globals/livechat-wave-1
rodrigok Feb 15, 2019
0c9eca5
Merge branch 'globals/livechat-wave-1' into globals/livechat-server-m…
rodrigok Feb 15, 2019
aa6f839
Merge branch 'globals/livechat-server-models' into globals/livechat-g…
rodrigok Feb 15, 2019
597e8e2
Merge remote-tracking branch 'origin/develop' into globals/livechat-s…
rodrigok Feb 15, 2019
db2928f
Merge branch 'globals/livechat-server-models' into globals/livechat-g…
rodrigok Feb 15, 2019
88d843c
Merge remote-tracking branch 'origin/develop' into globals/livechat-g…
rodrigok Feb 15, 2019
5e28cc9
Merge branch 'globals/livechat-global' into globals/livechat-server-r…
rodrigok Feb 15, 2019
1a4de21
Merge branch 'globals/livechat-server-rc-wave-1' into globals/livecha…
rodrigok Feb 15, 2019
8700c10
Merge branch 'globals/livechat-server-rc-wave-2' into globals/livecha…
rodrigok Feb 15, 2019
7c4d675
Merge remote-tracking branch 'origin/develop' into globals/livechat-s…
rodrigok Feb 15, 2019
5c258f4
Merge branch 'globals/livechat-server-rc-wave-1' into globals/livecha…
rodrigok Feb 15, 2019
e2925bf
Merge branch 'globals/livechat-server-rc-wave-2' into globals/livecha…
rodrigok Feb 15, 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
12 changes: 6 additions & 6 deletions packages/rocketchat-livechat/imports/server/rest/departments.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { check } from 'meteor/check';
import { RocketChat } from 'meteor/rocketchat:lib';
import { API } from 'meteor/rocketchat:api';
import { hasPermission } from 'meteor/rocketchat:authorization';
import { LivechatDepartment, LivechatDepartmentAgents } from '../../../server/models';
import { Livechat } from '../../../server/lib/Livechat';

API.v1.addRoute('livechat/department', { authRequired: true }, {
get() {
if (!RocketChat.authz.hasPermission(this.userId, 'view-livechat-manager')) {
if (!hasPermission(this.userId, 'view-livechat-manager')) {
return API.v1.unauthorized();
}

Expand All @@ -15,7 +15,7 @@ API.v1.addRoute('livechat/department', { authRequired: true }, {
});
},
post() {
if (!RocketChat.authz.hasPermission(this.userId, 'view-livechat-manager')) {
if (!hasPermission(this.userId, 'view-livechat-manager')) {
return API.v1.unauthorized();
}

Expand Down Expand Up @@ -43,7 +43,7 @@ API.v1.addRoute('livechat/department', { authRequired: true }, {

API.v1.addRoute('livechat/department/:_id', { authRequired: true }, {
get() {
if (!RocketChat.authz.hasPermission(this.userId, 'view-livechat-manager')) {
if (!hasPermission(this.userId, 'view-livechat-manager')) {
return API.v1.unauthorized();
}

Expand All @@ -61,7 +61,7 @@ API.v1.addRoute('livechat/department/:_id', { authRequired: true }, {
}
},
put() {
if (!RocketChat.authz.hasPermission(this.userId, 'view-livechat-manager')) {
if (!hasPermission(this.userId, 'view-livechat-manager')) {
return API.v1.unauthorized();
}

Expand All @@ -88,7 +88,7 @@ API.v1.addRoute('livechat/department/:_id', { authRequired: true }, {
}
},
delete() {
if (!RocketChat.authz.hasPermission(this.userId, 'view-livechat-manager')) {
if (!hasPermission(this.userId, 'view-livechat-manager')) {
return API.v1.unauthorized();
}

Expand Down
12 changes: 6 additions & 6 deletions packages/rocketchat-livechat/imports/server/rest/facebook.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import crypto from 'crypto';
import { Random } from 'meteor/random';
import { RocketChat } from 'meteor/rocketchat:lib';
import { API } from 'meteor/rocketchat:api';

import { Rooms, Users } from 'meteor/rocketchat:models';
import { settings } from 'meteor/rocketchat:settings';
import LivechatVisitors from '../../../server/models/LivechatVisitors';
import { Livechat } from '../../../server/lib/Livechat';

Expand Down Expand Up @@ -33,15 +33,15 @@ API.v1.addRoute('livechat/facebook', {
};
}

if (!RocketChat.settings.get('Livechat_Facebook_Enabled')) {
if (!settings.get('Livechat_Facebook_Enabled')) {
return {
success: false,
error: 'Integration disabled',
};
}

// validate if request come from omni
const signature = crypto.createHmac('sha1', RocketChat.settings.get('Livechat_Facebook_API_Secret')).update(JSON.stringify(this.request.body)).digest('hex');
const signature = crypto.createHmac('sha1', settings.get('Livechat_Facebook_API_Secret')).update(JSON.stringify(this.request.body)).digest('hex');
if (this.request.headers['x-hub-signature'] !== `sha1=${ signature }`) {
return {
success: false,
Expand All @@ -61,7 +61,7 @@ API.v1.addRoute('livechat/facebook', {
};
let visitor = LivechatVisitors.getVisitorByToken(this.bodyParams.token);
if (visitor) {
const rooms = RocketChat.models.Rooms.findOpenByVisitorToken(visitor.token).fetch();
const rooms = Rooms.findOpenByVisitorToken(visitor.token).fetch();
if (rooms && rooms.length > 0) {
sendMessage.message.rid = rooms[0]._id;
} else {
Expand All @@ -77,7 +77,7 @@ API.v1.addRoute('livechat/facebook', {
name: `${ this.bodyParams.first_name } ${ this.bodyParams.last_name }`,
});

visitor = RocketChat.models.Users.findOneById(userId);
visitor = Users.findOneById(userId);
}

sendMessage.message.msg = this.bodyParams.text;
Expand Down
4 changes: 2 additions & 2 deletions packages/rocketchat-livechat/imports/server/rest/sms.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { Random } from 'meteor/random';
import { RocketChat } from 'meteor/rocketchat:lib';
import { Rooms } from 'meteor/rocketchat:models';
import { API } from 'meteor/rocketchat:api';
import { SMS } from 'meteor/rocketchat:sms';
import LivechatVisitors from '../../../server/models/LivechatVisitors';
Expand All @@ -26,7 +26,7 @@ API.v1.addRoute('livechat/sms-incoming/:service', {
};

if (visitor) {
const rooms = RocketChat.models.Rooms.findOpenByVisitorToken(visitor.token).fetch();
const rooms = Rooms.findOpenByVisitorToken(visitor.token).fetch();

if (rooms && rooms.length > 0) {
sendMessage.message.rid = rooms[0]._id;
Expand Down
12 changes: 7 additions & 5 deletions packages/rocketchat-livechat/imports/server/rest/upload.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import { Meteor } from 'meteor/meteor';
import { RocketChat } from 'meteor/rocketchat:lib';
import { settings } from 'meteor/rocketchat:settings';
import { Settings, Rooms } from 'meteor/rocketchat:models';
import { fileUploadIsValidContentType } from 'meteor/rocketchat:utils';
import { FileUpload } from 'meteor/rocketchat:file-upload';
import { API } from 'meteor/rocketchat:api';
import Busboy from 'busboy';
import filesize from 'filesize';
import LivechatVisitors from '../../../server/models/LivechatVisitors';
let maxFileSize;

RocketChat.settings.get('FileUpload_MaxFileSize', function(key, value) {
settings.get('FileUpload_MaxFileSize', function(key, value) {
try {
maxFileSize = parseInt(value);
} catch (e) {
maxFileSize = RocketChat.models.Settings.findOneById('FileUpload_MaxFileSize').packageValue;
maxFileSize = Settings.findOneById('FileUpload_MaxFileSize').packageValue;
}
});

Expand All @@ -28,7 +30,7 @@ API.v1.addRoute('livechat/upload/:rid', {
return API.v1.unauthorized();
}

const room = RocketChat.models.Rooms.findOneOpenByRoomIdAndVisitorToken(this.urlParams.rid, visitorToken);
const room = Rooms.findOneOpenByRoomIdAndVisitorToken(this.urlParams.rid, visitorToken);
if (!room) {
return API.v1.unauthorized();
}
Expand Down Expand Up @@ -68,7 +70,7 @@ API.v1.addRoute('livechat/upload/:rid', {

const file = files[0];

if (!RocketChat.fileUploadIsValidContentType(file.mimetype)) {
if (!fileUploadIsValidContentType(file.mimetype)) {
return API.v1.failure({
reason: 'error-type-not-allowed',
});
Expand Down
17 changes: 9 additions & 8 deletions packages/rocketchat-livechat/imports/server/rest/users.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { check } from 'meteor/check';
import { RocketChat } from 'meteor/rocketchat:lib';
import { hasPermission, getUsersInRole } from 'meteor/rocketchat:authorization';
import { API } from 'meteor/rocketchat:api';
import { Users } from 'meteor/rocketchat:models';
import { Livechat } from '../../../server/lib/Livechat';
import _ from 'underscore';

API.v1.addRoute('livechat/users/:type', { authRequired: true }, {
get() {
if (!RocketChat.authz.hasPermission(this.userId, 'view-livechat-manager')) {
if (!hasPermission(this.userId, 'view-livechat-manager')) {
return API.v1.unauthorized();
}

Expand All @@ -24,7 +25,7 @@ API.v1.addRoute('livechat/users/:type', { authRequired: true }, {
throw 'Invalid type';
}

const users = RocketChat.authz.getUsersInRole(role);
const users = getUsersInRole(role);

return API.v1.success({
users: users.fetch().map((user) => _.pick(user, '_id', 'username', 'name', 'status', 'statusLivechat')),
Expand All @@ -34,7 +35,7 @@ API.v1.addRoute('livechat/users/:type', { authRequired: true }, {
}
},
post() {
if (!RocketChat.authz.hasPermission(this.userId, 'view-livechat-manager')) {
if (!hasPermission(this.userId, 'view-livechat-manager')) {
return API.v1.unauthorized();
}
try {
Expand Down Expand Up @@ -69,7 +70,7 @@ API.v1.addRoute('livechat/users/:type', { authRequired: true }, {

API.v1.addRoute('livechat/users/:type/:_id', { authRequired: true }, {
get() {
if (!RocketChat.authz.hasPermission(this.userId, 'view-livechat-manager')) {
if (!hasPermission(this.userId, 'view-livechat-manager')) {
return API.v1.unauthorized();
}

Expand All @@ -79,7 +80,7 @@ API.v1.addRoute('livechat/users/:type/:_id', { authRequired: true }, {
_id: String,
});

const user = RocketChat.models.Users.findOneById(this.urlParams._id);
const user = Users.findOneById(this.urlParams._id);

if (!user) {
return API.v1.failure('User not found');
Expand Down Expand Up @@ -109,7 +110,7 @@ API.v1.addRoute('livechat/users/:type/:_id', { authRequired: true }, {
}
},
delete() {
if (!RocketChat.authz.hasPermission(this.userId, 'view-livechat-manager')) {
if (!hasPermission(this.userId, 'view-livechat-manager')) {
return API.v1.unauthorized();
}

Expand All @@ -119,7 +120,7 @@ API.v1.addRoute('livechat/users/:type/:_id', { authRequired: true }, {
_id: String,
});

const user = RocketChat.models.Users.findOneById(this.urlParams._id);
const user = Users.findOneById(this.urlParams._id);

if (!user) {
return API.v1.failure();
Expand Down
9 changes: 6 additions & 3 deletions packages/rocketchat-livechat/lib/LivechatRoomType.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { Session } from 'meteor/session';
import { ChatRoom } from 'meteor/rocketchat:ui';
import { RocketChat, RoomSettingsEnum, RoomTypeConfig, RoomTypeRouteConfig, UiTextContext, openRoom } from 'meteor/rocketchat:lib';
import { ChatRoom } from 'meteor/rocketchat:models';
import { settings } from 'meteor/rocketchat:settings';
import { hasPermission } from 'meteor/rocketchat:authorization';
import { openRoom } from 'meteor/rocketchat:ui-utils';
import { RoomSettingsEnum, UiTextContext, RoomTypeRouteConfig, RoomTypeConfig } from 'meteor/rocketchat:utils';
import { LivechatInquiry } from './LivechatInquiry';

class LivechatRoomRoute extends RoomTypeRouteConfig {
Expand Down Expand Up @@ -46,7 +49,7 @@ export default class LivechatRoomType extends RoomTypeConfig {
}

condition() {
return RocketChat.settings.get('Livechat_enabled') && RocketChat.authz.hasPermission('view-l-room');
return settings.get('Livechat_enabled') && hasPermission('view-l-room');
}

canSendMessage(roomId) {
Expand Down
24 changes: 14 additions & 10 deletions packages/rocketchat-livechat/lib/messageTypes.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { Meteor } from 'meteor/meteor';
import { TAPi18n } from 'meteor/tap:i18n';
import { RocketChat } from 'meteor/rocketchat:lib';
import { MessageTypes } from 'meteor/rocketchat:ui-utils';
import { actionLinks } from 'meteor/rocketchat:action-links';
import { Notifications } from 'meteor/rocketchat:notifications';
import { Messages, Rooms } from 'meteor/rocketchat:models';
import { settings } from 'meteor/rocketchat:settings';
import { Livechat } from 'meteor/rocketchat:livechat';

RocketChat.MessageTypes.registerType({
MessageTypes.registerType({
id: 'livechat_navigation_history',
system: true,
message: 'New_visitor_navigation',
Expand All @@ -17,34 +21,34 @@ RocketChat.MessageTypes.registerType({
},
});

RocketChat.MessageTypes.registerType({
MessageTypes.registerType({
id: 'livechat_video_call',
system: true,
message: 'New_videocall_request',
});

RocketChat.actionLinks.register('createLivechatCall', function(message, params, instance) {
actionLinks.register('createLivechatCall', function(message, params, instance) {
if (Meteor.isClient) {
instance.tabBar.open('video');
}
});

RocketChat.actionLinks.register('denyLivechatCall', function(message/* , params*/) {
actionLinks.register('denyLivechatCall', function(message/* , params*/) {
if (Meteor.isServer) {
const user = Meteor.user();

RocketChat.models.Messages.createWithTypeRoomIdMessageAndUser('command', message.rid, 'endCall', user);
RocketChat.Notifications.notifyRoom(message.rid, 'deleteMessage', { _id: message._id });
Messages.createWithTypeRoomIdMessageAndUser('command', message.rid, 'endCall', user);
Notifications.notifyRoom(message.rid, 'deleteMessage', { _id: message._id });

const language = user.language || RocketChat.settings.get('Language') || 'en';
const language = user.language || settings.get('Language') || 'en';

Livechat.closeRoom({
user,
room: RocketChat.models.Rooms.findOneById(message.rid),
room: Rooms.findOneById(message.rid),
comment: TAPi18n.__('Videocall_declined', { lng: language }),
});
Meteor.defer(() => {
RocketChat.models.Messages.setHiddenById(message._id);
Messages.setHiddenById(message._id);
});
}
});
2 changes: 2 additions & 0 deletions packages/rocketchat-livechat/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ Package.onUse(function(api) {
'webapp',
'autoupdate',
'rocketchat:utils',
'rocketchat:action-links',
'rocketchat:ui-utils',
'rocketchat:settings',
'rocketchat:callbacks',
'rocketchat:models',
'rocketchat:lib',
'rocketchat:authorization',
Expand Down
4 changes: 2 additions & 2 deletions packages/rocketchat-livechat/server/agentStatus.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { RocketChat } from 'meteor/rocketchat:lib';
import { hasRole } from 'meteor/rocketchat:authorization';
import { UserPresenceMonitor } from 'meteor/konecty:user-presence';
import { Livechat } from './lib/Livechat';

UserPresenceMonitor.onSetUserStatus((user, status) => {
if (RocketChat.authz.hasRole(user._id, 'livechat-manager') || RocketChat.authz.hasRole(user._id, 'livechat-agent')) {
if (hasRole(user._id, 'livechat-manager') || hasRole(user._id, 'livechat-agent')) {
Livechat.notifyAgentStatusChanged(user._id, status);
}
});
12 changes: 6 additions & 6 deletions packages/rocketchat-livechat/server/api/lib/livechat.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Meteor } from 'meteor/meteor';
import { Random } from 'meteor/random';
import { RocketChat } from 'meteor/rocketchat:lib';
import { Users, Rooms } from 'meteor/rocketchat:models';
import { LivechatDepartment, LivechatTrigger } from '../../models';
import _ from 'underscore';
import LivechatVisitors from '../../models/LivechatVisitors';
import { Livechat } from '../../lib/Livechat';

export function online() {
return RocketChat.models.Users.findOnlineAgents().count() > 0;
return Users.findOnlineAgents().count() > 0;
}

export function findTriggers() {
Expand Down Expand Up @@ -38,10 +38,10 @@ export function findRoom(token, rid) {
};

if (!rid) {
return RocketChat.models.Rooms.findLivechatByVisitorToken(token, fields);
return Rooms.findLivechatByVisitorToken(token, fields);
}

return RocketChat.models.Rooms.findLivechatByIdAndVisitorToken(rid, token, fields);
return Rooms.findLivechatByIdAndVisitorToken(rid, token, fields);
}

export function findOpenRoom(token, departmentId) {
Expand All @@ -54,7 +54,7 @@ export function findOpenRoom(token, departmentId) {
};

let room;
const rooms = departmentId ? RocketChat.models.Rooms.findOpenByVisitorTokenAndDepartmentId(token, departmentId, options).fetch() : RocketChat.models.Rooms.findOpenByVisitorToken(token, options).fetch();
const rooms = departmentId ? Rooms.findOpenByVisitorTokenAndDepartmentId(token, departmentId, options).fetch() : Rooms.findOpenByVisitorToken(token, options).fetch();
if (rooms && rooms.length > 0) {
room = rooms[0];
}
Expand All @@ -77,7 +77,7 @@ export function getRoom(guest, rid, roomInfo) {
}

export function findAgent(agentId) {
return RocketChat.models.Users.getAgentInfo(agentId);
return Users.getAgentInfo(agentId);
}

export function settings() {
Expand Down
4 changes: 2 additions & 2 deletions packages/rocketchat-livechat/server/api/v1/config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RocketChat } from 'meteor/rocketchat:lib';
import { Users } from 'meteor/rocketchat:models';
import { API } from 'meteor/rocketchat:api';
import { findGuest, settings, online, findOpenRoom } from '../lib/livechat';
import { Match, check } from 'meteor/check';
Expand Down Expand Up @@ -26,7 +26,7 @@ API.v1.addRoute('livechat/config', {
if (token) {
guest = findGuest(token);
room = findOpenRoom(token);
agent = room && room.servedBy && RocketChat.models.Users.getAgentInfo(room.servedBy._id);
agent = room && room.servedBy && Users.getAgentInfo(room.servedBy._id);
}

Object.assign(config, { online: status, guest, room, agent });
Expand Down
Loading