Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private async runBridge(port: number, config: any) {
const checkOnly = process.env.BIFROST_CHECK_ONLY === "true";
log.info("Starting purple bridge on port", port);
this.cfg.ApplyConfig(config);
if (checkOnly && this.config.logging.console === "off") {
// Force console if we are doing an integrity check only.
Logging.configure({
console: "info",
});
} else {
Logging.configure(this.cfg.logging);
}
this.bridge = new Bridge({
controller: {
// onUserQuery: userQuery,
onAliasQuery: (alias, aliasLocalpart) => this.eventHandler!.onAliasQuery(alias, aliasLocalpart),
onEvent: (r: IEventRequest, context) => {
if (this.eventHandler === undefined) {return; }
const p = this.eventHandler.onEvent(r, context).catch((err) => {
log.error("onEvent err", err);
}).catch(() => {
Metrics.requestOutcome(false, r.getDuration(), "fail");
}).then(() => {
private async runBridge(port: number, config: any) {
const checkOnly = process.env.BIFROST_CHECK_ONLY === "true";
log.info("Starting purple bridge on port", port);
this.cfg.ApplyConfig(config);
if (checkOnly && this.config.logging.console === "off") {
// Force console if we are doing an integrity check only.
Logging.configure({
console: "info",
});
} else {
Logging.configure(this.cfg.logging);
}
this.bridge = new Bridge({
controller: {
// onUserQuery: userQuery,
onAliasQuery: (alias, aliasLocalpart) => this.eventHandler!.onAliasQuery(alias, aliasLocalpart),
onEvent: (r: IEventRequest, context) => {
if (this.eventHandler === undefined) {return; }
const p = this.eventHandler.onEvent(r, context).catch((err) => {
log.error("onEvent err", err);
}).catch(() => {
Metrics.requestOutcome(false, r.getDuration(), "fail");
}).then(() => {
Metrics.requestOutcome(false, r.getDuration(), "success");
});
},
onLog: (msg: string, error: boolean) => {
run(port: number, config: IConfig, registration: any) {
Logging.configure(config.logging || {});
const log = Logging.get("app");
new Main(config, registration).run(port).then(() => {
log.info("Matrix-side listening on port", port);
}).catch((ex) => {
log.error("Failed to start:", ex);
process.exit(1);
});
},
});
*/
import { Logging, MatrixUser, UserBridgeStore, RoomBridgeStore, EventBridgeStore } from "matrix-appservice-bridge";
import * as NeDB from "nedb";
import * as path from "path";
import { promisify } from "util";
import { NedbDatastore } from "../datastore/NedbDatastore";
import { PgDatastore } from "../datastore/postgres/PgDatastore";
import { BridgedRoom } from "../BridgedRoom";
import { SlackGhost } from "../SlackGhost";
import { Datastore, TeamEntry } from "../datastore/Models";
import { WebClient } from "@slack/web-api";
import { TeamInfoResponse } from "../SlackResponses";
import { SlackClientFactory } from "../SlackClientFactory";
Logging.configure({ console: "info" });
const log = Logging.get("script");
const POSTGRES_URL = process.argv[2];
const NEDB_DIRECTORY = process.argv[3] || "";
const USER_PREFIX = process.argv[4] || "slack_";
async function main() {
if (!POSTGRES_URL) {
log.error("You must specify the postgres url (ex: postgresql://user:pass@host/database");
throw Error("");
}
const pgres = new PgDatastore(POSTGRES_URL);
await pgres.ensureSchema();
const config = {
autoload: false,
public start(): any {
Logging.configure({console: "debug"});
try {
this.cli.run();
} catch (ex) {
log.error(ex);
}
}