Work on getting Rocket.Chat Apps to work on multi-instance rocket.chat instances

pull/9902/head
graywolf336 8 years ago
parent 23c7eaf119
commit fcefbc0774
No known key found for this signature in database
GPG Key ID: 63D2D655DA5B3643
  1. 2
      packages/rocketchat-apps/client/communication/websockets.js
  2. 2
      packages/rocketchat-apps/package.js
  3. 30
      packages/rocketchat-apps/server/bridges/activation.js
  4. 5
      packages/rocketchat-apps/server/communication/index.js
  5. 2
      packages/rocketchat-apps/server/communication/rest.js
  6. 36
      packages/rocketchat-apps/server/communication/websockets.js
  7. 2
      packages/rocketchat-apps/server/orchestrator.js
  8. 2
      packages/rocketchat-lib/client/lib/RestApiClient.js

@ -8,9 +8,11 @@ export class AppWebsocketReceiver {
this.streamer.on('command/disabled', this.onCommandDisabled.bind(this));
this.streamer.on('command/updated', this.onCommandUpdated.bind(this));
this.streamer.on('command/removed', this.onCommandDisabled.bind(this));
console.log('apps websocket listener');
}
onAppAdded(appId) {
console.log('app added');
RocketChat.API.get(`apps/${ appId }/languages`).then((result) => {
this.orch.parseAndLoadLanguages(result.languages);
});

@ -87,6 +87,6 @@ Package.onUse(function(api) {
Npm.depends({
'busboy': '0.2.13',
'@rocket.chat/apps-engine': '0.3.5',
'@rocket.chat/apps-engine': '0.3.7',
'@rocket.chat/apps-ts-definition': '0.7.6'
});

@ -3,33 +3,27 @@ export class AppActivationBridge {
this.orch = orch;
}
appEnabled(app) {
console.log(`The App ${ app.getName() } (${ app.getID() }) has been enabled.`);
}
appAdded(app) {
console.log(`The ${ app.getName() } App (${ app.getID() }) has been added.`);
appDisabled(app) {
console.log(`The App ${ app.getName() } (${ app.getID() }) has been disabled.`);
this.orch.getNotifier().appAdded(app.getID());
}
appLoaded(app, enabled) {
console.log(`The App ${ app.getName() } (${ app.getID() }) has been loaded and enabled? ${ enabled }`);
appUpdated(app) {
console.log(`The ${ app.getName() } App (${ app.getID() }) has been updated.`);
if (enabled) {
this.orch.getNotifier().appAdded(app.getID());
}
this.orch.getNotifier().appUpdated(app.getID());
}
appUpdated(app, enabled) {
console.log(`The App ${ app.getName() } (${ app.getID() }) has been updated and enabled? ${ enabled }`);
appRemoved(app) {
console.log(`The ${ app.getName() } App (${ app.getID() }) has been removed.`);
if (enabled) {
this.orch.getNotifier().appUpdated(app.getID());
}
this.orch.getNotifier().appRemoved(app.getID());
}
appRemoved(app) {
console.log(`The App ${ app.getName() } (${ app.getID() }) has been removed.`);
appStatusChanged(app, status) {
console.log(`The ${ app.getName() } App (${ app.getID() }) status has changed: ${ status }`);
this.orch.getNotifier().appRemoved(app.getID());
this.orch.getNotifier().appStatusUpdated(app.getID(), status);
}
}

@ -1,9 +1,10 @@
import { AppMethods} from './methods';
import { AppsRestApi } from './rest';
import { AppWebsocketNotifier } from './websockets';
import { AppWebsocketNotifier, AppWebsocketListener } from './websockets';
export {
AppMethods,
AppsRestApi,
AppWebsocketNotifier
AppWebsocketNotifier,
AppWebsocketListener
};

@ -158,7 +158,7 @@ export class AppsRestApi {
}
});
this.api.addRoute(':id/languages', { authRequired: true }, {
this.api.addRoute(':id/languages', { authRequired: false }, {
get() {
console.log(`Getting ${ this.urlParams.id }'s languages..`);
const prl = manager.getOneById(this.urlParams.id);

@ -1,13 +1,41 @@
export class AppWebsocketListener {
constructor(orch, streamer) {
this.orch = orch;
this.streamer = streamer;
this.streamer.on('app/added', this.onAppAdded.bind(this));
this.streamer.on('app/statusUpdate', this.onAppStatusUpdated.bind(this));
this.streamer.on('app/removed', this.onAppRemoved.bind(this));
console.log('hello from the app websocket listener');
}
onAppAdded(appId) {
console.log('On App Added!', appId);
this.orch.getManager().loadOne(appId).then(() => console.log('yay'));
}
onAppStatusUpdated({ appId, status }) {
console.log('App Status Update:', appId, status);
}
onAppRemoved(appId) {
console.log('On App Removed!', appId);
}
}
export class AppWebsocketNotifier {
constructor() {
this.streamer = new Meteor.Streamer('apps', { retransmit: false });
constructor(orch) {
this.streamer = new Meteor.Streamer('apps', { retransmit: true, retransmitToSelf: true });
this.streamer.allowRead('all');
this.streamer.allowEmit('all');
this.streamer.allowWrite('none');
this.listener = new AppWebsocketListener(orch, this.streamer);
}
appAdded(appId) {
this.streamer.emit('app/added', appId);
console.log('emitting: "app/added"', appId);
}
appRemoved(appId) {
@ -18,6 +46,10 @@ export class AppWebsocketNotifier {
this.streamer.emit('app/updated', appId);
}
appStatusUpdated(appId, status) {
this.streamer.emit('app/statusUpdate', { appId, status });
}
commandAdded(command) {
this.streamer.emit('command/added', command);
}

@ -29,7 +29,7 @@ class AppServerOrchestrator {
this._communicators = new Map();
this._communicators.set('methods', new AppMethods(this._manager));
this._communicators.set('notifier', new AppWebsocketNotifier());
this._communicators.set('notifier', new AppWebsocketNotifier(this));
this._communicators.set('restapi', new AppsRestApi(this, this._manager));
}

@ -44,7 +44,7 @@ RocketChat.API = {
return new Promise(function _rlRestApiGet(resolve, reject) {
jQuery.ajax({
method,
url: `${ Meteor.absoluteUrl() }api/${ endpoint }${ query }`,
url: `${ window.location.origin }/api/${ endpoint }${ query }`,
headers: {
'Content-Type': 'application/json',
'X-User-Id': localStorage['Meteor.userId'],

Loading…
Cancel
Save