Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
1 change: 0 additions & 1 deletion app/accounts/index.js

This file was deleted.

3 changes: 1 addition & 2 deletions app/action-links/client/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { actionLinks } from '../both/lib/actionLinks';
import './lib/actionLinks';
import { actionLinks } from './lib/actionLinks';
import './init';
import './stylesheets/actionLinks.css';

Expand Down
6 changes: 3 additions & 3 deletions app/action-links/client/init.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Blaze } from 'meteor/blaze';
import { Template } from 'meteor/templating';

import { handleError } from '../../utils';
import { fireGlobalEvent, Layout } from '../../ui-utils';
import { handleError } from '../../utils/client';
import { fireGlobalEvent, Layout } from '../../ui-utils/client';
import { messageArgs } from '../../ui-utils/client/lib/messageArgs';
import { actionLinks } from '../both/lib/actionLinks';
import { actionLinks } from './lib/actionLinks';


Template.room.events({
Expand Down
65 changes: 48 additions & 17 deletions app/action-links/client/lib/actionLinks.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,58 @@
import { Meteor } from 'meteor/meteor';

import { handleError } from '../../../utils';
import { actionLinks } from '../../both/lib/actionLinks';
// Action Links Handler. This method will be called off the client.
import { handleError } from '../../../utils/client';
import { Messages, Subscriptions } from '../../../models/client';

actionLinks.run = (name, messageId, instance) => {
const message = actionLinks.getMessage(name, messageId);
// Action Links namespace creation.
export const actionLinks = {
actions: {},
register(name, funct) {
actionLinks.actions[name] = funct;
},
getMessage(name, messageId) {
const userId = Meteor.userId();
if (!userId) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', { function: 'actionLinks.getMessage' });
}

const message = Messages.findOne({ _id: messageId });
if (!message) {
throw new Meteor.Error('error-invalid-message', 'Invalid message', { function: 'actionLinks.getMessage' });
}

const subscription = Subscriptions.findOne({
rid: message.rid,
'u._id': userId,
});
if (!subscription) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', { function: 'actionLinks.getMessage' });
}

if (!message.actionLinks || !message.actionLinks[name]) {
throw new Meteor.Error('error-invalid-actionlink', 'Invalid action link', { function: 'actionLinks.getMessage' });
}

const actionLink = message.actionLinks[name];
return message;
},
run(name, messageId, instance) {
const message = actionLinks.getMessage(name, messageId);

let ranClient = false;
const actionLink = message.actionLinks[name];

if (actionLinks && actionLinks.actions && actionLinks.actions[actionLink.method_id]) {
// run just on client side
actionLinks.actions[actionLink.method_id](message, actionLink.params, instance);
let ranClient = false;

ranClient = true;
}
if (actionLinks && actionLinks.actions && actionLinks.actions[actionLink.method_id]) {
// run just on client side
actionLinks.actions[actionLink.method_id](message, actionLink.params, instance);

// and run on server side
Meteor.call('actionLinkHandler', name, messageId, (err) => {
if (err && !ranClient) {
handleError(err);
ranClient = true;
}
});

// and run on server side
Meteor.call('actionLinkHandler', name, messageId, (err) => {
if (err && !ranClient) {
handleError(err);
}
});
},
};
8 changes: 0 additions & 8 deletions app/action-links/index.js

This file was deleted.

2 changes: 1 addition & 1 deletion app/action-links/server/actionLinkHandler.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Meteor } from 'meteor/meteor';

import { actionLinks } from '../both/lib/actionLinks';
import { actionLinks } from './lib/actionLinks';
// Action Links Handler. This method will be called off the client.

Meteor.methods({
Expand Down
2 changes: 1 addition & 1 deletion app/action-links/server/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { actionLinks } from '../both/lib/actionLinks';
import { actionLinks } from './lib/actionLinks';
import './actionLinkHandler';

export {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Meteor } from 'meteor/meteor';

import { Messages, Subscriptions } from '../../../models';
import { Messages, Subscriptions } from '../../../models/server';

// Action Links namespace creation.
export const actionLinks = {
Expand Down
2 changes: 1 addition & 1 deletion app/api/server/v1/assets.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Meteor } from 'meteor/meteor';
import Busboy from 'busboy';

import { RocketChatAssets } from '../../../assets';
import { RocketChatAssets } from '../../../assets/server';
import { API } from '../api';

API.v1.addRoute('assets.setAsset', { authRequired: true }, {
Expand Down
1 change: 0 additions & 1 deletion app/assets/index.js

This file was deleted.

2 changes: 1 addition & 1 deletion app/blockstack/server/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Meteor } from 'meteor/meteor';
import { WebApp } from 'meteor/webapp';

import { settings } from '../../settings';
import { RocketChatAssets } from '../../assets';
import { RocketChatAssets } from '../../assets/server';

WebApp.connectHandlers.use('/_blockstack/manifest', Meteor.bindEnvironment(function(req, res) {
const name = settings.get('Site_Name');
Expand Down
1 change: 1 addition & 0 deletions app/livechat/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ import './stylesheets/livechat.css';
import './views/sideNav/livechat';
import './views/sideNav/livechatFlex';
import './externalFrame';
import './lib/messageTypes';
5 changes: 5 additions & 0 deletions app/livechat/client/lib/messageTypes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { actionLinks } from '../../../action-links/client';

actionLinks.register('createLivechatCall', function(message, params, instance) {
instance.tabBar.open('video');
});
32 changes: 0 additions & 32 deletions app/livechat/lib/messageTypes.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import { Meteor } from 'meteor/meteor';
import { TAPi18n } from 'meteor/rocketchat:tap-i18n';
import { Livechat } from 'meteor/rocketchat:livechat';

import { MessageTypes } from '../../ui-utils';
import { actionLinks } from '../../action-links';
import { Notifications } from '../../notifications';
import { Messages, LivechatRooms } from '../../models';
import { settings } from '../../settings';

MessageTypes.registerType({
id: 'livechat_navigation_history',
Expand Down Expand Up @@ -60,29 +54,3 @@ MessageTypes.registerType({
system: true,
message: 'New_videocall_request',
});

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

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

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

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

Livechat.closeRoom({
user,
room: LivechatRooms.findOneById(message.rid),
comment: TAPi18n.__('Videocall_declined', { lng: language }),
});
Meteor.defer(() => {
Messages.setHiddenById(message._id);
});
}
});
1 change: 1 addition & 0 deletions app/livechat/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,6 @@ import './sendMessageBySMS';
import './api';
import './api/rest';
import './externalFrame';
import './lib/messageTypes';

export { Livechat } from './lib/Livechat';
26 changes: 26 additions & 0 deletions app/livechat/server/lib/messageTypes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Meteor } from 'meteor/meteor';
import { TAPi18n } from 'meteor/rocketchat:tap-i18n';

import { actionLinks } from '../../../action-links/server';
import { Notifications } from '../../../notifications/server';
import { Messages, LivechatRooms } from '../../../models/server';
import { settings } from '../../../settings/server';
import { Livechat } from './Livechat';

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

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

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

Livechat.closeRoom({
user,
room: LivechatRooms.findOneById(message.rid),
comment: TAPi18n.__('Videocall_declined', { lng: language }),
});
Meteor.defer(() => {
Messages.setHiddenById(message._id);
});
});
2 changes: 1 addition & 1 deletion app/videobridge/client/actionLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Session } from 'meteor/session';
import { TAPi18n } from 'meteor/rocketchat:tap-i18n';
import toastr from 'toastr';

import { actionLinks } from '../../action-links';
import { actionLinks } from '../../action-links/client';
import { Rooms } from '../../models';

actionLinks.register('joinJitsiCall', function(message, params, instance) {
Expand Down
2 changes: 1 addition & 1 deletion app/videobridge/server/actionLink.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { actionLinks } from '../../action-links';
import { actionLinks } from '../../action-links/server';

actionLinks.register('joinJitsiCall', function(/* message, params*/) {

Expand Down
2 changes: 1 addition & 1 deletion client/importPackages.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ import '../app/notifications';
import '../app/promises/client';
import '../app/ui-utils';
import '../app/ui-cached-collection';
import '../app/action-links';
import '../app/action-links/client';
import '../app/reactions/client';
import '../app/livechat/client';
import '../app/meteor-autocomplete/client';
Expand Down
6 changes: 3 additions & 3 deletions server/importPackages.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import '../app/cors/server';
import '../app/sms';
import '../app/2fa/server';
import '../app/accounts';
import '../app/accounts/server';
import '../app/analytics/server';
import '../app/api';
import '../app/assets';
import '../app/assets/server';
import '../app/authorization';
import '../app/autolinker/server';
import '../app/autotranslate/server';
Expand Down Expand Up @@ -109,6 +109,6 @@ import '../app/callbacks';
import '../app/notifications';
import '../app/promises/server';
import '../app/ui-utils';
import '../app/action-links';
import '../app/action-links/server';
import '../app/reactions/server';
import '../app/livechat/server';
2 changes: 1 addition & 1 deletion server/startup/migrations/v036.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { HTTP } from 'meteor/http';

import { Migrations } from '../../../app/migrations';
import { Settings } from '../../../app/models';
import { RocketChatAssets } from '../../../app/assets';
import { RocketChatAssets } from '../../../app/assets/server';

Migrations.add({
version: 36,
Expand Down
2 changes: 1 addition & 1 deletion server/startup/migrations/v042.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Mongo } from 'meteor/mongo';

import { Migrations } from '../../../app/migrations';
import { settings } from '../../../app/settings';
import { RocketChatAssets } from '../../../app/assets';
import { RocketChatAssets } from '../../../app/assets/server';

Migrations.add({
version: 42,
Expand Down