[BREAK] Remove deprecated publications (#16351)
parent
5c0490f2ed
commit
5bbd7d772a
@ -1,21 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
import { Roles } from '../../../models'; |
||||
import { clearCache } from '../functions/hasPermission'; |
||||
|
||||
Meteor.publish('roles', function() { |
||||
console.warn('The publication "roles" is deprecated and will be removed after version v3.0.0'); |
||||
if (!this.userId) { |
||||
return this.ready(); |
||||
} |
||||
|
||||
return Roles.find(); |
||||
}); |
||||
|
||||
Roles.on('change', ({ diff }) => { |
||||
if (diff && Object.keys(diff).length === 1 && diff._updatedAt) { |
||||
// avoid useless changes
|
||||
return; |
||||
} |
||||
clearCache(); |
||||
}); |
||||
@ -1,31 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
import s from 'underscore.string'; |
||||
|
||||
import { CustomSounds } from '../../../models'; |
||||
|
||||
Meteor.publish('customSounds', function(filter, limit) { |
||||
console.warn('The publication "customSounds" is deprecated and will be removed after version v3.0.0'); |
||||
if (!this.userId) { |
||||
return this.ready(); |
||||
} |
||||
|
||||
const fields = { |
||||
name: 1, |
||||
extension: 1, |
||||
}; |
||||
|
||||
filter = s.trim(filter); |
||||
|
||||
const options = { |
||||
fields, |
||||
limit, |
||||
sort: { name: 1 }, |
||||
}; |
||||
|
||||
if (filter) { |
||||
const filterReg = new RegExp(s.escapeRegExp(filter), 'i'); |
||||
return CustomSounds.findByName(filterReg, options); |
||||
} |
||||
|
||||
return CustomSounds.find({}, options); |
||||
}); |
||||
@ -1,45 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
import { Rooms } from '../../../models/server'; |
||||
import { hasPermission } from '../../../authorization/server'; |
||||
|
||||
Meteor.publish('discussionParentAutocomplete', function(selector) { |
||||
console.warn('The publication "discussionParentAutocomplete" is deprecated and will be removed after version v3.0.0'); |
||||
if (!this.userId) { |
||||
return this.ready(); |
||||
} |
||||
|
||||
if (hasPermission(this.userId, 'view-c-room') !== true) { |
||||
return this.ready(); |
||||
} |
||||
|
||||
const pub = this; |
||||
const options = { |
||||
fields: { |
||||
_id: 1, |
||||
name: 1, |
||||
}, |
||||
limit: 10, |
||||
sort: { |
||||
name: 1, |
||||
}, |
||||
}; |
||||
|
||||
const cursorHandle = Rooms.findDiscussionParentByNameStarting(selector.name, options).observeChanges({ |
||||
added(_id, record) { |
||||
return pub.added('autocompleteRecords', _id, record); |
||||
}, |
||||
changed(_id, record) { |
||||
return pub.changed('autocompleteRecords', _id, record); |
||||
}, |
||||
removed(_id, record) { |
||||
return pub.removed('autocompleteRecords', _id, record); |
||||
}, |
||||
}); |
||||
|
||||
this.ready(); |
||||
|
||||
this.onStop(function() { |
||||
return cursorHandle.stop(); |
||||
}); |
||||
}); |
||||
@ -1,33 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
import { Messages } from '../../../models/server'; |
||||
|
||||
Meteor.publish('discussionsOfRoom', function(rid, limit = 50) { |
||||
console.warn('The publication "discussionsOfRoom" is deprecated and will be removed after version v3.0.0'); |
||||
if (!this.userId) { |
||||
return this.ready(); |
||||
} |
||||
|
||||
const publication = this; |
||||
|
||||
if (!Meteor.call('canAccessRoom', rid, this.userId)) { |
||||
return this.ready(); |
||||
} |
||||
|
||||
const cursorHandle = Messages.find({ rid, drid: { $exists: true } }, { sort: { ts: -1 }, limit }).observeChanges({ |
||||
added(_id, record) { |
||||
return publication.added('rocketchat_discussions_of_room', _id, record); |
||||
}, |
||||
changed(_id, record) { |
||||
return publication.changed('rocketchat_discussions_of_room', _id, record); |
||||
}, |
||||
removed(_id) { |
||||
return publication.removed('rocketchat_discussions_of_room', _id); |
||||
}, |
||||
}); |
||||
|
||||
this.ready(); |
||||
return this.onStop(function() { |
||||
return cursorHandle.stop(); |
||||
}); |
||||
}); |
||||
@ -1,32 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
import s from 'underscore.string'; |
||||
|
||||
import { EmojiCustom } from '../../../models'; |
||||
|
||||
Meteor.publish('fullEmojiData', function(filter, limit) { |
||||
console.warn('The publication "fullEmojiData" is deprecated and will be removed after version v3.0.0'); |
||||
if (!this.userId) { |
||||
return this.ready(); |
||||
} |
||||
|
||||
const fields = { |
||||
name: 1, |
||||
aliases: 1, |
||||
extension: 1, |
||||
}; |
||||
|
||||
filter = s.trim(filter); |
||||
|
||||
const options = { |
||||
fields, |
||||
limit, |
||||
sort: { name: 1 }, |
||||
}; |
||||
|
||||
if (filter) { |
||||
const filterReg = new RegExp(s.escapeRegExp(filter), 'i'); |
||||
return EmojiCustom.findByNameOrAlias(filterReg, options); |
||||
} |
||||
|
||||
return EmojiCustom.find({}, options); |
||||
}); |
||||
@ -1,20 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
import { hasAtLeastOnePermission } from '../../../authorization/server'; |
||||
import { IntegrationHistory } from '../../../models/server'; |
||||
import { mountIntegrationHistoryQueryBasedOnPermissions } from '../lib/mountQueriesBasedOnPermission'; |
||||
|
||||
Meteor.publish('integrationHistory', function _integrationHistoryPublication(integrationId, limit = 25) { |
||||
console.warn('The publication "integrationHistory" is deprecated and will be removed after version v3.0.0'); |
||||
if (!this.userId) { |
||||
return this.ready(); |
||||
} |
||||
if (!hasAtLeastOnePermission(this.userId, [ |
||||
'manage-outgoing-integrations', |
||||
'manage-own-outgoing-integrations', |
||||
])) { |
||||
throw new Meteor.Error('not-authorized'); |
||||
} |
||||
|
||||
return IntegrationHistory.find(Object.assign(mountIntegrationHistoryQueryBasedOnPermissions(this.userId, integrationId)), { sort: { _updatedAt: -1 }, limit }); |
||||
}); |
||||
@ -1,23 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
import { hasAtLeastOnePermission } from '../../../authorization/server'; |
||||
import { Integrations } from '../../../models/server'; |
||||
import { mountIntegrationQueryBasedOnPermissions } from '../lib/mountQueriesBasedOnPermission'; |
||||
|
||||
Meteor.publish('integrations', function _integrationPublication() { |
||||
console.warn('The publication "integrations" is deprecated and will be removed after version v3.0.0'); |
||||
if (!this.userId) { |
||||
return this.ready(); |
||||
} |
||||
|
||||
if (!hasAtLeastOnePermission(this.userId, [ |
||||
'manage-outgoing-integrations', |
||||
'manage-own-outgoing-integrations', |
||||
'manage-incoming-integrations', |
||||
'manage-own-incoming-integrations', |
||||
])) { |
||||
throw new Meteor.Error('not-authorized'); |
||||
} |
||||
|
||||
return Integrations.find(mountIntegrationQueryBasedOnPermissions(this.userId)); |
||||
}); |
||||
@ -1,22 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
import s from 'underscore.string'; |
||||
|
||||
import { hasPermission } from '../../../authorization'; |
||||
import { LivechatCustomField } from '../../../models'; |
||||
|
||||
Meteor.publish('livechat:customFields', function(_id) { |
||||
console.warn('The publication "livechat:customFields" is deprecated and will be removed after version v3.0.0'); |
||||
if (!this.userId) { |
||||
return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'livechat:customFields' })); |
||||
} |
||||
|
||||
if (!hasPermission(this.userId, 'view-l-room')) { |
||||
return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'livechat:customFields' })); |
||||
} |
||||
|
||||
if (s.trim(_id)) { |
||||
return LivechatCustomField.find({ _id }); |
||||
} |
||||
|
||||
return LivechatCustomField.find(); |
||||
}); |
||||
@ -1,22 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
import { hasPermission } from '../../../authorization'; |
||||
import { LivechatDepartmentAgents } from '../../../models'; |
||||
|
||||
Meteor.publish('livechat:departmentAgents', function(departmentId, agentId) { |
||||
console.warn('The publication "livechat:departmentAgents" is deprecated and will be removed after version v3.0.0'); |
||||
if (!this.userId) { |
||||
return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'livechat:departmentAgents' })); |
||||
} |
||||
|
||||
if (!hasPermission(this.userId, 'view-l-room')) { |
||||
return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'livechat:departmentAgents' })); |
||||
} |
||||
|
||||
const filter = { |
||||
...departmentId && { departmentId }, |
||||
...agentId && { agentId }, |
||||
}; |
||||
|
||||
return LivechatDepartmentAgents.find(filter); |
||||
}); |
||||
@ -1,8 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
import { LivechatExternalMessage } from '../../../models/server'; |
||||
|
||||
Meteor.publish('livechat:externalMessages', function(roomId) { |
||||
console.warn('The publication "livechat:externalMessages" is deprecated and will be removed after version v3.0.0'); |
||||
return LivechatExternalMessage.findByRoomId(roomId); |
||||
}); |
||||
@ -1,34 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
import { hasPermission, getUsersInRole } from '../../../authorization'; |
||||
|
||||
Meteor.publish('livechat:agents', function() { |
||||
console.warn('The publication "livechat:agents" is deprecated and will be removed after version v3.0.0'); |
||||
if (!this.userId) { |
||||
return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'livechat:agents' })); |
||||
} |
||||
|
||||
if (!hasPermission(this.userId, 'manage-livechat-agents')) { |
||||
return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'livechat:agents' })); |
||||
} |
||||
|
||||
const self = this; |
||||
|
||||
const handle = getUsersInRole('livechat-agent').observeChanges({ |
||||
added(id, fields) { |
||||
self.added('agentUsers', id, fields); |
||||
}, |
||||
changed(id, fields) { |
||||
self.changed('agentUsers', id, fields); |
||||
}, |
||||
removed(id) { |
||||
self.removed('agentUsers', id); |
||||
}, |
||||
}); |
||||
|
||||
self.ready(); |
||||
|
||||
self.onStop(function() { |
||||
handle.stop(); |
||||
}); |
||||
}); |
||||
@ -1,59 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
import { hasPermission } from '../../../authorization'; |
||||
import { Settings } from '../../../models'; |
||||
|
||||
Meteor.publish('livechat:appearance', function() { |
||||
console.warn('The publication "livechat:appearance" is deprecated and will be removed after version v3.0.0'); |
||||
if (!this.userId) { |
||||
return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'livechat:appearance' })); |
||||
} |
||||
|
||||
if (!hasPermission(this.userId, 'view-livechat-manager')) { |
||||
return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'livechat:appearance' })); |
||||
} |
||||
|
||||
const query = { |
||||
_id: { |
||||
$in: [ |
||||
'Livechat_title', |
||||
'Livechat_title_color', |
||||
'Livechat_show_agent_info', |
||||
'Livechat_show_agent_email', |
||||
'Livechat_display_offline_form', |
||||
'Livechat_offline_form_unavailable', |
||||
'Livechat_offline_message', |
||||
'Livechat_offline_success_message', |
||||
'Livechat_offline_title', |
||||
'Livechat_offline_title_color', |
||||
'Livechat_offline_email', |
||||
'Livechat_conversation_finished_message', |
||||
'Livechat_conversation_finished_text', |
||||
'Livechat_registration_form', |
||||
'Livechat_name_field_registration_form', |
||||
'Livechat_email_field_registration_form', |
||||
'Livechat_registration_form_message', |
||||
], |
||||
}, |
||||
}; |
||||
|
||||
const self = this; |
||||
|
||||
const handle = Settings.find(query).observeChanges({ |
||||
added(id, fields) { |
||||
self.added('livechatAppearance', id, fields); |
||||
}, |
||||
changed(id, fields) { |
||||
self.changed('livechatAppearance', id, fields); |
||||
}, |
||||
removed(id) { |
||||
self.removed('livechatAppearance', id); |
||||
}, |
||||
}); |
||||
|
||||
this.ready(); |
||||
|
||||
this.onStop(() => { |
||||
handle.stop(); |
||||
}); |
||||
}); |
||||
@ -1,21 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
import { hasPermission } from '../../../authorization'; |
||||
import { LivechatDepartment } from '../../../models'; |
||||
|
||||
Meteor.publish('livechat:departments', function(_id, limit = 50) { |
||||
console.warn('The publication "livechat:departments" is deprecated and will be removed after version v3.0.0'); |
||||
if (!this.userId) { |
||||
return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'livechat:departments' })); |
||||
} |
||||
|
||||
if (!hasPermission(this.userId, 'view-l-room')) { |
||||
return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'livechat:departments' })); |
||||
} |
||||
|
||||
if (_id) { |
||||
return LivechatDepartment.findByDepartmentId(_id); |
||||
} |
||||
|
||||
return LivechatDepartment.find({}, { limit }); |
||||
}); |
||||
@ -1,51 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
import { hasPermission, hasRole } from '../../../authorization'; |
||||
import { settings } from '../../../settings'; |
||||
import { LivechatDepartment, LivechatDepartmentAgents, LivechatInquiry } from '../../../models/server'; |
||||
|
||||
Meteor.publish('livechat:inquiry', function(_id) { |
||||
console.warn('The publication "livechat:inquiry" is deprecated and will be removed after version v4.0.0'); |
||||
if (!this.userId) { |
||||
return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'livechat:inquiry' })); |
||||
} |
||||
|
||||
if (!hasPermission(this.userId, 'view-l-room')) { |
||||
return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'livechat:inquiry' })); |
||||
} |
||||
|
||||
const publication = this; |
||||
const limit = settings.get('Livechat_guest_pool_max_number_incoming_livechats_displayed'); |
||||
let departmentIds; |
||||
if (!hasRole(this.userId, 'livechat-manager')) { |
||||
const departmentAgents = LivechatDepartmentAgents.findByAgentId(this.userId).fetch().map((d) => d.departmentId); |
||||
departmentIds = LivechatDepartment.find({ _id: { $in: departmentAgents }, enabled: true }).fetch().map((d) => d._id); |
||||
} |
||||
|
||||
const filter = { |
||||
status: 'queued', |
||||
..._id && { _id }, |
||||
...departmentIds && departmentIds.length > 0 && { department: { $in: departmentIds } }, |
||||
}; |
||||
|
||||
const options = { |
||||
...limit && { limit }, |
||||
}; |
||||
|
||||
const cursorHandle = LivechatInquiry.find(filter, options).observeChanges({ |
||||
added(_id, record) { |
||||
return publication.added('rocketchat_livechat_inquiry', _id, record); |
||||
}, |
||||
changed(_id, record) { |
||||
return publication.changed('rocketchat_livechat_inquiry', _id, record); |
||||
}, |
||||
removed(_id) { |
||||
return publication.removed('rocketchat_livechat_inquiry', _id); |
||||
}, |
||||
}); |
||||
|
||||
this.ready(); |
||||
return this.onStop(function() { |
||||
return cursorHandle.stop(); |
||||
}); |
||||
}); |
||||
@ -1,35 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
import { hasPermission } from '../../../authorization'; |
||||
import { Settings } from '../../../models'; |
||||
|
||||
Meteor.publish('livechat:integration', function() { |
||||
console.warn('The publication "livechat:integration" is deprecated and will be removed after version v3.0.0'); |
||||
if (!this.userId) { |
||||
return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'livechat:integration' })); |
||||
} |
||||
|
||||
if (!hasPermission(this.userId, 'view-livechat-manager')) { |
||||
return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'livechat:integration' })); |
||||
} |
||||
|
||||
const self = this; |
||||
|
||||
const handle = Settings.findByIds(['Livechat_webhookUrl', 'Livechat_secret_token', 'Livechat_webhook_on_close', 'Livechat_webhook_on_offline_msg', 'Livechat_webhook_on_visitor_message', 'Livechat_webhook_on_agent_message']).observeChanges({ |
||||
added(id, fields) { |
||||
self.added('livechatIntegration', id, fields); |
||||
}, |
||||
changed(id, fields) { |
||||
self.changed('livechatIntegration', id, fields); |
||||
}, |
||||
removed(id) { |
||||
self.removed('livechatIntegration', id); |
||||
}, |
||||
}); |
||||
|
||||
self.ready(); |
||||
|
||||
self.onStop(function() { |
||||
handle.stop(); |
||||
}); |
||||
}); |
||||
@ -1,34 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
import { hasPermission, getUsersInRole } from '../../../authorization'; |
||||
|
||||
Meteor.publish('livechat:managers', function() { |
||||
console.warn('The publication "livechat:managers" is deprecated and will be removed after version v3.0.0'); |
||||
if (!this.userId) { |
||||
return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'livechat:managers' })); |
||||
} |
||||
|
||||
if (!hasPermission(this.userId, 'manage-livechat-managers')) { |
||||
return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'livechat:managers' })); |
||||
} |
||||
|
||||
const self = this; |
||||
|
||||
const handle = getUsersInRole('livechat-manager').observeChanges({ |
||||
added(id, fields) { |
||||
self.added('managerUsers', id, fields); |
||||
}, |
||||
changed(id, fields) { |
||||
self.changed('managerUsers', id, fields); |
||||
}, |
||||
removed(id) { |
||||
self.removed('managerUsers', id); |
||||
}, |
||||
}); |
||||
|
||||
self.ready(); |
||||
|
||||
self.onStop(function() { |
||||
handle.stop(); |
||||
}); |
||||
}); |
||||
@ -1,44 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
import { check } from 'meteor/check'; |
||||
|
||||
import { hasPermission } from '../../../authorization'; |
||||
import { LivechatRooms } from '../../../models'; |
||||
|
||||
Meteor.publish('livechat:monitoring', function(date) { |
||||
console.warn('The publication "livechat:monitoring" is deprecated and will be removed after version v3.0.0'); |
||||
if (!this.userId) { |
||||
return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'livechat:monitoring' })); |
||||
} |
||||
|
||||
if (!hasPermission(this.userId, 'view-livechat-manager')) { |
||||
return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'livechat:monitoring' })); |
||||
} |
||||
|
||||
date = { |
||||
gte: new Date(date.gte), |
||||
lt: new Date(date.lt), |
||||
}; |
||||
|
||||
check(date.gte, Date); |
||||
check(date.lt, Date); |
||||
|
||||
const self = this; |
||||
|
||||
const handle = LivechatRooms.getAnalyticsMetricsBetweenDate('l', date).observeChanges({ |
||||
added(id, fields) { |
||||
self.added('livechatMonitoring', id, fields); |
||||
}, |
||||
changed(id, fields) { |
||||
self.changed('livechatMonitoring', id, fields); |
||||
}, |
||||
removed(id) { |
||||
self.removed('livechatMonitoring', id); |
||||
}, |
||||
}); |
||||
|
||||
self.ready(); |
||||
|
||||
self.onStop(function() { |
||||
handle.stop(); |
||||
}); |
||||
}); |
||||
@ -1,13 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
import { hasPermission } from '../../../authorization'; |
||||
import { LivechatOfficeHour } from '../../../models'; |
||||
|
||||
console.warn('The publication "livechat:officeHour" is deprecated and will be removed after version v3.0.0'); |
||||
Meteor.publish('livechat:officeHour', function() { |
||||
if (!hasPermission(this.userId, 'view-l-room')) { |
||||
return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'livechat:officeHour' })); |
||||
} |
||||
|
||||
return LivechatOfficeHour.find(); |
||||
}); |
||||
@ -1,34 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
import { hasPermission } from '../../../authorization'; |
||||
import { LivechatDepartmentAgents } from '../../../models'; |
||||
|
||||
Meteor.publish('livechat:queue', function() { |
||||
console.warn('The publication "livechat:queue" is deprecated and will be removed after version v3.0.0'); |
||||
if (!this.userId) { |
||||
return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'livechat:queue' })); |
||||
} |
||||
|
||||
if (!hasPermission(this.userId, 'view-l-room')) { |
||||
return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'livechat:queue' })); |
||||
} |
||||
const self = this; |
||||
|
||||
const handleDepts = LivechatDepartmentAgents.findUsersInQueue().observeChanges({ |
||||
added(id, fields) { |
||||
self.added('livechatQueueUser', id, fields); |
||||
}, |
||||
changed(id, fields) { |
||||
self.changed('livechatQueueUser', id, fields); |
||||
}, |
||||
removed(id) { |
||||
self.removed('livechatQueueUser', id); |
||||
}, |
||||
}); |
||||
|
||||
this.ready(); |
||||
|
||||
this.onStop(() => { |
||||
handleDepts.stop(); |
||||
}); |
||||
}); |
||||
@ -1,108 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
import { Match, check } from 'meteor/check'; |
||||
|
||||
import { hasPermission } from '../../../authorization'; |
||||
import { LivechatDepartment, LivechatRooms } from '../../../models'; |
||||
import { canAccessRoom } from '../../../authorization/server/functions/canAccessRoom'; |
||||
|
||||
const userCanAccessRoom = ({ _id }) => { |
||||
if (!_id) { |
||||
return; |
||||
} |
||||
|
||||
const room = LivechatRooms.findOneById(_id); |
||||
const user = Meteor.user(); |
||||
|
||||
return canAccessRoom(room, user); |
||||
}; |
||||
|
||||
Meteor.publish('livechat:rooms', function(filter = {}, offset = 0, limit = 20) { |
||||
console.warn('The publication "livechat:rooms" is deprecated and will be removed after version v4.0.0'); |
||||
if (!this.userId) { |
||||
return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'livechat:rooms' })); |
||||
} |
||||
|
||||
if (!hasPermission(this.userId, 'view-livechat-rooms') && !userCanAccessRoom(filter)) { |
||||
return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'livechat:rooms' })); |
||||
} |
||||
|
||||
check(filter, { |
||||
_id: Match.Maybe(String), // room id to filter
|
||||
name: Match.Maybe(String), // room name to filter
|
||||
agent: Match.Maybe(String), // agent _id who is serving
|
||||
status: Match.Maybe(String), // either 'opened' or 'closed'
|
||||
from: Match.Maybe(Date), |
||||
to: Match.Maybe(Date), |
||||
department: Match.Maybe(String), // room department
|
||||
customFields: Match.Maybe(Object), |
||||
tags: Match.Maybe(Array), |
||||
}); |
||||
|
||||
const query = {}; |
||||
if (filter.name) { |
||||
query.fname = new RegExp(filter.name, 'i'); |
||||
} |
||||
if (filter.agent) { |
||||
query['servedBy._id'] = filter.agent; |
||||
} |
||||
if (filter.status) { |
||||
if (filter.status === 'opened') { |
||||
query.open = true; |
||||
} else { |
||||
query.open = { $exists: false }; |
||||
} |
||||
} |
||||
if (filter.from) { |
||||
query.ts = { |
||||
$gte: filter.from, |
||||
}; |
||||
} |
||||
if (filter.to) { |
||||
filter.to.setDate(filter.to.getDate() + 1); |
||||
filter.to.setSeconds(filter.to.getSeconds() - 1); |
||||
|
||||
if (!query.ts) { |
||||
query.ts = {}; |
||||
} |
||||
query.ts.$lte = filter.to; |
||||
} |
||||
if (filter.department) { |
||||
query.departmentId = filter.department; |
||||
} |
||||
if (filter._id) { |
||||
query._id = filter._id; |
||||
} |
||||
if (filter.customFields) { |
||||
for (const key in filter.customFields) { |
||||
if (filter.customFields[key]) { |
||||
query[`livechatData.${ key }`] = new RegExp(filter.customFields[key], 'i'); |
||||
} |
||||
} |
||||
} |
||||
if (filter.tags && filter.tags.length) { |
||||
query.tags = { |
||||
$in: filter.tags, |
||||
}; |
||||
} |
||||
|
||||
const self = this; |
||||
const handle = LivechatRooms.findLivechat(query, offset, limit).observeChanges({ |
||||
added(id, fields) { |
||||
fields = Object.assign(fields, { lookupDepartment: fields.departmentId ? LivechatDepartment.findOneById(fields.departmentId) : {} }); |
||||
self.added('livechatRoom', id, fields); |
||||
}, |
||||
changed(id, fields) { |
||||
fields = Object.assign(fields, { lookupDepartment: fields.departmentId ? LivechatDepartment.findOneById(fields.departmentId) : {} }); |
||||
self.changed('livechatRoom', id, fields); |
||||
}, |
||||
removed(id) { |
||||
self.removed('livechatRoom', id); |
||||
}, |
||||
}); |
||||
|
||||
this.ready(); |
||||
|
||||
this.onStop(() => { |
||||
handle.stop(); |
||||
}); |
||||
}); |
||||
@ -1,20 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
import { hasPermission } from '../../../authorization'; |
||||
import { LivechatTrigger } from '../../../models'; |
||||
|
||||
Meteor.publish('livechat:triggers', function(_id) { |
||||
console.warn('The publication "livechat:triggers" is deprecated and will be removed after version v3.0.0'); |
||||
if (!this.userId) { |
||||
return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'livechat:triggers' })); |
||||
} |
||||
|
||||
if (!hasPermission(this.userId, 'view-livechat-manager')) { |
||||
return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'livechat:triggers' })); |
||||
} |
||||
|
||||
if (_id !== undefined) { |
||||
return LivechatTrigger.findById(_id); |
||||
} |
||||
return LivechatTrigger.find(); |
||||
}); |
||||
@ -1,44 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
import { check } from 'meteor/check'; |
||||
|
||||
import { hasPermission } from '../../../authorization'; |
||||
import { LivechatVisitors } from '../../../models'; |
||||
|
||||
Meteor.publish('livechat:visitors', function(date) { |
||||
console.warn('The publication "livechat:visitors" is deprecated and will be removed after version v3.0.0'); |
||||
if (!this.userId) { |
||||
return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'livechat:visitors' })); |
||||
} |
||||
|
||||
if (!hasPermission(this.userId, 'view-livechat-manager')) { |
||||
return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'livechat:visitors' })); |
||||
} |
||||
|
||||
date = { |
||||
gte: new Date(date.gte), |
||||
lt: new Date(date.lt), |
||||
}; |
||||
|
||||
check(date.gte, Date); |
||||
check(date.lt, Date); |
||||
|
||||
const self = this; |
||||
|
||||
const handle = LivechatVisitors.getVisitorsBetweenDate(date).observeChanges({ |
||||
added(id, fields) { |
||||
self.added('livechatVisitors', id, fields); |
||||
}, |
||||
changed(id, fields) { |
||||
self.changed('livechatVisitors', id, fields); |
||||
}, |
||||
removed(id) { |
||||
self.removed('livechatVisitors', id); |
||||
}, |
||||
}); |
||||
|
||||
self.ready(); |
||||
|
||||
self.onStop(function() { |
||||
handle.stop(); |
||||
}); |
||||
}); |
||||
@ -1,46 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
import { hasPermission } from '../../../authorization'; |
||||
import { LivechatRooms, Subscriptions } from '../../../models'; |
||||
|
||||
Meteor.publish('livechat:visitorHistory', function({ rid: roomId }) { |
||||
console.warn('The publication "livechat:visitorHistory" is deprecated and will be removed after version v3.0.0'); |
||||
if (!this.userId) { |
||||
return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'livechat:visitorHistory' })); |
||||
} |
||||
|
||||
if (!hasPermission(this.userId, 'view-l-room')) { |
||||
return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'livechat:visitorHistory' })); |
||||
} |
||||
|
||||
const room = LivechatRooms.findOneById(roomId); |
||||
|
||||
const subscription = Subscriptions.findOneByRoomIdAndUserId(room._id, this.userId, { fields: { _id: 1 } }); |
||||
if (!subscription) { |
||||
return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'livechat:visitorHistory' })); |
||||
} |
||||
|
||||
const self = this; |
||||
|
||||
if (room && room.v && room.v._id) { |
||||
const handle = LivechatRooms.findByVisitorId(room.v._id).observeChanges({ |
||||
added(id, fields) { |
||||
self.added('visitor_history', id, fields); |
||||
}, |
||||
changed(id, fields) { |
||||
self.changed('visitor_history', id, fields); |
||||
}, |
||||
removed(id) { |
||||
self.removed('visitor_history', id); |
||||
}, |
||||
}); |
||||
|
||||
self.ready(); |
||||
|
||||
self.onStop(function() { |
||||
handle.stop(); |
||||
}); |
||||
} else { |
||||
self.ready(); |
||||
} |
||||
}); |
||||
@ -1,22 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
import { hasPermission } from '../../../authorization'; |
||||
import { LivechatRooms, LivechatVisitors } from '../../../models'; |
||||
|
||||
Meteor.publish('livechat:visitorInfo', function({ rid: roomId }) { |
||||
console.warn('The publication "livechat:visitorInfo" is deprecated and will be removed after version v3.0.0'); |
||||
if (!this.userId) { |
||||
return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'livechat:visitorInfo' })); |
||||
} |
||||
|
||||
if (!hasPermission(this.userId, 'view-l-room')) { |
||||
return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'livechat:visitorInfo' })); |
||||
} |
||||
|
||||
const room = LivechatRooms.findOneById(roomId); |
||||
|
||||
if (room && room.v && room.v._id) { |
||||
return LivechatVisitors.findById(room.v._id); |
||||
} |
||||
return this.ready(); |
||||
}); |
||||
@ -1,40 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
import { hasPermission } from '../../../authorization'; |
||||
import { LivechatRooms, Messages } from '../../../models'; |
||||
|
||||
Meteor.publish('livechat:visitorPageVisited', function({ rid: roomId }) { |
||||
console.warn('The publication "livechat:visitorPageVisited" is deprecated and will be removed after version v3.0.0'); |
||||
if (!this.userId) { |
||||
return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'livechat:visitorPageVisited' })); |
||||
} |
||||
|
||||
if (!hasPermission(this.userId, 'view-l-room')) { |
||||
return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'livechat:visitorPageVisited' })); |
||||
} |
||||
|
||||
const self = this; |
||||
const room = LivechatRooms.findOneById(roomId); |
||||
|
||||
if (room) { |
||||
const handle = Messages.findByRoomIdAndType(room._id, 'livechat_navigation_history').observeChanges({ |
||||
added(id, fields) { |
||||
self.added('visitor_navigation_history', id, fields); |
||||
}, |
||||
changed(id, fields) { |
||||
self.changed('visitor_navigation_history', id, fields); |
||||
}, |
||||
removed(id) { |
||||
self.removed('visitor_navigation_history', id); |
||||
}, |
||||
}); |
||||
|
||||
self.ready(); |
||||
|
||||
self.onStop(function() { |
||||
handle.stop(); |
||||
}); |
||||
} else { |
||||
self.ready(); |
||||
} |
||||
}); |
||||
@ -1 +0,0 @@ |
||||
import './publications/mentionedMessages'; |
||||
@ -1,40 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
import { Users, Messages } from '../../../models'; |
||||
|
||||
Meteor.publish('mentionedMessages', function(rid, limit = 50) { |
||||
console.warn('The publication "mentionedMessages" is deprecated and will be removed after version v3.0.0'); |
||||
if (!this.userId) { |
||||
return this.ready(); |
||||
} |
||||
const publication = this; |
||||
const user = Users.findOneById(this.userId); |
||||
if (!user) { |
||||
return this.ready(); |
||||
} |
||||
if (!Meteor.call('canAccessRoom', rid, this.userId)) { |
||||
return this.ready(); |
||||
} |
||||
const cursorHandle = Messages.findVisibleByMentionAndRoomId(user.username, rid, { |
||||
sort: { |
||||
ts: -1, |
||||
}, |
||||
limit, |
||||
}).observeChanges({ |
||||
added(_id, record) { |
||||
record.mentionedList = true; |
||||
return publication.added('rocketchat_mentioned_message', _id, record); |
||||
}, |
||||
changed(_id, record) { |
||||
record.mentionedList = true; |
||||
return publication.changed('rocketchat_mentioned_message', _id, record); |
||||
}, |
||||
removed(_id) { |
||||
return publication.removed('rocketchat_mentioned_message', _id); |
||||
}, |
||||
}); |
||||
this.ready(); |
||||
return this.onStop(function() { |
||||
return cursorHandle.stop(); |
||||
}); |
||||
}); |
||||
@ -1,4 +1,3 @@ |
||||
import './settings'; |
||||
import './pinMessage'; |
||||
import './publications/pinnedMessages'; |
||||
import './startup/indexes'; |
||||
|
||||
@ -1,34 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
import { Users, Messages } from '../../../models'; |
||||
|
||||
Meteor.publish('pinnedMessages', function(rid, limit = 50) { |
||||
console.warn('The publication "pinnedMessages" is deprecated and will be removed after version v3.0.0'); |
||||
if (!this.userId) { |
||||
return this.ready(); |
||||
} |
||||
const publication = this; |
||||
|
||||
const user = Users.findOneById(this.userId); |
||||
if (!user) { |
||||
return this.ready(); |
||||
} |
||||
if (!Meteor.call('canAccessRoom', rid, this.userId)) { |
||||
return this.ready(); |
||||
} |
||||
const cursorHandle = Messages.findPinnedByRoom(rid, { sort: { ts: -1 }, limit }).observeChanges({ |
||||
added(_id, record) { |
||||
return publication.added('rocketchat_pinned_message', _id, record); |
||||
}, |
||||
changed(_id, record) { |
||||
return publication.changed('rocketchat_pinned_message', _id, record); |
||||
}, |
||||
removed(_id) { |
||||
return publication.removed('rocketchat_pinned_message', _id); |
||||
}, |
||||
}); |
||||
this.ready(); |
||||
return this.onStop(function() { |
||||
return cursorHandle.stop(); |
||||
}); |
||||
}); |
||||
@ -1,56 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
import { Messages, Users, Rooms } from '../../../models'; |
||||
|
||||
Meteor.publish('snippetedMessage', function(_id) { |
||||
console.warn('The publication "snippetedMessage" is deprecated and will be removed after version v3.0.0'); |
||||
if (typeof this.userId === 'undefined' || this.userId === null) { |
||||
return this.ready(); |
||||
} |
||||
|
||||
const snippet = Messages.findOne({ _id, snippeted: true }); |
||||
const user = Users.findOneById(this.userId); |
||||
const roomSnippetQuery = { |
||||
_id: snippet.rid, |
||||
usernames: { |
||||
$in: [ |
||||
user.username, |
||||
], |
||||
}, |
||||
}; |
||||
|
||||
if (!Meteor.call('canAccessRoom', snippet.rid, this.userId)) { |
||||
return this.ready(); |
||||
} |
||||
|
||||
if (Rooms.findOne(roomSnippetQuery) === undefined) { |
||||
return this.ready(); |
||||
} |
||||
|
||||
const publication = this; |
||||
|
||||
|
||||
if (typeof user === 'undefined' || user === null) { |
||||
return this.ready(); |
||||
} |
||||
|
||||
const cursor = Messages.find( |
||||
{ _id }, |
||||
).observeChanges({ |
||||
added(_id, record) { |
||||
publication.added('rocketchat_snippeted_message', _id, record); |
||||
}, |
||||
changed(_id, record) { |
||||
publication.changed('rocketchat_snippeted_message', _id, record); |
||||
}, |
||||
removed(_id) { |
||||
publication.removed('rocketchat_snippeted_message', _id); |
||||
}, |
||||
}); |
||||
|
||||
this.ready(); |
||||
|
||||
this.onStop = function() { |
||||
cursor.stop(); |
||||
}; |
||||
}); |
||||
@ -1,45 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
import { Users, Messages } from '../../../models'; |
||||
|
||||
Meteor.publish('snippetedMessages', function(rid, limit = 50) { |
||||
console.warn('The publication "snippetedMessages" is deprecated and will be removed after version v3.0.0'); |
||||
if (typeof this.userId === 'undefined' || this.userId === null) { |
||||
return this.ready(); |
||||
} |
||||
|
||||
const publication = this; |
||||
|
||||
const user = Users.findOneById(this.userId); |
||||
|
||||
if (typeof user === 'undefined' || user === null) { |
||||
return this.ready(); |
||||
} |
||||
|
||||
if (!Meteor.call('canAccessRoom', rid, this.userId)) { |
||||
return this.ready(); |
||||
} |
||||
|
||||
const cursorHandle = Messages.findSnippetedByRoom( |
||||
rid, |
||||
{ |
||||
sort: { ts: -1 }, |
||||
limit, |
||||
}, |
||||
).observeChanges({ |
||||
added(_id, record) { |
||||
publication.added('rocketchat_snippeted_message', _id, record); |
||||
}, |
||||
changed(_id, record) { |
||||
publication.changed('rocketchat_snippeted_message', _id, record); |
||||
}, |
||||
removed(_id) { |
||||
publication.removed('rocketchat_snippeted_message', _id); |
||||
}, |
||||
}); |
||||
this.ready(); |
||||
|
||||
this.onStop = function() { |
||||
cursorHandle.stop(); |
||||
}; |
||||
}); |
||||
@ -1,4 +1,3 @@ |
||||
import './settings'; |
||||
import './starMessage'; |
||||
import './publications/starredMessages'; |
||||
import './startup/indexes'; |
||||
|
||||
@ -1,38 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
import { Users, Messages } from '../../../models'; |
||||
|
||||
Meteor.publish('starredMessages', function(rid, limit = 50) { |
||||
console.warn('The publication "starredMessages" is deprecated and will be removed after version v3.0.0'); |
||||
if (!this.userId) { |
||||
return this.ready(); |
||||
} |
||||
const publication = this; |
||||
const user = Users.findOneById(this.userId); |
||||
if (!user) { |
||||
return this.ready(); |
||||
} |
||||
if (!Meteor.call('canAccessRoom', rid, this.userId)) { |
||||
return this.ready(); |
||||
} |
||||
const cursorHandle = Messages.findStarredByUserAtRoom(this.userId, rid, { |
||||
sort: { |
||||
ts: -1, |
||||
}, |
||||
limit, |
||||
}).observeChanges({ |
||||
added(_id, record) { |
||||
return publication.added('rocketchat_starred_message', _id, record); |
||||
}, |
||||
changed(_id, record) { |
||||
return publication.changed('rocketchat_starred_message', _id, record); |
||||
}, |
||||
removed(_id) { |
||||
return publication.removed('rocketchat_starred_message', _id); |
||||
}, |
||||
}); |
||||
this.ready(); |
||||
return this.onStop(function() { |
||||
return cursorHandle.stop(); |
||||
}); |
||||
}); |
||||
@ -1,34 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
import { Mongo } from 'meteor/mongo'; |
||||
// This also attaches an onStop callback to sub, so we don't need to worry about that.
|
||||
// https://github.com/meteor/meteor/blob/devel/packages/mongo/collection.js
|
||||
const Autocomplete = class { |
||||
publishCursor(cursor, sub) { |
||||
Mongo.Collection._publishCursor(cursor, sub, 'autocompleteRecords'); |
||||
} |
||||
}; |
||||
|
||||
Meteor.publish('autocomplete-recordset', function(selector, options, collName) { |
||||
console.warn('The publication "autocomplete-recordset" is deprecated and will be removed after version v3.0.0'); |
||||
const collection = global[collName]; |
||||
|
||||
// This is a semi-documented Meteor feature:
|
||||
// https://github.com/meteor/meteor/blob/devel/packages/mongo-livedata/collection.js
|
||||
if (!collection) { |
||||
throw new Error(`${ collName } is not defined on the global namespace of the server.`); |
||||
} |
||||
if (!collection._isInsecure()) { |
||||
Meteor._debug(`${ collName } is a secure collection, therefore no data was returned because the client could compromise security by subscribing to arbitrary server collections via the browser console. Please write your own publish function.`); |
||||
return []; // We need this for the subscription to be marked ready
|
||||
} |
||||
if (options.limit) { |
||||
// guard against client-side DOS: hard limit to 50
|
||||
options.limit = Math.min(50, Math.abs(options.limit)); |
||||
} |
||||
|
||||
// Push this into our own collection on the client so they don't interfere with other publications of the named collection.
|
||||
// This also stops the observer automatically when the subscription is stopped.
|
||||
Autocomplete.publishCursor(collection.find(selector, options), this); |
||||
// Mark the subscription ready after the initial addition of documents.
|
||||
this.ready(); |
||||
}); |
||||
@ -1 +0,0 @@ |
||||
import './autocomplete-server'; |
||||
@ -1,15 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
import { hasPermission } from '../../../../authorization'; |
||||
import { OAuthApps } from '../../../../models'; |
||||
|
||||
Meteor.publish('oauthApps', function() { |
||||
console.warn('The publication "oauthApps" is deprecated and will be removed after version v3.0.0'); |
||||
if (!this.userId) { |
||||
return this.ready(); |
||||
} |
||||
if (!hasPermission(this.userId, 'manage-oauth-apps')) { |
||||
this.error(Meteor.Error('error-not-allowed', 'Not allowed', { publish: 'oauthApps' })); |
||||
} |
||||
return OAuthApps.find(); |
||||
}); |
||||
@ -1,6 +1,5 @@ |
||||
import './oauth/oauth2-server'; |
||||
import './oauth/default-services'; |
||||
import './admin/publications/oauthApps'; |
||||
import './admin/methods/addOAuthApp'; |
||||
import './admin/methods/updateOAuthApp'; |
||||
import './admin/methods/deleteOAuthApp'; |
||||
|
||||
@ -1 +0,0 @@ |
||||
import './publications/adminRooms'; |
||||
@ -1,59 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
import s from 'underscore.string'; |
||||
|
||||
import { hasPermission } from '../../../authorization'; |
||||
import { Rooms } from '../../../models/server'; |
||||
|
||||
Meteor.publish('adminRooms', function(filter, types = [], limit) { |
||||
console.warn('The publication "adminRooms" is deprecated and will be removed after version v3.0.0'); |
||||
const showTypes = Array.isArray(types) ? types.filter((type) => type !== 'dicussions') : []; |
||||
const discussion = types.includes('dicussions'); |
||||
|
||||
if (!this.userId) { |
||||
return this.ready(); |
||||
} |
||||
|
||||
if (hasPermission(this.userId, 'view-room-administration') !== true) { |
||||
return this.ready(); |
||||
} |
||||
|
||||
const options = { |
||||
fields: { |
||||
prid: 1, |
||||
fname: 1, |
||||
name: 1, |
||||
t: 1, |
||||
cl: 1, |
||||
u: 1, |
||||
usernames: 1, |
||||
usersCount: 1, |
||||
muted: 1, |
||||
unmuted: 1, |
||||
ro: 1, |
||||
default: 1, |
||||
topic: 1, |
||||
msgs: 1, |
||||
archived: 1, |
||||
tokenpass: 1, |
||||
}, |
||||
limit, |
||||
sort: { |
||||
default: -1, |
||||
name: 1, |
||||
}, |
||||
}; |
||||
|
||||
const name = s.trim(filter); |
||||
|
||||
if (name && showTypes.length) { |
||||
// CACHE: can we stop using publications here?
|
||||
return Rooms.findByNameContainingAndTypes(name, showTypes, discussion, options); |
||||
} |
||||
|
||||
if (showTypes.length) { |
||||
// CACHE: can we stop using publications here?
|
||||
return Rooms.findByTypes(showTypes, discussion, options); |
||||
} |
||||
// CACHE: can we stop using publications here?
|
||||
return Rooms.findByNameContaining(filter, discussion, options); |
||||
}); |
||||
@ -1,31 +0,0 @@ |
||||
import s from 'underscore.string'; |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
import { CustomUserStatus } from '../../../models'; |
||||
|
||||
Meteor.publish('fullUserStatusData', function(filter, limit) { |
||||
console.warn('The publication "fullUserStatusData" is deprecated and will be removed after version v3.0.0'); |
||||
if (!this.userId) { |
||||
return this.ready(); |
||||
} |
||||
|
||||
const fields = { |
||||
name: 1, |
||||
statusType: 1, |
||||
}; |
||||
|
||||
filter = s.trim(filter); |
||||
|
||||
const options = { |
||||
fields, |
||||
limit, |
||||
sort: { name: 1 }, |
||||
}; |
||||
|
||||
if (filter) { |
||||
const filterReg = new RegExp(s.escapeRegExp(filter), 'i'); |
||||
return CustomUserStatus.findByName(filterReg, options); |
||||
} |
||||
|
||||
return CustomUserStatus.find({}, options); |
||||
}); |
||||
@ -1,19 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
import { WebdavAccounts } from '../../../models'; |
||||
|
||||
Meteor.publish('webdavAccounts', function() { |
||||
console.warn('The publication "webdavAccounts" is deprecated and will be removed after version v3.0.0'); |
||||
if (!this.userId) { |
||||
return this.error(new Meteor.Error('error-not-authorized', 'Not authorized', { publish: 'webdavAccounts' })); |
||||
} |
||||
|
||||
return WebdavAccounts.findWithUserId(this.userId, { |
||||
fields: { |
||||
_id: 1, |
||||
username: 1, |
||||
server_url: 1, |
||||
name: 1, |
||||
}, |
||||
}); |
||||
}); |
||||
@ -1 +0,0 @@ |
||||
import './personalAccessTokens'; |
||||
@ -1,39 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
import { hasPermission } from '../../../../app/authorization'; |
||||
import { Users } from '../../../../app/models'; |
||||
|
||||
Meteor.publish('personalAccessTokens', function() { |
||||
console.warn('The publication "personalAccessTokens" is deprecated and will be removed after version v3.0.0'); |
||||
if (!this.userId) { |
||||
return this.ready(); |
||||
} |
||||
if (!hasPermission(this.userId, 'create-personal-access-tokens')) { |
||||
return this.ready(); |
||||
} |
||||
const self = this; |
||||
const getFieldsToPublish = (fields) => fields.services.resume.loginTokens |
||||
.filter((loginToken) => loginToken.type && loginToken.type === 'personalAccessToken') |
||||
.map((loginToken) => ({ |
||||
name: loginToken.name, |
||||
createdAt: loginToken.createdAt, |
||||
lastTokenPart: loginToken.lastTokenPart, |
||||
})); |
||||
const handle = Users.getLoginTokensByUserId(this.userId).observeChanges({ |
||||
added(id, fields) { |
||||
self.added('personal_access_tokens', id, { tokens: getFieldsToPublish(fields) }); |
||||
}, |
||||
changed(id, fields) { |
||||
self.changed('personal_access_tokens', id, { tokens: getFieldsToPublish(fields) }); |
||||
}, |
||||
removed(id) { |
||||
self.removed('personal_access_tokens', id); |
||||
}, |
||||
}); |
||||
|
||||
self.ready(); |
||||
|
||||
self.onStop(function() { |
||||
handle.stop(); |
||||
}); |
||||
}); |
||||
@ -1,20 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
import { Users } from '../../app/models'; |
||||
|
||||
Meteor.publish('activeUsers', function() { |
||||
console.warn('The publication "activeUsers" is deprecated and will be removed after version v3.0.0'); |
||||
if (!this.userId) { |
||||
return this.ready(); |
||||
} |
||||
|
||||
return Users.findUsersNotOffline({ |
||||
fields: { |
||||
username: 1, |
||||
name: 1, |
||||
status: 1, |
||||
utcOffset: 1, |
||||
statusText: 1, |
||||
}, |
||||
}); |
||||
}); |
||||
@ -1,45 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
import { hasPermission } from '../../app/authorization'; |
||||
import { Rooms } from '../../app/models'; |
||||
|
||||
Meteor.publish('channelAndPrivateAutocomplete', function(selector) { |
||||
console.warn('The publication "channelAndPrivateAutocomplete" is deprecated and will be removed after version v3.0.0'); |
||||
if (!this.userId) { |
||||
return this.ready(); |
||||
} |
||||
|
||||
if (hasPermission(this.userId, 'view-other-user-channels') !== true) { |
||||
return this.ready(); |
||||
} |
||||
|
||||
const pub = this; |
||||
const options = { |
||||
fields: { |
||||
_id: 1, |
||||
name: 1, |
||||
}, |
||||
limit: 10, |
||||
sort: { |
||||
name: 1, |
||||
}, |
||||
}; |
||||
|
||||
const cursorHandle = Rooms.findChannelAndPrivateByNameStarting(selector.name, options).observeChanges({ |
||||
added(_id, record) { |
||||
return pub.added('autocompleteRecords', _id, record); |
||||
}, |
||||
changed(_id, record) { |
||||
return pub.changed('autocompleteRecords', _id, record); |
||||
}, |
||||
removed(_id, record) { |
||||
return pub.removed('autocompleteRecords', _id, record); |
||||
}, |
||||
}); |
||||
|
||||
this.ready(); |
||||
|
||||
this.onStop(function() { |
||||
return cursorHandle.stop(); |
||||
}); |
||||
}); |
||||
@ -1,31 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
import { getFullUserData } from '../../app/lib'; |
||||
|
||||
Meteor.publish('fullUserData', function(filter, limit) { |
||||
console.warn('The publication "fullUserData" is deprecated and will be removed after version v3.0.0'); |
||||
if (!this.userId) { |
||||
return this.ready(); |
||||
} |
||||
|
||||
const handle = getFullUserData({ |
||||
userId: this.userId, |
||||
filter, |
||||
limit, |
||||
}).observeChanges({ |
||||
added: (id, fields) => { |
||||
this.added('rocketchat_full_user', id, fields); |
||||
}, |
||||
|
||||
changed: (id, fields) => { |
||||
this.changed('rocketchat_full_user', id, fields); |
||||
}, |
||||
|
||||
removed: (id) => { |
||||
this.removed('rocketchat_full_user', id); |
||||
}, |
||||
}); |
||||
|
||||
this.ready(); |
||||
this.onStop(() => handle.stop()); |
||||
}); |
||||
@ -1,8 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
import { roomFiles } from '../lib/roomFiles'; |
||||
|
||||
Meteor.publish('roomFiles', function(rid, limit = 50) { |
||||
console.warn('The publication "roomFiles" is deprecated and will be removed after version v3.0.0'); |
||||
return roomFiles(this, { rid, limit }); |
||||
}); |
||||
@ -1,8 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
import { roomFiles } from '../lib/roomFiles'; |
||||
|
||||
Meteor.publish('roomFilesWithSearchText', function(rid, searchText, limit = 50) { |
||||
console.warn('The publication "roomFilesWithSearchText" is deprecated and will be removed after version v3.0.0'); |
||||
return roomFiles(this, { rid, searchText, limit }); |
||||
}); |
||||
@ -1,55 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
import _ from 'underscore'; |
||||
|
||||
import { hasPermission } from '../../app/authorization/server'; |
||||
import { Users } from '../../app/models/server'; |
||||
|
||||
Meteor.publish('userAutocomplete', function(selector) { |
||||
console.warn('The publication "userAutocomplete" is deprecated and will be removed after version v3.0.0'); |
||||
const uid = this.userId; |
||||
if (!uid) { |
||||
return this.ready(); |
||||
} |
||||
|
||||
if (!_.isObject(selector)) { |
||||
return this.ready(); |
||||
} |
||||
|
||||
if (!hasPermission(uid, 'view-outside-room')) { |
||||
return this.ready(); |
||||
} |
||||
|
||||
const options = { |
||||
fields: { |
||||
name: 1, |
||||
username: 1, |
||||
status: 1, |
||||
}, |
||||
sort: { |
||||
username: 1, |
||||
}, |
||||
limit: 10, |
||||
}; |
||||
|
||||
const pub = this; |
||||
const exceptions = selector.exceptions || []; |
||||
const conditions = selector.conditions || {}; |
||||
|
||||
const cursorHandle = Users.findActiveByUsernameOrNameRegexWithExceptionsAndConditions(selector.term, exceptions, conditions, options).observeChanges({ |
||||
added(_id, record) { |
||||
return pub.added('autocompleteRecords', _id, record); |
||||
}, |
||||
changed(_id, record) { |
||||
return pub.changed('autocompleteRecords', _id, record); |
||||
}, |
||||
removed(_id, record) { |
||||
return pub.removed('autocompleteRecords', _id, record); |
||||
}, |
||||
}); |
||||
|
||||
this.ready(); |
||||
|
||||
this.onStop(function() { |
||||
return cursorHandle.stop(); |
||||
}); |
||||
}); |
||||
@ -1,28 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
import { hasPermission } from '../../app/authorization'; |
||||
import { Subscriptions } from '../../app/models'; |
||||
|
||||
Meteor.publish('userChannels', function(userId) { |
||||
console.warn('The publication "userChannels" is deprecated and will be removed after version v3.0.0'); |
||||
if (!this.userId) { |
||||
return this.ready(); |
||||
} |
||||
|
||||
if (hasPermission(this.userId, 'view-other-user-channels') !== true) { |
||||
return this.ready(); |
||||
} |
||||
|
||||
return Subscriptions.findByUserId(userId, { |
||||
fields: { |
||||
rid: 1, |
||||
name: 1, |
||||
t: 1, |
||||
u: 1, |
||||
}, |
||||
sort: { |
||||
t: 1, |
||||
name: 1, |
||||
}, |
||||
}); |
||||
}); |
||||
@ -1,23 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
import { Users } from '../../app/models'; |
||||
import { getDefaultUserFields } from '../../app/utils/server/functions/getDefaultUserFields'; |
||||
|
||||
Meteor.publish('userData', function() { |
||||
console.warn('The publication "userData" is deprecated and will be removed after version v3.0.0'); |
||||
if (!this.userId) { |
||||
return this.ready(); |
||||
} |
||||
|
||||
const handle = Users.find({ _id: this.userId }, { |
||||
fields: getDefaultUserFields(), |
||||
}).observeChanges({ |
||||
added: (_id, record) => this.added('own_user', _id, record), |
||||
changed: (_id, record) => this.changed('own_user', _id, record), |
||||
removed: (_id, record) => this.removed('own_user', _id, record), |
||||
}); |
||||
|
||||
this.ready(); |
||||
|
||||
this.onStop(() => handle.stop()); |
||||
}); |
||||
Loading…
Reference in new issue