@rocket.chat/apps-engine
Advanced tools
Comparing version 0.4.8 to 0.4.9
{ | ||
"name": "@rocket.chat/apps-engine", | ||
"version": "0.4.8", | ||
"version": "0.4.9", | ||
"description": "The engine code for the Rocket.Chat Apps which manages, runs, translates, coordinates and all of that.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -8,2 +8,3 @@ import { ConfigurationExtend } from './ConfigurationExtend'; | ||
import { MessageBuilder } from './MessageBuilder'; | ||
import { MessageExtender } from './MessageExtender'; | ||
import { MessageRead } from './MessageRead'; | ||
@@ -19,2 +20,3 @@ import { Modify } from './Modify'; | ||
import { RoomBuilder } from './RoomBuilder'; | ||
import { RoomExtender } from './RoomExtender'; | ||
import { RoomRead } from './RoomRead'; | ||
@@ -28,2 +30,2 @@ import { ServerSettingRead } from './ServerSettingRead'; | ||
import { UserRead } from './UserRead'; | ||
export { ConfigurationExtend, ConfigurationModify, EnvironmentalVariableRead, EnvironmentRead, Http, HttpExtend, MessageBuilder, MessageRead, Modify, ModifyCreator, ModifyExtender, ModifyUpdater, Notifier, Persistence, PersistenceRead, Reader, RoomBuilder, RoomRead, ServerSettingRead, ServerSettingsModify, SettingRead, SettingsExtend, SlashCommandsExtend, SlashCommandsModify, UserRead }; | ||
export { ConfigurationExtend, ConfigurationModify, EnvironmentalVariableRead, EnvironmentRead, Http, HttpExtend, MessageBuilder, MessageExtender, MessageRead, Modify, ModifyCreator, ModifyExtender, ModifyUpdater, Notifier, Persistence, PersistenceRead, Reader, RoomBuilder, RoomExtender, RoomRead, ServerSettingRead, ServerSettingsModify, SettingRead, SettingsExtend, SlashCommandsExtend, SlashCommandsModify, UserRead }; |
@@ -17,2 +17,4 @@ "use strict"; | ||
exports.MessageBuilder = MessageBuilder_1.MessageBuilder; | ||
var MessageExtender_1 = require("./MessageExtender"); | ||
exports.MessageExtender = MessageExtender_1.MessageExtender; | ||
var MessageRead_1 = require("./MessageRead"); | ||
@@ -38,2 +40,4 @@ exports.MessageRead = MessageRead_1.MessageRead; | ||
exports.RoomBuilder = RoomBuilder_1.RoomBuilder; | ||
var RoomExtender_1 = require("./RoomExtender"); | ||
exports.RoomExtender = RoomExtender_1.RoomExtender; | ||
var RoomRead_1 = require("./RoomRead"); | ||
@@ -40,0 +44,0 @@ exports.RoomRead = RoomRead_1.RoomRead; |
@@ -174,3 +174,3 @@ "use strict"; | ||
process: {}, | ||
}), { timeout: 100, filename: "App_" + storage.info.nameSlug + ".js" }); | ||
}), { timeout: 1000, filename: "App_" + storage.info.nameSlug + ".js" }); | ||
if (!(rl instanceof App_1.App)) { | ||
@@ -177,0 +177,0 @@ throw new errors_1.MustExtendAppError(); |
@@ -142,2 +142,5 @@ "use strict"; | ||
var entry = zip.getEntry(filePath); | ||
if (typeof entry === 'undefined') { | ||
return undefined; | ||
} | ||
if (entry.isDirectory) { | ||
@@ -144,0 +147,0 @@ return undefined; |
@@ -17,3 +17,9 @@ import { AppManager } from '../AppManager'; | ||
private executePreMessageSentPrevent(data); | ||
private executePreMessageSentExtend(data); | ||
private executePreMessageSentModify(data); | ||
private executePostMessageSent(data); | ||
private executePreRoomCreatePrevent(data); | ||
private executePreRoomCreateExtend(data); | ||
private executePreRoomCreateModify(data); | ||
private executePostRoomCreate(data); | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var accessors_1 = require("../accessors"); | ||
var compiler_1 = require("../compiler"); | ||
@@ -43,5 +44,21 @@ var metadata_1 = require("@rocket.chat/apps-ts-definition/metadata"); | ||
return this.executePreMessageSentPrevent(data); | ||
case compiler_1.AppInterface.IPreMessageSentExtend: | ||
return this.executePreMessageSentExtend(data); | ||
case compiler_1.AppInterface.IPreMessageSentModify: | ||
return this.executePreMessageSentModify(data); | ||
case compiler_1.AppInterface.IPostMessageSent: | ||
this.executePostMessageSent(data); | ||
return; | ||
case compiler_1.AppInterface.IPreRoomCreatePrevent: | ||
return this.executePreRoomCreatePrevent(data); | ||
case compiler_1.AppInterface.IPreRoomCreateExtend: | ||
return this.executePreRoomCreateExtend(data); | ||
case compiler_1.AppInterface.IPreRoomCreateModify: | ||
return this.executePreRoomCreateModify(data); | ||
case compiler_1.AppInterface.IPostRoomCreate: | ||
this.executePostRoomCreate(data); | ||
return; | ||
default: | ||
console.warn('Unimplemented (or invalid) AppInterface was just tried to execute.'); | ||
return; | ||
} | ||
@@ -67,2 +84,32 @@ }; | ||
}; | ||
AppListenerManger.prototype.executePreMessageSentExtend = function (data) { | ||
var msg = Object.assign({}, data); | ||
for (var _i = 0, _a = this.listeners.get(compiler_1.AppInterface.IPreMessageSentExtend); _i < _a.length; _i++) { | ||
var appId = _a[_i]; | ||
var app = this.manager.getOneById(appId); | ||
var continueOn = true; | ||
if (app.hasMethod(metadata_1.AppMethod.CHECKPREMESSAGESENTEXTEND)) { | ||
continueOn = app.call(metadata_1.AppMethod.CHECKPREMESSAGESENTEXTEND, Object.freeze(msg), this.am.getReader(appId), this.am.getHttp(appId)); | ||
} | ||
if (continueOn && app.hasMethod(metadata_1.AppMethod.EXECUTEPREMESSAGESENTEXTEND)) { | ||
msg = app.call(metadata_1.AppMethod.EXECUTEPREMESSAGESENTEXTEND, msg, new accessors_1.MessageExtender(msg), this.am.getReader(appId), this.am.getHttp(appId), this.am.getPersistence(appId)); | ||
} | ||
} | ||
return data; | ||
}; | ||
AppListenerManger.prototype.executePreMessageSentModify = function (data) { | ||
var msg = Object.assign({}, data); | ||
for (var _i = 0, _a = this.listeners.get(compiler_1.AppInterface.IPreMessageSentModify); _i < _a.length; _i++) { | ||
var appId = _a[_i]; | ||
var app = this.manager.getOneById(appId); | ||
var continueOn = true; | ||
if (app.hasMethod(metadata_1.AppMethod.CHECKPREMESSAGESENTMODIFY)) { | ||
continueOn = app.call(metadata_1.AppMethod.CHECKPREMESSAGESENTMODIFY, Object.freeze(msg), this.am.getReader(appId), this.am.getHttp(appId)); | ||
} | ||
if (continueOn && app.hasMethod(metadata_1.AppMethod.EXECUTEPREMESSAGESENTMODIFY)) { | ||
msg = app.call(metadata_1.AppMethod.EXECUTEPREMESSAGESENTMODIFY, Object.freeze(msg), new accessors_1.MessageBuilder(msg), this.am.getReader(appId), this.am.getHttp(appId), this.am.getPersistence(appId)); | ||
} | ||
} | ||
return data; | ||
}; | ||
AppListenerManger.prototype.executePostMessageSent = function (data) { | ||
@@ -81,2 +128,63 @@ for (var _i = 0, _a = this.listeners.get(compiler_1.AppInterface.IPostMessageSent); _i < _a.length; _i++) { | ||
}; | ||
AppListenerManger.prototype.executePreRoomCreatePrevent = function (data) { | ||
var prevented = false; | ||
for (var _i = 0, _a = this.listeners.get(compiler_1.AppInterface.IPreRoomCreatePrevent); _i < _a.length; _i++) { | ||
var appId = _a[_i]; | ||
var app = this.manager.getOneById(appId); | ||
var continueOn = true; | ||
if (app.hasMethod(metadata_1.AppMethod.CHECKPREROOMCREATEPREVENT)) { | ||
continueOn = app.call(metadata_1.AppMethod.CHECKPREROOMCREATEPREVENT, data, this.am.getReader(appId), this.am.getHttp(appId)); | ||
} | ||
if (continueOn && app.hasMethod(metadata_1.AppMethod.EXECUTEPREROOMCREATEPREVENT)) { | ||
prevented = app.call(metadata_1.AppMethod.EXECUTEPREROOMCREATEPREVENT, data, this.am.getReader(appId), this.am.getHttp(appId), this.am.getPersistence(appId)); | ||
if (prevented) { | ||
return prevented; | ||
} | ||
} | ||
} | ||
return prevented; | ||
}; | ||
AppListenerManger.prototype.executePreRoomCreateExtend = function (data) { | ||
var room = Object.assign({}, data); | ||
for (var _i = 0, _a = this.listeners.get(compiler_1.AppInterface.IPreRoomCreateExtend); _i < _a.length; _i++) { | ||
var appId = _a[_i]; | ||
var app = this.manager.getOneById(appId); | ||
var continueOn = true; | ||
if (app.hasMethod(metadata_1.AppMethod.CHECKPREROOMCREATEEXTEND)) { | ||
continueOn = app.call(metadata_1.AppMethod.CHECKPREROOMCREATEEXTEND, Object.freeze(room), this.am.getReader(appId), this.am.getHttp(appId)); | ||
} | ||
if (continueOn && app.hasMethod(metadata_1.AppMethod.EXECUTEPREROOMCREATEEXTEND)) { | ||
room = app.call(metadata_1.AppMethod.EXECUTEPREROOMCREATEEXTEND, room, new accessors_1.RoomExtender(room), this.am.getReader(appId), this.am.getHttp(appId), this.am.getPersistence(appId)); | ||
} | ||
} | ||
return data; | ||
}; | ||
AppListenerManger.prototype.executePreRoomCreateModify = function (data) { | ||
var room = Object.assign({}, data); | ||
for (var _i = 0, _a = this.listeners.get(compiler_1.AppInterface.IPreRoomCreateModify); _i < _a.length; _i++) { | ||
var appId = _a[_i]; | ||
var app = this.manager.getOneById(appId); | ||
var continueOn = true; | ||
if (app.hasMethod(metadata_1.AppMethod.CHECKPREROOMCREATEMODIFY)) { | ||
continueOn = app.call(metadata_1.AppMethod.CHECKPREROOMCREATEMODIFY, Object.freeze(room), this.am.getReader(appId), this.am.getHttp(appId)); | ||
} | ||
if (continueOn && app.hasMethod(metadata_1.AppMethod.EXECUTEPREROOMCREATEMODIFY)) { | ||
room = app.call(metadata_1.AppMethod.EXECUTEPREROOMCREATEMODIFY, Object.freeze(room), new accessors_1.RoomBuilder(room), this.am.getReader(appId), this.am.getHttp(appId), this.am.getPersistence(appId)); | ||
} | ||
} | ||
return data; | ||
}; | ||
AppListenerManger.prototype.executePostRoomCreate = function (data) { | ||
for (var _i = 0, _a = this.listeners.get(compiler_1.AppInterface.IPostRoomCreate); _i < _a.length; _i++) { | ||
var appId = _a[_i]; | ||
var app = this.manager.getOneById(appId); | ||
var continueOn = true; | ||
if (app.hasMethod(metadata_1.AppMethod.CHECKPOSTROOMCREATE)) { | ||
continueOn = app.call(metadata_1.AppMethod.CHECKPOSTROOMCREATE, data, this.am.getReader(appId), this.am.getHttp(appId)); | ||
} | ||
if (continueOn && app.hasMethod(metadata_1.AppMethod.EXECUTEPOSTROOMCREATE)) { | ||
app.call(metadata_1.AppMethod.EXECUTEPOSTROOMCREATE, data, this.am.getReader(appId), this.am.getHttp(appId), this.am.getPersistence(appId)); | ||
} | ||
} | ||
}; | ||
return AppListenerManger; | ||
@@ -83,0 +191,0 @@ }()); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
401564
4119