[BREAK] Remove deprecated publications (#16351)

pull/16397/head
Marcos Spessatto Defendi 6 years ago committed by GitHub
parent 5c0490f2ed
commit 5bbd7d772a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/api/server/v1/misc.js
  2. 3
      app/authorization/server/index.js
  3. 21
      app/authorization/server/publications/roles.js
  4. 9
      app/authorization/server/startup.js
  5. 0
      app/authorization/server/streamer/permissions/emitter.js
  6. 0
      app/authorization/server/streamer/permissions/index.js
  7. 1
      app/custom-sounds/server/index.js
  8. 31
      app/custom-sounds/server/publications/customSounds.js
  9. 2
      app/discussion/server/index.js
  10. 45
      app/discussion/server/publications/discussionParentAutocomplete.js
  11. 33
      app/discussion/server/publications/discussionsOfRoom.js
  12. 1
      app/emoji-custom/server/index.js
  13. 32
      app/emoji-custom/server/publications/fullEmojiData.js
  14. 2
      app/integrations/server/index.js
  15. 20
      app/integrations/server/publications/integrationHistory.js
  16. 23
      app/integrations/server/publications/integrations.js
  17. 18
      app/livechat/server/index.js
  18. 22
      app/livechat/server/publications/customFields.js
  19. 22
      app/livechat/server/publications/departmentAgents.js
  20. 8
      app/livechat/server/publications/externalMessages.js
  21. 34
      app/livechat/server/publications/livechatAgents.js
  22. 59
      app/livechat/server/publications/livechatAppearance.js
  23. 21
      app/livechat/server/publications/livechatDepartments.js
  24. 51
      app/livechat/server/publications/livechatInquiries.js
  25. 35
      app/livechat/server/publications/livechatIntegration.js
  26. 34
      app/livechat/server/publications/livechatManagers.js
  27. 44
      app/livechat/server/publications/livechatMonitoring.js
  28. 13
      app/livechat/server/publications/livechatOfficeHours.js
  29. 34
      app/livechat/server/publications/livechatQueue.js
  30. 108
      app/livechat/server/publications/livechatRooms.js
  31. 20
      app/livechat/server/publications/livechatTriggers.js
  32. 44
      app/livechat/server/publications/livechatVisitors.js
  33. 46
      app/livechat/server/publications/visitorHistory.js
  34. 22
      app/livechat/server/publications/visitorInfo.js
  35. 40
      app/livechat/server/publications/visitorPageVisited.js
  36. 2
      app/logger/server/index.js
  37. 21
      app/logger/server/streamer.js
  38. 1
      app/mentions-flextab/server/index.js
  39. 40
      app/mentions-flextab/server/publications/mentionedMessages.js
  40. 1
      app/message-pin/server/index.js
  41. 34
      app/message-pin/server/publications/pinnedMessages.js
  42. 2
      app/message-snippet/server/index.js
  43. 56
      app/message-snippet/server/publications/snippetedMessage.js
  44. 45
      app/message-snippet/server/publications/snippetedMessagesByRoom.js
  45. 1
      app/message-star/server/index.js
  46. 38
      app/message-star/server/publications/starredMessages.js
  47. 34
      app/meteor-autocomplete/server/autocomplete-server.js
  48. 1
      app/meteor-autocomplete/server/index.js
  49. 15
      app/oauth2-server-config/server/admin/publications/oauthApps.js
  50. 1
      app/oauth2-server-config/server/index.js
  51. 15
      app/oauth2-server-config/server/oauth/oauth2-server.js
  52. 1
      app/ui-admin/server/index.js
  53. 59
      app/ui-admin/server/publications/adminRooms.js
  54. 2
      app/user-status/server/index.js
  55. 31
      app/user-status/server/publications/fullUserStatusData.js
  56. 1
      app/webdav/server/index.js
  57. 19
      app/webdav/server/publications/webdavAccounts.js
  58. 1
      imports/personal-access-tokens/server/index.js
  59. 1
      imports/personal-access-tokens/server/publications/index.js
  60. 39
      imports/personal-access-tokens/server/publications/personalAccessTokens.js
  61. 3
      server/importPackages.js
  62. 8
      server/main.js
  63. 20
      server/publications/activeUsers.js
  64. 45
      server/publications/channelAndPrivateAutocomplete.js
  65. 31
      server/publications/fullUserData.js
  66. 62
      server/publications/messages.js
  67. 8
      server/publications/roomFiles.js
  68. 8
      server/publications/roomFilesWithSearchText.js
  69. 55
      server/publications/userAutocomplete.js
  70. 28
      server/publications/userChannels.js
  71. 23
      server/publications/userData.js

@ -10,7 +10,7 @@ import { settings } from '../../../settings/server';
import { API } from '../api';
import { getDefaultUserFields } from '../../../utils/server/functions/getDefaultUserFields';
import { getURL } from '../../../utils/lib/getURL';
import { StdOut } from '../../../logger/server/publish';
import { StdOut } from '../../../logger/server/streamer';
// DEPRECATED

@ -20,8 +20,7 @@ import './methods/deleteRole';
import './methods/removeRoleFromPermission';
import './methods/removeUserFromRole';
import './methods/saveRole';
import './publications/permissions';
import './publications/roles';
import './streamer/permissions';
import './startup';
export {

@ -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();
});

@ -4,6 +4,7 @@ import { Meteor } from 'meteor/meteor';
import { Roles, Permissions, Settings } from '../../models';
import { settings } from '../../settings/server';
import { getSettingPermissionId, CONSTANTS } from '../lib';
import { clearCache } from './functions/hasPermission';
Meteor.startup(function() {
// Note:
@ -208,4 +209,12 @@ Meteor.startup(function() {
};
settings.onload('*', createPermissionForAddedSetting);
Roles.on('change', ({ diff }) => {
if (diff && Object.keys(diff).length === 1 && diff._updatedAt) {
// avoid useless changes
return;
}
clearCache();
});
});

@ -5,4 +5,3 @@ import './methods/deleteCustomSound';
import './methods/insertOrUpdateSound';
import './methods/listCustomSounds';
import './methods/uploadCustomSound';
import './publications/customSounds';

@ -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);
});

@ -3,8 +3,6 @@ import './authorization';
import './permissions';
import './hooks/propagateDiscussionMetadata';
import './publications/discussionParentAutocomplete';
import './publications/discussionsOfRoom';
// Methods
import './methods/createDiscussion';

@ -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,6 +1,5 @@
import './startup/emoji-custom';
import './startup/settings';
import './publications/fullEmojiData';
import './methods/listEmojiCustom';
import './methods/deleteEmojiCustom';
import './methods/insertOrUpdateEmoji';

@ -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,8 +1,6 @@
import '../lib/rocketchat';
import './logger';
import './lib/validation';
import './publications/integrations';
import './publications/integrationHistory';
import './methods/incoming/addIncomingIntegration';
import './methods/incoming/updateIncomingIntegration';
import './methods/incoming/deleteIncomingIntegration';

@ -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));
});

@ -80,24 +80,6 @@ import './lib/stream/inquiry';
import './lib/stream/queueManager';
import './sendMessageBySMS';
import './unclosedLivechats';
import './publications/customFields';
import './publications/departmentAgents';
import './publications/externalMessages';
import './publications/livechatAgents';
import './publications/livechatAppearance';
import './publications/livechatDepartments';
import './publications/livechatIntegration';
import './publications/livechatManagers';
import './publications/livechatMonitoring';
import './publications/livechatRooms';
import './publications/livechatQueue';
import './publications/livechatTriggers';
import './publications/livechatVisitors';
import './publications/visitorHistory';
import './publications/visitorInfo';
import './publications/visitorPageVisited';
import './publications/livechatInquiries';
import './publications/livechatOfficeHours';
import './api';
import './api/rest';

@ -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,4 +1,4 @@
import './publish.js';
import './streamer.js';
import { LoggerManager, Logger, SystemLogger } from './server';
export {

@ -66,24 +66,3 @@ Meteor.startup(() => {
};
StdOut.on('write', handler);
});
Meteor.publish('stdout', function() {
console.warn('The publication "stdout" is deprecated and will be removed after version v3.0.0');
if (!this.userId || hasPermission(this.userId, 'view-logs') !== true) {
return this.ready();
}
const handler = (string, item) => {
this.added('stdout', item.id, {
string: item.string,
ts: item.ts,
});
};
StdOut.queue.forEach((item) => handler('', item));
this.ready();
this.onStop(() => StdOut.removeListener('write', handler));
StdOut.on('write', handler);
});

@ -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,5 +1,3 @@
import './startup/settings';
import './methods/snippetMessage';
import './requests';
import './publications/snippetedMessagesByRoom';
import './publications/snippetedMessage';

@ -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';

@ -46,21 +46,6 @@ oauth2server.routes.get('/oauth/userinfo', function(req, res) {
});
});
Meteor.publish('oauthClient', function(clientId) {
console.warn('The publication "oauthClient" is deprecated and will be removed after version v3.0.0');
if (!this.userId) {
return this.ready();
}
return OAuthApps.find({
clientId,
active: true,
}, {
fields: {
name: 1,
},
});
});
API.v1.addAuthMethod(function() {
let headerToken = this.request.headers.authorization;
const getToken = this.request.query.access_token;

@ -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);
});

@ -3,5 +3,3 @@ import './methods/insertOrUpdateUserStatus';
import './methods/listCustomUserStatus';
import './methods/setUserStatus';
import './methods/getUserStatusText';
import './publications/fullUserStatusData';

@ -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);
});

@ -4,5 +4,4 @@ import './methods/getWebdavFileList';
import './methods/getWebdavFilePreview';
import './methods/getFileFromWebdav';
import './methods/uploadFileToWebdav';
import './publications/webdavAccounts';
import './startup/settings';

@ -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,2 +1 @@
import './api/methods';
import './publications';

@ -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();
});
});

@ -49,7 +49,6 @@ import '../app/mailer';
import '../app/mapview/server';
import '../app/markdown/server';
import '../app/mentions/server';
import '../app/mentions-flextab/server';
import '../app/message-mark-as-unread/server';
import '../app/message-pin/server';
import '../app/message-snippet/server';
@ -84,7 +83,6 @@ import '../app/spotify/server';
import '../app/theme/server';
import '../app/threads/server';
import '../app/tokenpass/server';
import '../app/ui-admin/server';
import '../app/ui-master/server';
import '../app/ui-vrecord/server';
import '../app/user-data-download';
@ -113,4 +111,3 @@ import '../app/ui-utils';
import '../app/action-links';
import '../app/reactions/server';
import '../app/livechat/server';
import '../app/meteor-autocomplete/server';

@ -65,19 +65,11 @@ import './methods/setUserPassword';
import './methods/toogleFavorite';
import './methods/unmuteUserInRoom';
import './methods/userSetUtcOffset';
import './publications/activeUsers';
import './publications/channelAndPrivateAutocomplete';
import './publications/fullUserData';
import './publications/messages';
import './publications/room';
import './publications/roomFiles';
import './publications/roomFilesWithSearchText';
import './publications/settings';
import './publications/spotlight';
import './publications/subscription';
import './publications/userAutocomplete';
import './publications/userChannels';
import './publications/userData';
import './routes/avatar';
import './stream/messages';
import './stream/rooms';

@ -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,70 +1,8 @@
import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import { normalizeMessagesForUser } from '../../app/utils/server/lib/normalizeMessagesForUser';
import { Messages } from '../../app/models';
Meteor.publish('messages', function(rid/* , start*/) {
console.warn('The publication "messages" is deprecated and will be removed after version v3.0.0');
if (!this.userId) {
return this.ready();
}
const publication = this;
if (typeof rid !== 'string') {
return this.ready();
}
if (!Meteor.call('canAccessRoom', rid, this.userId)) {
return this.ready();
}
const cursor = Messages.findVisibleByRoomId(rid, {
sort: {
ts: -1,
},
limit: 50,
});
const cursorHandle = cursor.observeChanges({
added(_id, record) {
const [message] = normalizeMessagesForUser([record], publication.userId);
return publication.added('rocketchat_message', _id, message);
},
changed(_id, record) {
const [message] = normalizeMessagesForUser([record], publication.userId);
return publication.changed('rocketchat_message', _id, message);
},
});
const cursorDelete = Messages.findInvisibleByRoomId(rid, {
fields: {
_id: 1,
},
});
const cursorDeleteHandle = cursorDelete.observeChanges({
added(_id/* , record*/) {
return publication.added('rocketchat_message', _id, {
_hidden: true,
});
},
changed(_id/* , record*/) {
return publication.added('rocketchat_message', _id, {
_hidden: true,
});
},
});
this.ready();
return this.onStop(function() {
cursorHandle.stop();
return cursorDeleteHandle.stop();
});
});
Meteor.methods({
'messages/get'(rid, { lastUpdate, latestDate = new Date(), oldestDate, inclusive = false, count = 20, unreads = false }) {
check(rid, String);

@ -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…
Cancel
Save