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

Convert rocketchat-integrations to main module structure #12670

Merged
merged 3 commits into from
Nov 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* global processWebhookMessage */

import { processWebhookMessage } from 'meteor/rocketchat:integrations';
import { authenticated } from '../../helpers/authenticated';
import schema from '../../schemas/messages/sendMessage.graphqls';

Expand Down
4 changes: 2 additions & 2 deletions packages/rocketchat-integrations/client/collections.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Mongo } from 'meteor/mongo';

this.ChatIntegrations = new Mongo.Collection('rocketchat_integrations');
this.ChatIntegrationHistory = new Mongo.Collection('rocketchat_integration_history');
export const ChatIntegrations = new Mongo.Collection('rocketchat_integrations');
export const ChatIntegrationHistory = new Mongo.Collection('rocketchat_integration_history');
16 changes: 16 additions & 0 deletions packages/rocketchat-integrations/client/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import './stylesheets/integrations.css';
import '../lib/rocketchat';
import './collections';
import './startup';
import './route';
import './views/integrations.html';
import './views/integrations';
import './views/integrationsNew.html';
import './views/integrationsNew';
import './views/integrationsIncoming.html';
import './views/integrationsIncoming';
import './views/integrationsOutgoing.html';
import './views/integrationsOutgoing';
import './views/integrationsOutgoingHistory.html';
import './views/integrationsOutgoingHistory';
import './views/additional/zapier.html';
1 change: 1 addition & 0 deletions packages/rocketchat-integrations/client/route.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Meteor } from 'meteor/meteor';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { BlazeLayout } from 'meteor/kadira:blaze-layout';
import { t } from 'meteor/rocketchat:ui';

FlowRouter.route('/admin/integrations', {
name: 'admin-integrations',
Expand Down
2 changes: 2 additions & 0 deletions packages/rocketchat-integrations/client/startup.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { RocketChat } from 'meteor/rocketchat:lib';

RocketChat.AdminBox.addOption({
href: 'admin-integrations',
i18nLabel: 'Integrations',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* global ChatIntegrations */
import { Template } from 'meteor/templating';
import { TAPi18n } from 'meteor/tap:i18n';
import { RocketChat } from 'meteor/rocketchat:lib';
import { ChatIntegrations } from '../collections';
import moment from 'moment';

Template.integrations.helpers({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/* global ChatIntegrations */
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import { Random } from 'meteor/random';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { Template } from 'meteor/templating';
import { TAPi18n } from 'meteor/tap:i18n';
import { RocketChat, handleError } from 'meteor/rocketchat:lib';
import { t, modal } from 'meteor/rocketchat:ui';
import { ChatIntegrations } from '../collections';
import hljs from 'highlight.js';
import toastr from 'toastr';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Template } from 'meteor/templating';
import { RocketChat } from 'meteor/rocketchat:lib';

Template.integrationsNew.helpers({
hasPermission() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/* global ChatIntegrations */
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import { Random } from 'meteor/random';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { Template } from 'meteor/templating';
import { TAPi18n } from 'meteor/tap:i18n';
import { RocketChat, handleError } from 'meteor/rocketchat:lib';
import { t, modal } from 'meteor/rocketchat:ui';
import { ChatIntegrations } from '../collections';
import hljs from 'highlight.js';
import toastr from 'toastr';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/* global ChatIntegrations, ChatIntegrationHistory */
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { Template } from 'meteor/templating';
import { TAPi18n } from 'meteor/tap:i18n';
import { RocketChat, handleError } from 'meteor/rocketchat:lib';
import { ChatIntegrations, ChatIntegrationHistory } from '../collections';
import _ from 'underscore';
import hljs from 'highlight.js';
import moment from 'moment';
Expand Down
2 changes: 2 additions & 0 deletions packages/rocketchat-integrations/lib/rocketchat.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { RocketChat } from 'meteor/rocketchat:lib';

RocketChat.integrations = {
outgoingEvents: {
sendMessage: {
Expand Down
78 changes: 15 additions & 63 deletions packages/rocketchat-integrations/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,67 +7,19 @@ Package.describe({
});

Package.onUse(function(api) {
api.use('mongo');
api.use('ecmascript');
api.use('babel-compiler');
api.use('rocketchat:lib');
api.use('rocketchat:authorization');
api.use('rocketchat:theme');
api.use('rocketchat:logger');

api.use('kadira:flow-router', 'client');
api.use('kadira:blaze-layout', 'client');
api.use('templating', 'client');

api.addFiles('lib/rocketchat.js', ['server', 'client']);

// items
api.addFiles('client/collections.js', 'client');
api.addFiles('client/startup.js', 'client');
api.addFiles('client/route.js', 'client');

// views
api.addFiles('client/views/integrations.html', 'client');
api.addFiles('client/views/integrations.js', 'client');
api.addFiles('client/views/integrationsNew.html', 'client');
api.addFiles('client/views/integrationsNew.js', 'client');
api.addFiles('client/views/integrationsIncoming.html', 'client');
api.addFiles('client/views/integrationsIncoming.js', 'client');
api.addFiles('client/views/integrationsOutgoing.html', 'client');
api.addFiles('client/views/integrationsOutgoing.js', 'client');
api.addFiles('client/views/integrationsOutgoingHistory.html', 'client');
api.addFiles('client/views/integrationsOutgoingHistory.js', 'client');
api.addFiles('client/views/additional/zapier.html', 'client');

// stylesheets
api.addFiles('client/stylesheets/integrations.css', 'client');

api.addFiles('server/logger.js', 'server');
api.addFiles('server/lib/validation.js', 'server');

api.addFiles('server/models/Integrations.js', 'server');
api.addFiles('server/models/IntegrationHistory.js', 'server');

// publications
api.addFiles('server/publications/integrations.js', 'server');
api.addFiles('server/publications/integrationHistory.js', 'server');

// methods
api.addFiles('server/methods/incoming/addIncomingIntegration.js', 'server');
api.addFiles('server/methods/incoming/updateIncomingIntegration.js', 'server');
api.addFiles('server/methods/incoming/deleteIncomingIntegration.js', 'server');
api.addFiles('server/methods/outgoing/addOutgoingIntegration.js', 'server');
api.addFiles('server/methods/outgoing/updateOutgoingIntegration.js', 'server');
api.addFiles('server/methods/outgoing/replayOutgoingIntegration.js', 'server');
api.addFiles('server/methods/outgoing/deleteOutgoingIntegration.js', 'server');
api.addFiles('server/methods/clearIntegrationHistory.js', 'server');

// api
api.addFiles('server/api/api.js', 'server');

api.addFiles('server/lib/triggerHandler.js', 'server');
api.addFiles('server/triggers.js', 'server');

api.addFiles('server/processWebhookMessage.js', 'server');
api.export('processWebhookMessage', 'server');
api.use([
'ecmascript',
'mongo',
'babel-compiler',
'rocketchat:lib',
'rocketchat:authorization',
'rocketchat:theme',
'rocketchat:logger',
'kadira:flow-router',
'kadira:blaze-layout',
'nimble:restivus',
'templating',
]);
api.mainModule('client/index.js', 'client');
api.mainModule('server/index.js', 'server');
});
8 changes: 5 additions & 3 deletions packages/rocketchat-integrations/server/api/api.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/* globals Meteor Restivus logger processWebhookMessage*/
// TODO: remove globals

import { Meteor } from 'meteor/meteor';
import { HTTP } from 'meteor/http';
import { Random } from 'meteor/random';
import { RocketChat } from 'meteor/rocketchat:lib';
import { Restivus } from 'meteor/nimble:restivus';
import { logger } from '../logger';
import { processWebhookMessage } from '../processWebhookMessage';
import Fiber from 'fibers';
import Future from 'fibers/future';
import _ from 'underscore';
Expand Down
23 changes: 23 additions & 0 deletions packages/rocketchat-integrations/server/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import '../lib/rocketchat';
import './logger';
import './lib/validation';
import './models/Integrations';
import './models/IntegrationHistory';
import './publications/integrations';
import './publications/integrationHistory';
import './methods/incoming/addIncomingIntegration';
import './methods/incoming/updateIncomingIntegration';
import './methods/incoming/deleteIncomingIntegration';
import './methods/outgoing/addOutgoingIntegration';
import './methods/outgoing/updateOutgoingIntegration';
import './methods/outgoing/replayOutgoingIntegration';
import './methods/outgoing/deleteOutgoingIntegration';
import './methods/clearIntegrationHistory';
import './api/api';
import './lib/triggerHandler';
import './triggers';
import { processWebhookMessage } from './processWebhookMessage';

export {
processWebhookMessage,
};
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/* global logger, processWebhookMessage */
import { Meteor } from 'meteor/meteor';
import { Random } from 'meteor/random';
import { HTTP } from 'meteor/http';
import { RocketChat } from 'meteor/rocketchat:lib';
import { logger } from '../logger';
import { processWebhookMessage } from '../processWebhookMessage';
import _ from 'underscore';
import s from 'underscore.string';
import moment from 'moment';
Expand Down
3 changes: 2 additions & 1 deletion packages/rocketchat-integrations/server/lib/validation.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* global Babel */
import { Meteor } from 'meteor/meteor';
import { Match } from 'meteor/check';
import { Babel } from 'meteor/babel-compiler';
import { RocketChat } from 'meteor/rocketchat:lib';
import _ from 'underscore';
import s from 'underscore.string';
const scopedChannels = ['all_public_channels', 'all_private_groups', 'all_direct_messages'];
Expand Down
5 changes: 2 additions & 3 deletions packages/rocketchat-integrations/server/logger.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* globals logger:true */
/* exported logger */
import { Logger } from 'meteor/rocketchat:logger';

logger = new Logger('Integrations', {
export const logger = new Logger('Integrations', {
sections: {
incoming: 'Incoming WebHook',
outgoing: 'Outgoing WebHook',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { RocketChat } from 'meteor/rocketchat:lib';

Meteor.methods({
clearIntegrationHistory(integrationId) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* global Babel */
import { Meteor } from 'meteor/meteor';
import { Random } from 'meteor/random';
import { Babel } from 'meteor/babel-compiler';
import { RocketChat } from 'meteor/rocketchat:lib';
import _ from 'underscore';
import s from 'underscore.string';
const validChannelChars = ['@', '#'];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { RocketChat } from 'meteor/rocketchat:lib';

Meteor.methods({
deleteIncomingIntegration(integrationId) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* global Babel */
import { Meteor } from 'meteor/meteor';
import { RocketChat } from 'meteor/rocketchat:lib';
import { Babel } from 'meteor/babel-compiler';
import _ from 'underscore';
import s from 'underscore.string';
const validChannelChars = ['@', '#'];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { RocketChat } from 'meteor/rocketchat:lib';

Meteor.methods({
addOutgoingIntegration(integration) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { RocketChat } from 'meteor/rocketchat:lib';

Meteor.methods({
deleteOutgoingIntegration(integrationId) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { RocketChat } from 'meteor/rocketchat:lib';

Meteor.methods({
replayOutgoingIntegration({ integrationId, historyId }) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { RocketChat } from 'meteor/rocketchat:lib';

Meteor.methods({
updateOutgoingIntegration(integrationId, integration) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { RocketChat } from 'meteor/rocketchat:lib';

RocketChat.models.IntegrationHistory = new class IntegrationHistory extends RocketChat.models._Base {
constructor() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { RocketChat } from 'meteor/rocketchat:lib';

RocketChat.models.Integrations = new class Integrations extends RocketChat.models._Base {
constructor() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Meteor } from 'meteor/meteor';
import { RocketChat } from 'meteor/rocketchat:lib';
import _ from 'underscore';
import s from 'underscore.string';

processWebhookMessage = function(messageObj, user, defaultValues = { channel: '', alias: '', avatar: '', emoji: '' }, mustBeJoined = false) { //eslint-disable-line
export const processWebhookMessage = function(messageObj, user, defaultValues = { channel: '', alias: '', avatar: '', emoji: '' }, mustBeJoined = false) {
const sentData = [];
const channels = [].concat(messageObj.channel || messageObj.roomId || defaultValues.channel);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { RocketChat } from 'meteor/rocketchat:lib';

Meteor.publish('integrationHistory', function _integrationHistoryPublication(integrationId, limit = 25) {
if (!this.userId) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Meteor } from 'meteor/meteor';
import { RocketChat } from 'meteor/rocketchat:lib';

Meteor.publish('integrations', function _integrationPublication() {
if (!this.userId) {
Expand Down
2 changes: 2 additions & 0 deletions packages/rocketchat-integrations/server/triggers.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { RocketChat } from 'meteor/rocketchat:lib';

const callbackHandler = function _callbackHandler(eventType) {
return function _wrapperFunction(...args) {
return RocketChat.integrations.triggerHandler.executeTriggers(eventType, ...args);
Expand Down