Skip to content
Extraits de code Groupes Projets
Valider 0d80a4e0 rédigé par Will Hunt's avatar Will Hunt
Parcourir les fichiers

Remove done stuff

parent 04afe790
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -22,7 +22,6 @@ import { DiscordBot } from "./bot"; ...@@ -22,7 +22,6 @@ import { DiscordBot } from "./bot";
import { DiscordStore } from "./store"; import { DiscordStore } from "./store";
import { Log } from "./log"; import { Log } from "./log";
import "source-map-support/register"; import "source-map-support/register";
import { IRequestPromise } from "./util";
const log = new Log("DiscordAS"); const log = new Log("DiscordAS");
...@@ -94,15 +93,6 @@ async function run(port: number, fileConfig: DiscordBridgeConfig) { ...@@ -94,15 +93,6 @@ async function run(port: number, fileConfig: DiscordBridgeConfig) {
} catch (err) { log.error("Exception thrown while handling \"onAliasQuery\" event", err); } } catch (err) { log.error("Exception thrown while handling \"onAliasQuery\" event", err); }
}, },
onEvent: async (request) => { onEvent: async (request) => {
// This function emulates the Bluebird.done function so the underlying bridge library doesn't
// break.
// tslint:disable-next-line no-any
const done = function(resolve: (res: any) => void, reject: (err: Error) => void) {
// tslint:disable-next-line no-invalid-this no-floating-promises
(this as Promise<{}>).then(resolve);
// tslint:disable-next-line no-invalid-this no-floating-promises
(this as Promise<{}>).catch(reject);
};
try { try {
// Build our own context. // Build our own context.
if (!store.roomStore) { if (!store.roomStore) {
...@@ -110,21 +100,20 @@ async function run(port: number, fileConfig: DiscordBridgeConfig) { ...@@ -110,21 +100,20 @@ async function run(port: number, fileConfig: DiscordBridgeConfig) {
return; return;
} }
const roomId = request.getData().room_id; const roomId = request.getData().room_id;
const context: BridgeContext = { const context: BridgeContext = {
rooms: {}, rooms: {},
}; };
if (roomId) { if (roomId) {
const entries = await store.roomStore.getEntriesByMatrixId(roomId); const entries = await store.roomStore.getEntriesByMatrixId(roomId);
context.rooms = entries[0] || {}; context.rooms = entries[0] || {};
} }
await request.outcomeFrom({ await request.outcomeFrom(callbacks.onEvent(request, context));
done,
...callbacks.onEvent(request, context),
} as IRequestPromise<{}>);
} catch (err) { } catch (err) {
log.error("Exception thrown while handling \"onEvent\" event", err); log.error("Exception thrown while handling \"onEvent\" event", err);
await request.outcomeFrom({done, ...Promise.reject("Failed to handle")}); await request.outcomeFrom(Promise.reject("Failed to handle"));
} }
}, },
onLog: (line, isError) => { onLog: (line, isError) => {
......
...@@ -51,10 +51,6 @@ export interface IPatternMap { ...@@ -51,10 +51,6 @@ export interface IPatternMap {
[index: string]: string; [index: string]: string;
} }
export interface IRequestPromise<T> extends PromiseLike<T> {
done(resolve: (msg: T) => {}, reject: (err: Error) => {}): void;
}
export class Util { export class Util {
/** /**
* downloadFile - This function will take a URL and store the resulting data into * downloadFile - This function will take a URL and store the resulting data into
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter