Skip to content

Commit

Permalink
[IMPROVE] Remove index files from action-links, accounts and assets (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcosSpessatto authored May 21, 2020
1 parent cb46fb3 commit 6ed0e44
Show file tree
Hide file tree
Showing 66 changed files with 143 additions and 124 deletions.
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
1 change: 0 additions & 1 deletion app/api/index.js

This file was deleted.

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.

1 change: 0 additions & 1 deletion app/bigbluebutton/index.js

This file was deleted.

1 change: 1 addition & 0 deletions app/bigbluebutton/server/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './bigbluebutton-api';
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: 0 additions & 1 deletion app/bot-helpers/index.js

This file was deleted.

2 changes: 1 addition & 1 deletion app/integrations/server/api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import moment from 'moment';

import { logger } from '../logger';
import { processWebhookMessage } from '../../../lib';
import { API, APIClass, defaultRateLimiterOptions } from '../../../api';
import { API, APIClass, defaultRateLimiterOptions } from '../../../api/server';
import * as Models from '../../../models';
import { settings } from '../../../settings/server';

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');
});
2 changes: 1 addition & 1 deletion app/livechat/imports/server/rest/agent.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Match, check } from 'meteor/check';

import { API } from '../../../../api';
import { API } from '../../../../api/server';
import { findAgentDepartments } from '../../../server/api/lib/agents';

API.v1.addRoute('livechat/agents/:agentId/departments', { authRequired: true }, {
Expand Down
2 changes: 1 addition & 1 deletion app/livechat/imports/server/rest/appearance.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { API } from '../../../../api';
import { API } from '../../../../api/server';
import { findAppearance } from '../../../server/api/lib/appearance';

API.v1.addRoute('livechat/appearance', { authRequired: true }, {
Expand Down
2 changes: 1 addition & 1 deletion app/livechat/imports/server/rest/dashboards.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Match, check } from 'meteor/check';

import { API } from '../../../../api';
import { API } from '../../../../api/server';
import { hasPermission } from '../../../../authorization/server';
import {
findAllChatsStatus,
Expand Down
2 changes: 1 addition & 1 deletion app/livechat/imports/server/rest/departments.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Match, check } from 'meteor/check';

import { API } from '../../../../api';
import { API } from '../../../../api/server';
import { hasPermission } from '../../../../authorization';
import { LivechatDepartment, LivechatDepartmentAgents } from '../../../../models';
import { Livechat } from '../../../server/lib/Livechat';
Expand Down
2 changes: 1 addition & 1 deletion app/livechat/imports/server/rest/facebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import crypto from 'crypto';

import { Random } from 'meteor/random';

import { API } from '../../../../api';
import { API } from '../../../../api/server';
import { LivechatRooms, LivechatVisitors } from '../../../../models';
import { settings } from '../../../../settings';
import { Livechat } from '../../../server/lib/Livechat';
Expand Down
2 changes: 1 addition & 1 deletion app/livechat/imports/server/rest/inquiries.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Meteor } from 'meteor/meteor';
import { Match, check } from 'meteor/check';

import { API } from '../../../../api';
import { API } from '../../../../api/server';
import { hasPermission } from '../../../../authorization';
import { Users, LivechatDepartment, LivechatInquiry } from '../../../../models';
import { findInquiries, findOneInquiryByRoomId } from '../../../server/api/lib/inquiries';
Expand Down
2 changes: 1 addition & 1 deletion app/livechat/imports/server/rest/integrations.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { API } from '../../../../api';
import { API } from '../../../../api/server';
import { findIntegrationSettings } from '../../../server/api/lib/integrations';

API.v1.addRoute('livechat/integrations.settings', { authRequired: true }, {
Expand Down
2 changes: 1 addition & 1 deletion app/livechat/imports/server/rest/messages.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import { check } from 'meteor/check';

import { API } from '../../../../api';
import { API } from '../../../../api/server';
import { findExternalMessages } from '../../../server/api/lib/messages';

API.v1.addRoute('livechat/messages.external/:roomId', { authRequired: true }, {
Expand Down
2 changes: 1 addition & 1 deletion app/livechat/imports/server/rest/officeHour.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { API } from '../../../../api';
import { API } from '../../../../api/server';
import { findLivechatOfficeHours } from '../../../server/api/lib/officeHour';

API.v1.addRoute('livechat/office-hours', { authRequired: true }, {
Expand Down
2 changes: 1 addition & 1 deletion app/livechat/imports/server/rest/queue.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { API } from '../../../../api';
import { API } from '../../../../api/server';
import { findQueueMetrics } from '../../../server/api/lib/queue';

API.v1.addRoute('livechat/queue', { authRequired: true }, {
Expand Down
2 changes: 1 addition & 1 deletion app/livechat/imports/server/rest/rooms.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Match, check } from 'meteor/check';

import { hasPermission } from '../../../../authorization/server';
import { API } from '../../../../api';
import { API } from '../../../../api/server';
import { findRooms } from '../../../server/api/lib/rooms';

const validateDateParams = (property, date) => {
Expand Down
2 changes: 1 addition & 1 deletion app/livechat/imports/server/rest/sms.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Meteor } from 'meteor/meteor';
import { Random } from 'meteor/random';

import { LivechatRooms, LivechatVisitors, LivechatDepartment } from '../../../../models';
import { API } from '../../../../api';
import { API } from '../../../../api/server';
import { SMS } from '../../../../sms';
import { Livechat } from '../../../server/lib/Livechat';

Expand Down
2 changes: 1 addition & 1 deletion app/livechat/imports/server/rest/triggers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { check } from 'meteor/check';

import { API } from '../../../../api';
import { API } from '../../../../api/server';
import { findTriggers, findTriggerById } from '../../../server/api/lib/triggers';

API.v1.addRoute('livechat/triggers', { authRequired: true }, {
Expand Down
2 changes: 1 addition & 1 deletion app/livechat/imports/server/rest/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { settings } from '../../../../settings';
import { Settings, LivechatRooms, LivechatVisitors } from '../../../../models';
import { fileUploadIsValidContentType } from '../../../../utils';
import { FileUpload } from '../../../../file-upload';
import { API } from '../../../../api';
import { API } from '../../../../api/server';

let maxFileSize;

Expand Down
2 changes: 1 addition & 1 deletion app/livechat/imports/server/rest/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { check } from 'meteor/check';
import _ from 'underscore';

import { hasPermission } from '../../../../authorization';
import { API } from '../../../../api';
import { API } from '../../../../api/server';
import { Users } from '../../../../models';
import { Livechat } from '../../../server/lib/Livechat';
import { findAgents, findManagers } from '../../../server/api/lib/users';
Expand Down
2 changes: 1 addition & 1 deletion app/livechat/imports/server/rest/visitors.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import { check } from 'meteor/check';

import { API } from '../../../../api';
import { API } from '../../../../api/server';
import { findVisitorInfo, findVisitedPages, findChatHistory } from '../../../server/api/lib/visitors';

API.v1.addRoute('livechat/visitors.info', { authRequired: true }, {
Expand Down
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);
});
}
});
2 changes: 1 addition & 1 deletion app/livechat/server/api/v1/agent.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Meteor } from 'meteor/meteor';
import { Match, check } from 'meteor/check';

import { API } from '../../../../api';
import { API } from '../../../../api/server';
import { findRoom, findGuest, findAgent, findOpenRoom } from '../lib/livechat';
import { Livechat } from '../../lib/Livechat';

Expand Down
2 changes: 1 addition & 1 deletion app/livechat/server/api/v1/config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Match, check } from 'meteor/check';

import { API } from '../../../../api';
import { API } from '../../../../api/server';
import { findGuest, settings, online, findOpenRoom, getExtraConfigInfo, findAgent } from '../lib/livechat';

API.v1.addRoute('livechat/config', {
Expand Down
2 changes: 1 addition & 1 deletion app/livechat/server/api/v1/customField.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Meteor } from 'meteor/meteor';
import { Match, check } from 'meteor/check';

import { API } from '../../../../api';
import { API } from '../../../../api/server';
import { findGuest } from '../lib/livechat';
import { Livechat } from '../../lib/Livechat';
import { findLivechatCustomFields, findCustomFieldById } from '../lib/customFields';
Expand Down
2 changes: 1 addition & 1 deletion app/livechat/server/api/v1/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Random } from 'meteor/random';

import { Messages, LivechatRooms, LivechatVisitors } from '../../../../models';
import { hasPermission } from '../../../../authorization';
import { API } from '../../../../api';
import { API } from '../../../../api/server';
import { loadMessageHistory } from '../../../../lib';
import { findGuest, findRoom, normalizeHttpHeaderData } from '../lib/livechat';
import { Livechat } from '../../lib/Livechat';
Expand Down
2 changes: 1 addition & 1 deletion app/livechat/server/api/v1/offlineMessage.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Match, check } from 'meteor/check';
import { TAPi18n } from 'meteor/rocketchat:tap-i18n';

import { API } from '../../../../api';
import { API } from '../../../../api/server';
import { Livechat } from '../../lib/Livechat';

API.v1.addRoute('livechat/offline.message', {
Expand Down
Loading

0 comments on commit 6ed0e44

Please sign in to comment.