Socket
Socket
Sign inDemoInstall

mx-puppet-bridge

Package Overview
Dependencies
Maintainers
1
Versions
112
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mx-puppet-bridge - npm Package Compare versions

Comparing version 0.0.28 to 0.0.29

53

lib/src/botprovisioner.js

@@ -165,3 +165,3 @@ "use strict";

else {
yield this.commands[name].fn(sender, param, sendMessage);
yield this.commands[name].fn(sender, param || "", sendMessage);
}

@@ -172,9 +172,4 @@ break;

if (!handled) {
const commands = ["help", "link", "unlink", "relink"];
for (const name in this.commands) {
if (this.commands.hasOwnProperty(name)) {
commands.push(name);
}
}
yield this.sendMessage(roomId, "Available commands: " + commands.join(", "));
yield this.sendMessage(roomId, "Command not found! Please type `help` to see a list of" +
" all commands or `help <command>` to get help on a specific command.");
}

@@ -238,2 +233,28 @@ }

registerDefaultCommands() {
this.registerCommand("help", {
fn: (sender, param, sendMessage) => __awaiter(this, void 0, void 0, function* () {
param = param.trim();
if (!param) {
const commands = ["`help`", "`link`", "`unlink`", "`relink`"];
for (const name in this.commands) {
if (this.commands.hasOwnProperty(name)) {
commands.push(`\`${name}\``);
}
}
const msg = `Available commands: ${commands.join(", ")}\n\nType \`help <command>\` to get more help on them.`;
yield sendMessage(msg);
return;
}
// alright, let's display some help!
if (!this.commands[param]) {
yield sendMessage(`Command \`${param}\` not found!`);
return;
}
yield sendMessage(this.commands[param].help);
}),
help: `List all commands and optionally get help on specific ones.
Usage: \`help\`, \`help <command>\``,
withPid: false,
});
this.registerCommand("list", {

@@ -257,3 +278,5 @@ fn: (sender, param, sendMessage) => __awaiter(this, void 0, void 0, function* () {

}),
help: "List all set links",
help: `List all set links along with their information.
Usage: \`list\``,
withPid: false,

@@ -281,3 +304,5 @@ });

}),
help: "Sets a matrix token to enable double-puppeting",
help: `Sets a matrix token to enable double-puppeting.
Usage: \`setmatrixtoken <token>\``,
withPid: false,

@@ -321,3 +346,5 @@ });

}),
help: "Lists all users that are linked",
help: `Lists all users that are linked currently, from all links.
Usage: \`listusers\``,
withPid: false,

@@ -361,3 +388,5 @@ });

}),
help: "List all rooms that are linked",
help: `List all rooms that are linked currently, from all links.
Usage: \`listrooms\``,
withPid: false,

@@ -364,0 +393,0 @@ });

@@ -23,2 +23,3 @@ export declare class Config {

homeserverUrl: string;
mediaUrl: string;
loginSharedSecretMap: {

@@ -25,0 +26,0 @@ [homeserver: string]: string;

@@ -210,3 +210,3 @@ "use strict";

}
const data = this.newData(row.mxid, row.group_id, row.puppet_id);
const data = this.newData(row.mxid, row.group_id, Number(row.puppet_id));
data.name = row.name;

@@ -213,0 +213,0 @@ data.avatarUrl = row.avatar_url;

@@ -47,2 +47,3 @@ "use strict";

avatarMxc: row.avatar_mxc,
avatarUrl: null,
token: row.token,

@@ -66,2 +67,3 @@ statusRoom: row.status_room,

avatarMxc: null,
avatarUrl: null,
token: null,

@@ -266,3 +268,3 @@ statusRoom: null,

return {
puppetId: row.puppet_id,
puppetId: Number(row.puppet_id),
puppetMxid: row.puppet_mxid,

@@ -269,0 +271,0 @@ data: JSON.parse(row.data),

@@ -108,3 +108,3 @@ "use strict";

return {
puppetId: row.puppet_id,
puppetId: Number(row.puppet_id),
roomId: row.room_id,

@@ -111,0 +111,0 @@ userId: row.user_id,

@@ -186,3 +186,3 @@ "use strict";

}
const data = this.newData(row.mxid, row.room_id, row.puppet_id);
const data = this.newData(row.mxid, row.room_id, Number(row.puppet_id));
data.name = row.name;

@@ -189,0 +189,0 @@ data.avatarUrl = row.avatar_url;

@@ -202,3 +202,3 @@ "use strict";

}
const data = this.newRoomOverrideData(row.puppet_id, row.user_id, row.room_id);
const data = this.newRoomOverrideData(Number(row.puppet_id), row.user_id, row.room_id);
data.name = row.name;

@@ -205,0 +205,0 @@ data.avatarUrl = row.avatar_url;

@@ -59,5 +59,4 @@ "use strict";

else {
const mod = module;
allEnabled.push(mod.module);
enhancedEnabled[mod.module] = mod;
allEnabled.push(module.module);
enhancedEnabled[module.module] = module;
}

@@ -70,5 +69,4 @@ }

else {
const mod = module;
allDisabled.push(mod.module);
enhancedDisabled[mod.module] = mod;
allDisabled.push(module.module);
enhancedDisabled[module.module] = module;
}

@@ -75,0 +73,0 @@ }

@@ -56,3 +56,3 @@ "use strict";

return __awaiter(this, void 0, void 0, function* () {
const homeserver = mxid.split(":")[1];
const homeserver = mxid.substring(mxid.indexOf(":") + 1);
const sharedSecret = this.bridge.config.bridge.loginSharedSecretMap[homeserver];

@@ -64,3 +64,3 @@ if (!sharedSecret) {

const hmac = crypto_1.createHmac("sha512", sharedSecret);
const password = hmac.update(new Buffer(mxid, "utf-8")).digest("hex");
const password = hmac.update(Buffer.from(mxid, "utf-8")).digest("hex");
const homeserverUrl = yield this.getHsUrl(mxid);

@@ -82,3 +82,3 @@ const auth = new matrix_bot_sdk_1.MatrixAuth(homeserverUrl);

log.verbose(`Looking up Homserver URL for mxid ${mxid}...`);
let hsUrl = mxid.split(":")[1];
let hsUrl = mxid.substring(mxid.indexOf(":") + 1);
if (this.bridge.config.homeserverUrlMap[hsUrl]) {

@@ -98,3 +98,6 @@ hsUrl = this.bridge.config.homeserverUrlMap[hsUrl];

const wellKnown = JSON.parse(wellKnownStr);
hsUrl = wellKnown["m.homeserver"].base_url;
const maybeUrl = wellKnown["m.homeserver"].base_url;
if (typeof maybeUrl === "string") {
hsUrl = maybeUrl;
}
}

@@ -101,0 +104,0 @@ catch (err) { } // do nothing

@@ -157,3 +157,3 @@ /// <reference types="node" />

*/
getUrlFromMxc(mxc: string): string;
getUrlFromMxc(mxc: string, width?: number, height?: number, method?: string): string;
/**

@@ -160,0 +160,0 @@ * Get the info (name, avatar) of the the specified puppet

@@ -237,3 +237,3 @@ "use strict";

port: this.config.bridge.port,
registration: registration,
registration,
joinStrategy: new joinstrategy_1.PuppetBridgeJoinRoomStrategy(new matrix_bot_sdk_1.SimpleRetryJoinStrategy(), this),

@@ -438,4 +438,15 @@ });

*/
getUrlFromMxc(mxc) {
return `${this.config.bridge.homeserverUrl}/_matrix/media/v1/download/${mxc.substring("mxc://".length)}`;
getUrlFromMxc(mxc, width, height, method) {
const baseUrl = this.config.bridge.mediaUrl || this.config.bridge.homeserverUrl;
const mxcPath = mxc.substring("mxc://".length);
if (!width || !height) {
return `${baseUrl}/_matrix/media/r0/download/${mxcPath}`;
}
if (!method) {
method = "crop";
}
const widthUri = encodeURIComponent(width);
const heightUri = encodeURIComponent(height);
method = encodeURIComponent(method);
return `${baseUrl}/_matrix/media/r0/thumbnail/${mxcPath}?width=${widthUri}&height=${heightUri}&method=${method}`;
}

@@ -464,12 +475,13 @@ /**

const ret = yield this.botIntent.underlyingClient.getUserProfile(puppetMxid);
const p = {
puppetMxid,
name: ret.displayname || null,
avatarMxc: ret.avatar_url,
token: null,
};
const p = yield this.store.puppetStore.getOrCreateMxidInfo(puppetMxid);
p.name = ret.displayname || null;
if (ret.avatar_url) {
p.avatarMxc = ret.avatar_url;
p.avatarUrl = this.getUrlFromMxc(ret.avatar_url);
}
else {
p.avatarMxc = null;
p.avatarUrl = null;
}
yield this.store.puppetStore.setMxidInfo(p);
if (p.avatarMxc) {
p.avatarUrl = this.getUrlFromMxc(p.avatarMxc);
}
return p;

@@ -476,0 +488,0 @@ }

@@ -163,3 +163,3 @@ "use strict";

const versionReply = yield this.db.Get(`SELECT version FROM ${table}`);
version = versionReply.version;
version = Number(versionReply.version);
}

@@ -166,0 +166,0 @@ catch (er) {

@@ -43,2 +43,3 @@ "use strict";

this.db.delete(value);
this.scheduleGc(true);
return this;

@@ -56,4 +57,8 @@ }

}
scheduleGc() {
if (this.nextGc) {
scheduleGc(force = false) {
if (force && this.nextGc) {
clearTimeout(this.nextGc);
this.nextGc = null;
}
if (this.nextGc !== null || this.db.size === 0) {
return;

@@ -60,0 +65,0 @@ }

@@ -7,5 +7,5 @@ export declare class MessageDeduplicator {

constructor(lockTimeout?: number, lockDataTimeout?: number);
lock(roomId: string, authorId?: string, message?: string): void;
lock(roomId: string, authorId: string, message?: string): void;
unlock(roomId: string, authorId?: string, eventId?: string): void;
dedupe(roomId: string, authorId?: string, eventId?: string, message?: string): Promise<boolean>;
dedupe(roomId: string, authorId: string, eventId?: string, message?: string): Promise<boolean>;
}

@@ -37,6 +37,4 @@ "use strict";

this.locks.set(roomId);
if (authorId) {
this.authorIds.add(authorId);
}
if (authorId && message) {
this.authorIds.add(authorId);
if (message) {
this.data.add(`${roomId};${authorId};m:${message}`);

@@ -56,3 +54,3 @@ }

return __awaiter(this, void 0, void 0, function* () {
if (authorId && !this.authorIds.has(authorId)) {
if (!this.authorIds.has(authorId)) {
return false;

@@ -62,3 +60,3 @@ }

let returnValue = false;
if (authorId && eventId) {
if (eventId) {
const key = `${roomId};${authorId};e:${eventId}`;

@@ -70,3 +68,3 @@ if (this.data.has(key)) {

}
if (authorId && message) {
if (message) {
const key = `${roomId};${authorId};m:${message}`;

@@ -73,0 +71,0 @@ if (this.data.has(key)) {

{
"name": "mx-puppet-bridge",
"version": "0.0.28",
"version": "0.0.29",
"description": "Matrix Puppeting Bridge library",

@@ -5,0 +5,0 @@ "repository": {

@@ -177,3 +177,3 @@ /*

} else {
await (this.commands[name].fn as FullCommandFn)(sender, param, sendMessage);
await (this.commands[name].fn as FullCommandFn)(sender, param || "", sendMessage);
}

@@ -184,9 +184,4 @@ break;

if (!handled) {
const commands = ["help", "link", "unlink", "relink"];
for (const name in this.commands) {
if (this.commands.hasOwnProperty(name)) {
commands.push(name);
}
}
await this.sendMessage(roomId, "Available commands: " + commands.join(", "));
await this.sendMessage(roomId, "Command not found! Please type `help` to see a list of" +
" all commands or `help <command>` to get help on a specific command.");
}

@@ -249,2 +244,28 @@ }

private registerDefaultCommands() {
this.registerCommand("help", {
fn: async (sender: string, param: string, sendMessage: SendMessageFn) => {
param = param.trim();
if (!param) {
const commands = ["`help`", "`link`", "`unlink`", "`relink`"];
for (const name in this.commands) {
if (this.commands.hasOwnProperty(name)) {
commands.push(`\`${name}\``);
}
}
const msg = `Available commands: ${commands.join(", ")}\n\nType \`help <command>\` to get more help on them.`;
await sendMessage(msg);
return;
}
// alright, let's display some help!
if (!this.commands[param]) {
await sendMessage(`Command \`${param}\` not found!`);
return;
}
await sendMessage(this.commands[param].help);
},
help: `List all commands and optionally get help on specific ones.
Usage: \`help\`, \`help <command>\``,
withPid: false,
});
this.registerCommand("list", {

@@ -268,3 +289,5 @@ fn: async (sender: string, param: string, sendMessage: SendMessageFn) => {

},
help: "List all set links",
help: `List all set links along with their information.
Usage: \`list\``,
withPid: false,

@@ -292,3 +315,5 @@ });

},
help: "Sets a matrix token to enable double-puppeting",
help: `Sets a matrix token to enable double-puppeting.
Usage: \`setmatrixtoken <token>\``,
withPid: false,

@@ -331,3 +356,5 @@ });

},
help: "Lists all users that are linked",
help: `Lists all users that are linked currently, from all links.
Usage: \`listusers\``,
withPid: false,

@@ -370,3 +397,5 @@ });

},
help: "List all rooms that are linked",
help: `List all rooms that are linked currently, from all links.
Usage: \`listrooms\``,
withPid: false,

@@ -373,0 +402,0 @@ });

@@ -41,2 +41,3 @@ /*

public homeserverUrl: string;
public mediaUrl: string;
public loginSharedSecretMap: {[homeserver: string]: string} = {};

@@ -43,0 +44,0 @@ public displayname?: string;

@@ -38,3 +38,3 @@ /*

roomIds: [],
} as IGroupStoreEntry;
};
}

@@ -66,3 +66,3 @@

});
const results = [] as IGroupStoreEntry[];
const results: IGroupStoreEntry[] = [];
for (const row of rows) {

@@ -219,3 +219,3 @@ const res = await this.getFromRow(row);

row.group_id as string,
row.puppet_id as number,
Number(row.puppet_id),
);

@@ -222,0 +222,0 @@ data.name = row.name as string | null;

@@ -62,5 +62,6 @@ /*

avatarMxc: row.avatar_mxc as string | null,
avatarUrl: null,
token: row.token as string | null,
statusRoom: row.status_room as string | null,
} as IMxidInfo;
};
}

@@ -76,9 +77,10 @@

}
const p = {
const p: IMxidInfo = {
puppetMxid,
name: null,
avatarMxc: null,
avatarUrl: null,
token: null,
statusRoom: null,
} as IMxidInfo;
};
await this.setMxidInfo(p);

@@ -124,3 +126,3 @@ this.mxidInfoLock.release(puppetMxid);

public async getAll(): Promise<IPuppet[]> {
const result = [] as IPuppet[];
const result: IPuppet[] = [];
const rows = await this.db.All("SELECT * FROM puppet_store");

@@ -137,3 +139,3 @@ for (const r of rows) {

public async getForMxid(puppetMxid: string): Promise<IPuppet[]> {
const result = [] as IPuppet[];
const result: IPuppet[] = [];
const rows = await this.db.All("SELECT * FROM puppet_store WHERE puppet_mxid=$mxid", { mxid: puppetMxid });

@@ -236,3 +238,3 @@ for (const r of rows) {

public async getGhostsInRoom(room: string): Promise<string[]> {
const result = [] as string[];
const result: string[] = [];
const rows = await this.db.All("SELECT * FROM ghosts_joined_chans WHERE chan_mxid = $room", { room });

@@ -246,3 +248,3 @@ for (const r of rows) {

public async getRoomsOfGhost(ghost: string): Promise<string[]> {
const result = [] as string[];
const result: string[] = [];
const rows = await this.db.All("SELECT * FROM ghosts_joined_chans WHERE ghost_mxid = $ghost", { ghost });

@@ -270,7 +272,7 @@ for (const r of rows) {

return {
puppetId: row.puppet_id as number,
puppetId: Number(row.puppet_id),
puppetMxid: row.puppet_mxid as string,
data: JSON.parse(row.data as string),
userId: row.user_id as string | null,
} as IPuppet;
};
} catch (err) {

@@ -277,0 +279,0 @@ log.warn(`Unable to decode json data:${err} on puppet ${row.puppet_id}`);

@@ -113,3 +113,3 @@ /*

return {
puppetId: row.puppet_id as number,
puppetId: Number(row.puppet_id),
roomId: row.room_id as string,

@@ -120,4 +120,4 @@ userId: row.user_id as string,

key: row.key as string,
} as IReactionStoreEntry;
};
}
}

@@ -41,3 +41,3 @@ /*

puppetId,
} as IRoomStoreEntry;
};
}

@@ -63,3 +63,3 @@

});
const results = [] as IRoomStoreEntry[];
const results: IRoomStoreEntry[] = [];
for (const row of rows) {

@@ -194,3 +194,3 @@ const res = this.getFromRow(row);

row.room_id as string,
row.puppet_id as number,
Number(row.puppet_id),
);

@@ -197,0 +197,0 @@ data.name = row.name as string | null;

@@ -36,3 +36,3 @@ /*

userId,
} as IUserStoreEntry;
};
}

@@ -121,3 +121,3 @@

roomId,
} as IUserStoreRoomOverrideEntry;
};
}

@@ -208,3 +208,3 @@

const data = this.newRoomOverrideData(
row.puppet_id as number,
Number(row.puppet_id),
row.user_id as string,

@@ -211,0 +211,0 @@ row.room_id as string,

@@ -66,5 +66,4 @@ /*

} else {
const mod = module as LoggingInterfaceModuleConfig;
allEnabled.push(mod.module);
enhancedEnabled[mod.module] = mod;
allEnabled.push(module.module);
enhancedEnabled[module.module] = module;
}

@@ -76,5 +75,4 @@ }

} else {
const mod = module as LoggingInterfaceModuleConfig;
allDisabled.push(mod.module);
enhancedDisabled[mod.module] = mod;
allDisabled.push(module.module);
enhancedDisabled[module.module] = module;
}

@@ -81,0 +79,0 @@ }

@@ -285,3 +285,3 @@ /*

const url = this.bridge.getUrlFromMxc(content.url);
const data = {
const data: IFileEvent = {
filename: content.body,

@@ -291,3 +291,3 @@ mxc: content.url,

eventId: event.eventId,
} as IFileEvent;
};
if (content.info) {

@@ -325,7 +325,7 @@ data.info = content.info;

log.debug("Emitting as text fallback...");
const textData = {
const textData: IMessageEvent = {
body: `New ${emitEvent}: ${data.url}`,
emote: false,
eventId: event.eventId,
} as IMessageEvent;
};
this.bridge.emit("message", room, textData, event);

@@ -338,3 +338,3 @@ }

const content = event.content;
const msgData = {
const msgData: IMessageEvent = {
body: content.body,

@@ -344,3 +344,3 @@ emote: msgtype === "m.emote",

eventId: event.eventId,
} as IMessageEvent;
};
if (content.format) {

@@ -356,4 +356,4 @@ msgData.formattedBody = content.formatted_body;

if (this.bridge.protocol.features.edit && relate.rel_type === "m.replace") {
const newContent = event.content["m.new_content"] as TextualMessageEventContent;
const relData = {
const newContent: TextualMessageEventContent = event.content["m.new_content"];
const relData: IMessageEvent = {
body: newContent.body,

@@ -363,3 +363,3 @@ emote: newContent.msgtype === "m.emote",

eventId: event.eventId,
} as IMessageEvent;
};
if (newContent.format) {

@@ -366,0 +366,0 @@ relData.formattedBody = newContent.formatted_body;

@@ -65,3 +65,3 @@ /*

public async loginWithSharedSecret(mxid: string): Promise<string | null> {
const homeserver = mxid.split(":")[1];
const homeserver = mxid.substring(mxid.indexOf(":") + 1);
const sharedSecret = this.bridge.config.bridge.loginSharedSecretMap[homeserver];

@@ -74,3 +74,3 @@ if (!sharedSecret) {

const hmac = createHmac("sha512", sharedSecret);
const password = hmac.update(new Buffer(mxid, "utf-8")).digest("hex");
const password = hmac.update(Buffer.from(mxid, "utf-8")).digest("hex");

@@ -91,3 +91,3 @@ const homeserverUrl = await this.getHsUrl(mxid);

log.verbose(`Looking up Homserver URL for mxid ${mxid}...`);
let hsUrl = mxid.split(":")[1];
let hsUrl = mxid.substring(mxid.indexOf(":") + 1);
if (this.bridge.config.homeserverUrlMap[hsUrl]) {

@@ -106,3 +106,6 @@ hsUrl = this.bridge.config.homeserverUrlMap[hsUrl];

const wellKnown = JSON.parse(wellKnownStr);
hsUrl = wellKnown["m.homeserver"].base_url;
const maybeUrl = wellKnown["m.homeserver"].base_url;
if (typeof maybeUrl === "string") {
hsUrl = maybeUrl;
}
} catch (err) { } // do nothing

@@ -128,3 +131,3 @@ log.verbose(`Resolved to ${hsUrl}`);

token: info.token,
} as ITokenResponse;
};
}

@@ -203,3 +206,3 @@

const datas = await this.getForMxid(puppetMxid);
const descs = [] as IProvisionerDesc[];
const descs: IProvisionerDesc[] = [];
for (const data of datas) {

@@ -216,3 +219,3 @@ descs.push(await this.getDescFromData(data));

desc: `${data.puppetMxid} (${data.puppetId})`,
} as IProvisionerDesc;
};
}

@@ -222,3 +225,3 @@ return {

desc: await this.bridge.hooks.getDesc(data.puppetId, data.data),
} as IProvisionerDesc;
};
}

@@ -225,0 +228,0 @@

@@ -128,3 +128,3 @@ /*

}
this.hooks = {} as IPuppetBridgeHooks;
this.hooks = {};
this.delayedFunction = new DelayedFunction();

@@ -307,3 +307,3 @@ this.mxcLookupLock = new Lock(MXC_LOOKUP_LOCK_TIMEOUT);

port: this.config.bridge.port,
registration: registration as IAppserviceRegistration,
registration,
joinStrategy: new PuppetBridgeJoinRoomStrategy(new SimpleRetryJoinStrategy(), this),

@@ -504,4 +504,15 @@ });

*/
public getUrlFromMxc(mxc: string): string {
return `${this.config.bridge.homeserverUrl}/_matrix/media/v1/download/${mxc.substring("mxc://".length)}`;
public getUrlFromMxc(mxc: string, width?: number, height?: number, method?: string): string {
const baseUrl = this.config.bridge.mediaUrl || this.config.bridge.homeserverUrl;
const mxcPath = mxc.substring("mxc://".length);
if (!width || !height) {
return `${baseUrl}/_matrix/media/r0/download/${mxcPath}`;
}
if (!method) {
method = "crop";
}
const widthUri = encodeURIComponent(width);
const heightUri = encodeURIComponent(height);
method = encodeURIComponent(method);
return `${baseUrl}/_matrix/media/r0/thumbnail/${mxcPath}?width=${widthUri}&height=${heightUri}&method=${method}`;
}

@@ -529,12 +540,12 @@

const ret = await this.botIntent.underlyingClient.getUserProfile(puppetMxid);
const p = {
puppetMxid,
name: ret.displayname || null,
avatarMxc: ret.avatar_url,
token: null,
} as IMxidInfo;
const p = await this.store.puppetStore.getOrCreateMxidInfo(puppetMxid);
p.name = ret.displayname || null;
if (ret.avatar_url) {
p.avatarMxc = ret.avatar_url;
p.avatarUrl = this.getUrlFromMxc(ret.avatar_url);
} else {
p.avatarMxc = null;
p.avatarUrl = null;
}
await this.store.puppetStore.setMxidInfo(p);
if (p.avatarMxc) {
p.avatarUrl = this.getUrlFromMxc(p.avatarMxc);
}
return p;

@@ -541,0 +552,0 @@ } catch (err) {

@@ -38,3 +38,3 @@ /*

// okay, let's create a dummy entry and check if the reaction exists already
const entry = {
const entry: IReactionStoreEntry = {
puppetId: params.room.puppetId,

@@ -46,3 +46,3 @@ roomId: params.room.roomId,

key,
} as IReactionStoreEntry;
};
if (await this.reactionStore.exists(entry)) {

@@ -81,3 +81,3 @@ log.warn("Reaction already exists, ignoring...");

// okay, let's fetch the reaction from the DB
const entry = {
const entry: IReactionStoreEntry = {
puppetId: params.room.puppetId,

@@ -89,3 +89,3 @@ roomId: params.room.roomId,

key,
} as IReactionStoreEntry;
};
const reaction = await this.reactionStore.getFromKey(entry);

@@ -122,3 +122,3 @@ if (!reaction) {

log.info(`Got reaction from matrix in room ${room.roomId} to add...`);
const entry = {
const entry: IReactionStoreEntry = {
puppetId: room.puppetId,

@@ -130,3 +130,3 @@ roomId: room.roomId,

key,
} as IReactionStoreEntry;
};
await this.reactionStore.insert(entry);

@@ -133,0 +133,0 @@ }

@@ -101,6 +101,6 @@ /*

}
const send = {
const send: TextualMessageEventContent = {
msgtype,
body: opts.body,
} as TextualMessageEventContent;
};
(send as any).source = "remote"; // tslint:disable-line no-any

@@ -271,7 +271,7 @@ if (opts.formattedBody) {

);
const info = {
const info: FileWithThumbnailInfo = {
mimetype,
size: buffer.byteLength,
} as FileWithThumbnailInfo;
const sendData = {
};
const sendData: FileMessageEventContent = {
body: name,

@@ -281,3 +281,3 @@ info,

url: fileMxc,
} as FileMessageEventContent;
};
(sendData as any).source = "remote"; // tslint:disable-line no-any

@@ -284,0 +284,0 @@ if (typeof thing === "string") {

@@ -269,7 +269,7 @@ /*

this.mxidLock.set(lockKey);
const entry = {
const entry: IRoomStoreEntry = {
mxid,
roomId: roomData.roomId,
puppetId: roomData.puppetId,
} as IRoomStoreEntry;
};
await this.roomStore.set(entry);

@@ -362,3 +362,3 @@ this.mxidLock.release(lockKey);

puppetId: room.puppetId,
} as IRemoteRoom;
};
}

@@ -365,0 +365,0 @@ const suffix = this.bridge.AS.getSuffixForAlias(mxid);

@@ -167,3 +167,3 @@ /*

const versionReply = await this.db.Get(`SELECT version FROM ${table}`);
version = versionReply!.version as number;
version = Number(versionReply!.version);
} catch (er) {

@@ -170,0 +170,0 @@ log.warn("Couldn't fetch schema version, defaulting to 0");

@@ -53,2 +53,3 @@ /*

this.db.delete(value);
this.scheduleGc(true);
return this;

@@ -68,4 +69,8 @@ }

private scheduleGc() {
if (this.nextGc) {
private scheduleGc(force: boolean = false) {
if (force && this.nextGc) {
clearTimeout(this.nextGc);
this.nextGc = null;
}
if (this.nextGc !== null || this.db.size === 0) {
return;

@@ -72,0 +77,0 @@ }

@@ -35,8 +35,6 @@ /*

public lock(roomId: string, authorId?: string, message?: string) {
public lock(roomId: string, authorId: string, message?: string) {
this.locks.set(roomId);
if (authorId) {
this.authorIds.add(authorId);
}
if (authorId && message) {
this.authorIds.add(authorId);
if (message) {
this.data.add(`${roomId};${authorId};m:${message}`);

@@ -56,4 +54,4 @@ }

public async dedupe(roomId: string, authorId?: string, eventId?: string, message?: string): Promise<boolean> {
if (authorId && !this.authorIds.has(authorId)) {
public async dedupe(roomId: string, authorId: string, eventId?: string, message?: string): Promise<boolean> {
if (!this.authorIds.has(authorId)) {
return false;

@@ -63,3 +61,3 @@ }

let returnValue = false;
if (authorId && eventId) {
if (eventId) {
const key = `${roomId};${authorId};e:${eventId}`;

@@ -71,3 +69,3 @@ if (this.data.has(key)) {

}
if (authorId && message) {
if (message) {
const key = `${roomId};${authorId};m:${message}`;

@@ -74,0 +72,0 @@ if (this.data.has(key)) {

@@ -196,3 +196,3 @@ /*

}
const result = {} as IProfileDbEntry;
const result: IProfileDbEntry = {};
if (oldProfile === null) {

@@ -199,0 +199,0 @@ log.verbose("No old profile exists, creating a new one");

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc