Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dependency of RC namespace in rc-emoji-custom and drupal #13256

Merged
merged 84 commits into from
Jan 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
6f749bc
Move integrations models to rc-models
MarcosSpessatto Jan 21, 2019
5dec8ce
Move composeMessage function to rc-utils
MarcosSpessatto Jan 21, 2019
583cb87
Move PushNotifications class to push-notifications package
MarcosSpessatto Jan 21, 2019
039e7cd
Import variables to remove dependency of RC namespace
MarcosSpessatto Jan 21, 2019
d49540b
Import variables to remove RC namespace dependency inside rc-lib/serv…
MarcosSpessatto Jan 22, 2019
4cede2e
Import variables to remove RC namespace inside rc-lib/server/methods
MarcosSpessatto Jan 22, 2019
5ecc7b8
Import variables to remove dependency with RC namespace
MarcosSpessatto Jan 22, 2019
f3280a6
Remove duplicated server settings located in rc-lib
MarcosSpessatto Jan 22, 2019
f526680
Merge remote-tracking branch 'origin/depackaging' into globals/rc-lib…
rodrigok Jan 22, 2019
8d4c70f
Merge branch 'globals/rc-lib-wave-5' into globals/rc-lib-wave-6
MarcosSpessatto Jan 22, 2019
fb7666d
Merge branch 'globals/rc-lib-wave-6' into globals/lib-settings
MarcosSpessatto Jan 22, 2019
f457877
Export function and lib function of rc-lib but keep it inside RC name…
MarcosSpessatto Jan 22, 2019
3b6ffa6
Import variables from functions and lib to remove RC namespace depend…
MarcosSpessatto Jan 22, 2019
27043cb
Merge remote-tracking branch 'origin/depackaging' into globals/lib-fu…
rodrigok Jan 22, 2019
6ab7f28
Remove dependency of RC namespace in rc-sandstorm
MarcosSpessatto Jan 22, 2019
f00a322
Merge branch 'globals/lib-functions' into globals/lib-functions-import
MarcosSpessatto Jan 22, 2019
6043a3d
Merge branch 'globals/lib-functions-import' into globals/lib-x-sandstorm
MarcosSpessatto Jan 22, 2019
568ed1f
Remove dependency of RC namespace in chatpal-search
MarcosSpessatto Jan 23, 2019
36c17f2
Merge remote-tracking branch 'origin/depackaging' into globals/lib-fu…
rodrigok Jan 23, 2019
08d8bd1
Merge remote-tracking branch 'origin/globals/lib-functions-import' in…
rodrigok Jan 23, 2019
06a780f
Merge remote-tracking branch 'origin/depackaging' into globals/lib-x-…
rodrigok Jan 23, 2019
5d60447
Move CreadentialTokens model to rc-models
MarcosSpessatto Jan 23, 2019
dd9303f
Move getUsernameSuggestion function and method from server/ to rc-lib
MarcosSpessatto Jan 23, 2019
842a519
Remove dependency of RC namespace in meteor saml
MarcosSpessatto Jan 23, 2019
76b17c8
Merge branch 'globals/lib-x-sandstorm' into globals/lib-x-chatpal-search
rodrigok Jan 23, 2019
9645e02
Merge remote-tracking branch 'origin/depackaging' into globals/lib-x-…
rodrigok Jan 23, 2019
ba81c02
Remove dependency of RC namespace in rc-theme
MarcosSpessatto Jan 23, 2019
c32491e
Merge branch 'globals/lib-x-chatpal-search' into globals/rc-x-saml
rodrigok Jan 23, 2019
df3c3f8
Merge remote-tracking branch 'origin/depackaging' into globals/rc-x-saml
rodrigok Jan 23, 2019
1290be4
Move 2FA Users model to rc-models
MarcosSpessatto Jan 23, 2019
25b121e
Remove dependency of RC namespace in rc-2fa
MarcosSpessatto Jan 23, 2019
9a4ee66
Merge branch 'globals/rc-x-saml' into globals/rc-x-theme
MarcosSpessatto Jan 23, 2019
41de984
Merge branch 'globals/rc-x-theme' into globals/rc-x-2fa
MarcosSpessatto Jan 23, 2019
025eb99
Merge remote-tracking branch 'origin/depackaging' into globals/rc-x-t…
rodrigok Jan 23, 2019
a7bf7a9
Remove dependency of RC namespace in rc-action-links
MarcosSpessatto Jan 23, 2019
eff1176
Add action links in the RC namespace
MarcosSpessatto Jan 23, 2019
2503f08
Remove dependency of RC namespace in rc-analytics
MarcosSpessatto Jan 23, 2019
0c95868
Remove dependency of RC namespace in rc-assets
MarcosSpessatto Jan 23, 2019
2174cee
Add Assets in RC namespace
MarcosSpessatto Jan 23, 2019
e0cf4d6
Remove dependency of RC namespace in rc-autolinker
MarcosSpessatto Jan 23, 2019
fb28dea
Move autotranslate models to rc-models
MarcosSpessatto Jan 23, 2019
83c3373
Partial remove dependency of Rc namespace in rc-autotranslate
MarcosSpessatto Jan 23, 2019
e687a9b
Remove dependency of RC namespace in rc-markdown
MarcosSpessatto Jan 23, 2019
fe90277
Finish of remotion of RC namespace in rc-autotranslate
MarcosSpessatto Jan 23, 2019
05e7858
Import Autotranslate where it has been used
MarcosSpessatto Jan 23, 2019
f052849
Merge branch 'globals/rc-x-theme' into globals/rc-x-2fa
rodrigok Jan 23, 2019
d8bcac7
Merge remote-tracking branch 'origin/depackaging' into globals/rc-x-2fa
rodrigok Jan 23, 2019
4ec3a96
Fix lint
MarcosSpessatto Jan 23, 2019
5e4dfa8
Merge branch 'globals/rc-x-2fa' into globals/rc-x-action-links
rodrigok Jan 23, 2019
49b0372
Merge remote-tracking branch 'origin/depackaging' into globals/rc-x-a…
rodrigok Jan 23, 2019
ac592ae
Rename Assets variable to avoid conflicts
MarcosSpessatto Jan 23, 2019
9ea47dd
Merge branch 'globals/rc-x-action-links' into globals/lib-x-analytics…
rodrigok Jan 23, 2019
c16e5d9
Merge remote-tracking branch 'origin/depackaging' into globals/lib-x-…
rodrigok Jan 23, 2019
23922e5
Fix rename Assets
MarcosSpessatto Jan 24, 2019
b8f6905
Merge branch 'globals/lib-x-analytics-assets' into globals/lib-x-auto…
MarcosSpessatto Jan 24, 2019
9575227
Remove dependency of RC namespace in rc-blockstack
MarcosSpessatto Jan 24, 2019
85d0c1d
Remove RC dependency in bot-helpers
MarcosSpessatto Jan 24, 2019
4a3ebd6
Remove RC dependency in rc-cas
MarcosSpessatto Jan 24, 2019
13d553c
Move some functions from tokenpass to channel settings and models
MarcosSpessatto Jan 24, 2019
ffcd36d
Merge remote-tracking branch 'origin/depackaging' into globals/lib-x-…
rodrigok Jan 24, 2019
9706011
Move some function from livestream to channel settings
MarcosSpessatto Jan 24, 2019
b8cc8bc
Remove dependency of RC namespace in rc-channel-settings
MarcosSpessatto Jan 24, 2019
5d3d0a5
Fix wrong imports
MarcosSpessatto Jan 24, 2019
2bbe5d8
Merge remote-tracking branch 'origin/globals/lib-x-autolinker-autotra…
MarcosSpessatto Jan 24, 2019
467ad3f
Merge branch 'globals/lib-x-autolinker-autotranslate' into globals/li…
MarcosSpessatto Jan 24, 2019
70d599c
Merge branch 'globals/lib-x-blockstack-cas-bot-helpers' into globals/…
MarcosSpessatto Jan 24, 2019
5d90f9b
Merge remote-tracking branch 'origin/depackaging' into globals/lib-x-…
rodrigok Jan 24, 2019
2d6ca42
Merge branch 'globals/lib-x-blockstack-cas-bot-helpers' into globals/…
rodrigok Jan 24, 2019
a2043f4
Merge remote-tracking branch 'origin/depackaging' into globals/rc-x-c…
rodrigok Jan 24, 2019
cc5ec5c
Remove dependency of RC namespace in rc-channel-mail-messages
MarcosSpessatto Jan 24, 2019
d912d2e
Remove dependency of RC namespace in rc-cloud
MarcosSpessatto Jan 24, 2019
265bf82
Remove dependency of RC namespace in rc-colors
MarcosSpessatto Jan 24, 2019
0f9cf3d
Remove dependency of RC namespace in rc-cors
MarcosSpessatto Jan 24, 2019
f418bd3
Remove dependency of RC namespace in rc-crowd
MarcosSpessatto Jan 24, 2019
f2ed727
Remove dependency of RC namespace in rc-dolphin
MarcosSpessatto Jan 24, 2019
62e7758
Remove dependency of RC namespace in rc-drupal
MarcosSpessatto Jan 24, 2019
96ebaf1
Move Emoji custom server and client models to rc-models
MarcosSpessatto Jan 24, 2019
80e2326
Remove dependency of RC namespace in rc-emoji-custom
MarcosSpessatto Jan 24, 2019
abf4d39
Merge remote-tracking branch 'origin/depackaging' into globals/lib-x-…
rodrigok Jan 24, 2019
34f5915
Merge branch 'globals/lib-x-channel-mail-messages-cloud' into globals…
rodrigok Jan 24, 2019
b03ed46
Merge branch 'globals/colors-cors-crowd-dolphin' into globals/drupal-…
rodrigok Jan 24, 2019
b70e7ef
Merge remote-tracking branch 'origin/depackaging' into globals/colors…
rodrigok Jan 24, 2019
d03bf74
Merge branch 'globals/colors-cors-crowd-dolphin' into globals/drupal-…
rodrigok Jan 24, 2019
bf7db44
Merge remote-tracking branch 'origin/depackaging' into globals/drupal…
rodrigok Jan 24, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/rocketchat-drupal/lib/common.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
import { RocketChat } from 'meteor/rocketchat:lib';
import { settings } from 'meteor/rocketchat:settings';
import { CustomOAuth } from 'meteor/rocketchat:custom-oauth';

// Drupal Server CallBack URL needs to be http(s)://{rocketchat.server}[:port]/_oauth/drupal
Expand All @@ -25,16 +25,16 @@ const Drupal = new CustomOAuth('drupal', config);

if (Meteor.isServer) {
Meteor.startup(function() {
RocketChat.settings.get('API_Drupal_URL', function(key, value) {
settings.get('API_Drupal_URL', function(key, value) {
config.serverURL = value;
Drupal.configure(config);
});
});
} else {
Meteor.startup(function() {
Tracker.autorun(function() {
if (RocketChat.settings.get('API_Drupal_URL')) {
config.serverURL = RocketChat.settings.get('API_Drupal_URL');
if (settings.get('API_Drupal_URL')) {
config.serverURL = settings.get('API_Drupal_URL');
Drupal.configure(config);
}
});
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-drupal/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Package.onUse(function(api) {
api.use([
'ecmascript',
'service-configuration',
'rocketchat:lib@0.0.1',
'rocketchat:settings',
'rocketchat:custom-oauth',
'templating',
]);
Expand Down
4 changes: 2 additions & 2 deletions packages/rocketchat-drupal/server/startup.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { RocketChat } from 'meteor/rocketchat:lib';
import { settings } from 'meteor/rocketchat:settings';

RocketChat.settings.addGroup('OAuth', function() {
settings.addGroup('OAuth', function() {
this.section('Drupal', function() {
const enableQuery = {
_id: 'Accounts_OAuth_Drupal',
Expand Down
12 changes: 6 additions & 6 deletions packages/rocketchat-emoji-custom/client/admin/adminEmoji.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ReactiveVar } from 'meteor/reactive-var';
import { RocketChat, RocketChatTabBar } from 'meteor/rocketchat:lib';
import { RocketChatTabBar, SideNav, TabBar } from 'meteor/rocketchat:ui-utils';
import { Tracker } from 'meteor/tracker';
import { EmojiCustom } from 'meteor/rocketchat:models';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { Template } from 'meteor/templating';
import { SideNav } from 'meteor/rocketchat:ui';
import s from 'underscore.string';

Template.adminEmoji.helpers({
Expand Down Expand Up @@ -49,7 +49,7 @@ Template.adminEmoji.onCreated(function() {
this.tabBar.showGroup(FlowRouter.current().route.name);
this.tabBarData = new ReactiveVar();

RocketChat.TabBar.addButton({
TabBar.addButton({
groups: ['emoji-custom'],
id: 'add-emoji',
i18nTitle: 'Custom_Emoji_Add',
Expand All @@ -58,7 +58,7 @@ Template.adminEmoji.onCreated(function() {
order: 1,
});

RocketChat.TabBar.addButton({
TabBar.addButton({
groups: ['emoji-custom'],
id: 'admin-emoji-info',
i18nTitle: 'Custom_Emoji_Info',
Expand All @@ -85,7 +85,7 @@ Template.adminEmoji.onCreated(function() {

const limit = (instance.limit != null) ? instance.limit.get() : 0;

return RocketChat.models.EmojiCustom.find(query, { limit, sort: { name: 1 } }).fetch();
return EmojiCustom.find(query, { limit, sort: { name: 1 } }).fetch();
};
});

Expand Down Expand Up @@ -113,7 +113,7 @@ Template.adminEmoji.events({

'click .emoji-info'(e, instance) {
e.preventDefault();
instance.tabBarData.set(RocketChat.models.EmojiCustom.findOne({ _id: this._id }));
instance.tabBarData.set(EmojiCustom.findOne({ _id: this._id }));
instance.tabBar.open('admin-emoji-info');
},

Expand Down
3 changes: 1 addition & 2 deletions packages/rocketchat-emoji-custom/client/admin/emojiEdit.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Meteor } from 'meteor/meteor';
import { Template } from 'meteor/templating';
import { TAPi18n } from 'meteor/tap:i18n';
import { handleError } from 'meteor/rocketchat:lib';
import { t } from 'meteor/rocketchat:utils';
import { t, handleError } from 'meteor/rocketchat:utils';
import toastr from 'toastr';
import s from 'underscore.string';

Expand Down
5 changes: 2 additions & 3 deletions packages/rocketchat-emoji-custom/client/admin/emojiInfo.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import { Template } from 'meteor/templating';
import { handleError } from 'meteor/rocketchat:lib';
import { modal } from 'meteor/rocketchat:ui';
import { t } from 'meteor/rocketchat:utils';
import { handleError, t } from 'meteor/rocketchat:utils';
import { modal } from 'meteor/rocketchat:ui-utils';

Template.emojiInfo.helpers({
name() {
Expand Down
7 changes: 4 additions & 3 deletions packages/rocketchat-emoji-custom/client/admin/startup.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { RocketChat } from 'meteor/rocketchat:lib';
import { AdminBox } from 'meteor/rocketchat:ui-utils';
import { hasPermission } from 'meteor/rocketchat:authorization';

RocketChat.AdminBox.addOption({
AdminBox.addOption({
href: 'emoji-custom',
i18nLabel: 'Custom_Emoji',
icon: 'emoji',
permissionGranted() {
return RocketChat.authz.hasPermission('manage-emoji');
return hasPermission('manage-emoji');
},
});
1 change: 0 additions & 1 deletion packages/rocketchat-emoji-custom/client/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import './models/EmojiCustom';
import './lib/emojiCustom';
import './notifications/deleteEmojiCustom';
import './notifications/updateEmojiCustom';
Expand Down
93 changes: 47 additions & 46 deletions packages/rocketchat-emoji-custom/client/lib/emojiCustom.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Meteor } from 'meteor/meteor';
import { Blaze } from 'meteor/blaze';
import { Session } from 'meteor/session';
import { RocketChat } from 'meteor/rocketchat:lib';
import { isSetNotNull } from '../lib/function-isSet';
import { RoomManager } from 'meteor/rocketchat:ui';
import { RoomManager } from 'meteor/rocketchat:ui-utils';
import { emoji, EmojiPicker } from 'meteor/rocketchat:emoji';
import { CachedCollectionManager } from 'meteor/rocketchat:ui-cached-collection';

export const getEmojiUrlFromName = function(name, extension) {
Session.get;
Expand All @@ -25,25 +26,25 @@ export const getEmojiUrlFromName = function(name, extension) {
Blaze.registerHelper('emojiUrlFromName', getEmojiUrlFromName);

export const deleteEmojiCustom = function(emojiData) {
delete RocketChat.emoji.list[`:${ emojiData.name }:`];
const arrayIndex = RocketChat.emoji.packages.emojiCustom.emojisByCategory.rocket.indexOf(emojiData.name);
delete emoji.list[`:${ emojiData.name }:`];
const arrayIndex = emoji.packages.emojiCustom.emojisByCategory.rocket.indexOf(emojiData.name);
if (arrayIndex !== -1) {
RocketChat.emoji.packages.emojiCustom.emojisByCategory.rocket.splice(arrayIndex, 1);
emoji.packages.emojiCustom.emojisByCategory.rocket.splice(arrayIndex, 1);
}
const arrayIndexList = RocketChat.emoji.packages.emojiCustom.list.indexOf(`:${ emojiData.name }:`);
const arrayIndexList = emoji.packages.emojiCustom.list.indexOf(`:${ emojiData.name }:`);
if (arrayIndexList !== -1) {
RocketChat.emoji.packages.emojiCustom.list.splice(arrayIndexList, 1);
emoji.packages.emojiCustom.list.splice(arrayIndexList, 1);
}
if (isSetNotNull(() => emojiData.aliases)) {
for (const alias of emojiData.aliases) {
delete RocketChat.emoji.list[`:${ alias }:`];
const aliasIndex = RocketChat.emoji.packages.emojiCustom.list.indexOf(`:${ alias }:`);
delete emoji.list[`:${ alias }:`];
const aliasIndex = emoji.packages.emojiCustom.list.indexOf(`:${ alias }:`);
if (aliasIndex !== -1) {
RocketChat.emoji.packages.emojiCustom.list.splice(aliasIndex, 1);
emoji.packages.emojiCustom.list.splice(aliasIndex, 1);
}
}
}
RocketChat.EmojiPicker.updateRecent();
EmojiPicker.updateRecent();
};

export const updateEmojiCustom = function(emojiData) {
Expand All @@ -53,40 +54,40 @@ export const updateEmojiCustom = function(emojiData) {
const previousExists = isSetNotNull(() => emojiData.previousName);
const currentAliases = isSetNotNull(() => emojiData.aliases);

if (previousExists && isSetNotNull(() => RocketChat.emoji.list[`:${ emojiData.previousName }:`].aliases)) {
for (const alias of RocketChat.emoji.list[`:${ emojiData.previousName }:`].aliases) {
delete RocketChat.emoji.list[`:${ alias }:`];
const aliasIndex = RocketChat.emoji.packages.emojiCustom.list.indexOf(`:${ alias }:`);
if (previousExists && isSetNotNull(() => emoji.list[`:${ emojiData.previousName }:`].aliases)) {
for (const alias of emoji.list[`:${ emojiData.previousName }:`].aliases) {
delete emoji.list[`:${ alias }:`];
const aliasIndex = emoji.packages.emojiCustom.list.indexOf(`:${ alias }:`);
if (aliasIndex !== -1) {
RocketChat.emoji.packages.emojiCustom.list.splice(aliasIndex, 1);
emoji.packages.emojiCustom.list.splice(aliasIndex, 1);
}
}
}

if (previousExists && emojiData.name !== emojiData.previousName) {
const arrayIndex = RocketChat.emoji.packages.emojiCustom.emojisByCategory.rocket.indexOf(emojiData.previousName);
const arrayIndex = emoji.packages.emojiCustom.emojisByCategory.rocket.indexOf(emojiData.previousName);
if (arrayIndex !== -1) {
RocketChat.emoji.packages.emojiCustom.emojisByCategory.rocket.splice(arrayIndex, 1);
emoji.packages.emojiCustom.emojisByCategory.rocket.splice(arrayIndex, 1);
}
const arrayIndexList = RocketChat.emoji.packages.emojiCustom.list.indexOf(`:${ emojiData.previousName }:`);
const arrayIndexList = emoji.packages.emojiCustom.list.indexOf(`:${ emojiData.previousName }:`);
if (arrayIndexList !== -1) {
RocketChat.emoji.packages.emojiCustom.list.splice(arrayIndexList, 1);
emoji.packages.emojiCustom.list.splice(arrayIndexList, 1);
}
delete RocketChat.emoji.list[`:${ emojiData.previousName }:`];
delete emoji.list[`:${ emojiData.previousName }:`];
}

const categoryIndex = RocketChat.emoji.packages.emojiCustom.emojisByCategory.rocket.indexOf(`${ emojiData.name }`);
const categoryIndex = emoji.packages.emojiCustom.emojisByCategory.rocket.indexOf(`${ emojiData.name }`);
if (categoryIndex === -1) {
RocketChat.emoji.packages.emojiCustom.emojisByCategory.rocket.push(`${ emojiData.name }`);
RocketChat.emoji.packages.emojiCustom.list.push(`:${ emojiData.name }:`);
emoji.packages.emojiCustom.emojisByCategory.rocket.push(`${ emojiData.name }`);
emoji.packages.emojiCustom.list.push(`:${ emojiData.name }:`);
}
RocketChat.emoji.list[`:${ emojiData.name }:`] = Object.assign({ emojiPackage: 'emojiCustom' }, RocketChat.emoji.list[`:${ emojiData.name }:`], emojiData);
emoji.list[`:${ emojiData.name }:`] = Object.assign({ emojiPackage: 'emojiCustom' }, emoji.list[`:${ emojiData.name }:`], emojiData);
if (currentAliases) {
for (const alias of emojiData.aliases) {
RocketChat.emoji.packages.emojiCustom.list.push(`:${ alias }:`);
RocketChat.emoji.list[`:${ alias }:`] = {};
RocketChat.emoji.list[`:${ alias }:`].emojiPackage = 'emojiCustom';
RocketChat.emoji.list[`:${ alias }:`].aliasOf = emojiData.name;
emoji.packages.emojiCustom.list.push(`:${ alias }:`);
emoji.list[`:${ alias }:`] = {};
emoji.list[`:${ alias }:`].emojiPackage = 'emojiCustom';
emoji.list[`:${ alias }:`].aliasOf = emojiData.name;
}
}

Expand Down Expand Up @@ -119,30 +120,30 @@ export const updateEmojiCustom = function(emojiData) {
}
}

RocketChat.EmojiPicker.updateRecent();
EmojiPicker.updateRecent();
};

RocketChat.emoji.packages.emojiCustom = {
emoji.packages.emojiCustom = {
emojiCategories: { rocket: 'Custom' },
toneList: {},
list: [],

render(html) {
const regShortNames = new RegExp(`<object[^>]*>.*?<\/object>|<span[^>]*>.*?<\/span>|<(?:object|embed|svg|img|div|span|p|a)[^>]*>|(${ RocketChat.emoji.packages.emojiCustom.list.join('|') })`, 'gi');
const regShortNames = new RegExp(`<object[^>]*>.*?<\/object>|<span[^>]*>.*?<\/span>|<(?:object|embed|svg|img|div|span|p|a)[^>]*>|(${ emoji.packages.emojiCustom.list.join('|') })`, 'gi');

// replace regular shortnames first
html = html.replace(regShortNames, function(shortname) {
// console.log('shortname (preif) ->', shortname, html);
if ((typeof shortname === 'undefined') || (shortname === '') || (RocketChat.emoji.packages.emojiCustom.list.indexOf(shortname) === -1)) {
if ((typeof shortname === 'undefined') || (shortname === '') || (emoji.packages.emojiCustom.list.indexOf(shortname) === -1)) {
// if the shortname doesnt exist just return the entire match
return shortname;
} else {
let emojiAlias = shortname.replace(/:/g, '');

let dataCheck = RocketChat.emoji.list[shortname];
let dataCheck = emoji.list[shortname];
if (dataCheck.hasOwnProperty('aliasOf')) {
emojiAlias = dataCheck.aliasOf;
dataCheck = RocketChat.emoji.list[`:${ emojiAlias }:`];
dataCheck = emoji.list[`:${ emojiAlias }:`];
}

return `<span class="emoji" style="background-image:url(${ getEmojiUrlFromName(emojiAlias, dataCheck.extension) });" data-emoji="${ emojiAlias }" title="${ shortname }">${ shortname }</span>`;
Expand All @@ -154,19 +155,19 @@ RocketChat.emoji.packages.emojiCustom = {
};

Meteor.startup(() =>
RocketChat.CachedCollectionManager.onLogin(() => {
CachedCollectionManager.onLogin(() => {
Meteor.call('listEmojiCustom', (error, result) => {
RocketChat.emoji.packages.emojiCustom.emojisByCategory = { rocket: [] };
for (const emoji of result) {
RocketChat.emoji.packages.emojiCustom.emojisByCategory.rocket.push(emoji.name);
RocketChat.emoji.packages.emojiCustom.list.push(`:${ emoji.name }:`);
RocketChat.emoji.list[`:${ emoji.name }:`] = emoji;
RocketChat.emoji.list[`:${ emoji.name }:`].emojiPackage = 'emojiCustom';
for (const alias of emoji.aliases) {
RocketChat.emoji.packages.emojiCustom.list.push(`:${ alias }:`);
RocketChat.emoji.list[`:${ alias }:`] = {
emoji.packages.emojiCustom.emojisByCategory = { rocket: [] };
for (const currentEmoji of result) {
emoji.packages.emojiCustom.emojisByCategory.rocket.push(currentEmoji.name);
emoji.packages.emojiCustom.list.push(`:${ currentEmoji.name }:`);
emoji.list[`:${ currentEmoji.name }:`] = currentEmoji;
emoji.list[`:${ currentEmoji.name }:`].emojiPackage = 'emojiCustom';
for (const alias of currentEmoji.aliases) {
emoji.packages.emojiCustom.list.push(`:${ alias }:`);
emoji.list[`:${ alias }:`] = {
emojiPackage: 'emojiCustom',
aliasOf: emoji.name,
aliasOf: currentEmoji.name,
};
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Meteor } from 'meteor/meteor';
import { RocketChat } from 'meteor/rocketchat:lib';
import { Notifications } from 'meteor/rocketchat:notifications';
import { deleteEmojiCustom } from '../lib/emojiCustom';

Meteor.startup(() =>
RocketChat.Notifications.onLogged('deleteEmojiCustom', (data) => deleteEmojiCustom(data.emojiData))
Notifications.onLogged('deleteEmojiCustom', (data) => deleteEmojiCustom(data.emojiData))
);
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Meteor } from 'meteor/meteor';
import { RocketChat } from 'meteor/rocketchat:lib';
import { Notifications } from 'meteor/rocketchat:notifications';
import { updateEmojiCustom } from '../lib/emojiCustom';

Meteor.startup(() =>
RocketChat.Notifications.onLogged('updateEmojiCustom', (data) => updateEmojiCustom(data.emojiData))
Notifications.onLogged('updateEmojiCustom', (data) => updateEmojiCustom(data.emojiData))
);
7 changes: 6 additions & 1 deletion packages/rocketchat-emoji-custom/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ Package.onUse(function(api) {
'ecmascript',
'rocketchat:emoji',
'rocketchat:file',
'rocketchat:lib',
'rocketchat:utils',
'rocketchat:models',
'rocketchat:settings',
'rocketchat:authorization',
'rocketchat:notifications',
'rocketchat:ui-cached-collection',
'rocketchat:ui-utils',
'templating',
'webapp',
'kadira:flow-router',
Expand Down
1 change: 0 additions & 1 deletion packages/rocketchat-emoji-custom/server/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import './startup/emoji-custom';
import './startup/settings';
import './models/EmojiCustom';
import './publications/fullEmojiData';
import './methods/listEmojiCustom';
import './methods/deleteEmojiCustom';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { Meteor } from 'meteor/meteor';
import { RocketChat } from 'meteor/rocketchat:lib';
import { hasPermission } from 'meteor/rocketchat:authorization';
import { EmojiCustom } from 'meteor/rocketchat:models';
import { Notifications } from 'meteor/rocketchat:notifications';
import { RocketChatFileEmojiCustomInstance } from '../startup/emoji-custom';

Meteor.methods({
deleteEmojiCustom(emojiID) {
let emoji = null;

if (RocketChat.authz.hasPermission(this.userId, 'manage-emoji')) {
emoji = RocketChat.models.EmojiCustom.findOneByID(emojiID);
if (hasPermission(this.userId, 'manage-emoji')) {
emoji = EmojiCustom.findOneByID(emojiID);
} else {
throw new Meteor.Error('not_authorized');
}
Expand All @@ -17,8 +19,8 @@ Meteor.methods({
}

RocketChatFileEmojiCustomInstance.deleteFile(encodeURIComponent(`${ emoji.name }.${ emoji.extension }`));
RocketChat.models.EmojiCustom.removeByID(emojiID);
RocketChat.Notifications.notifyLogged('deleteEmojiCustom', { emojiData: emoji });
EmojiCustom.removeByID(emojiID);
Notifications.notifyLogged('deleteEmojiCustom', { emojiData: emoji });

return true;
},
Expand Down
Loading