feat: add option for relay hint

This commit is contained in:
reya
2024-05-26 08:23:29 +07:00
parent b90ad1421f
commit 4dc13385a5
6 changed files with 56 additions and 20 deletions

View File

@@ -22,24 +22,25 @@ export class LumeEvent {
return this.tags.filter((tag) => tag[0] === "p").map((tag) => tag[1]);
}
static getEventThread(tags: string[][]) {
static getEventThread(tags: string[][], gossip?: boolean) {
let root: string = null;
let reply: string = null;
// Get all event references from tags, ignore mention
const events = tags.filter((el) => el[0] === "e" && el[3] !== "mention");
/*
if (gossip) {
const relays = tags.filter((el) => el[0] === "e" && el[2]?.length);
if (gossip) {
const relays = tags.filter((el) => el[0] === "e" && el[2]?.length);
if (relays.length >= 1) {
for (const relay of relays) {
if (relay[2]?.length) this.add_relay(relay[2]);
}
}
}
*/
if (relays.length >= 1) {
for (const relay of relays) {
if (relay[2]?.length)
commands
.connectRelay(relay[2])
.then(() => console.log("[gossip]: ", relay[2]));
}
}
}
if (events.length === 1) {
root = events[0][1];

View File

@@ -4,6 +4,7 @@ export interface Settings {
autoUpdate: boolean;
zap: boolean;
nsfw: boolean;
gossip: boolean;
[key: string]: string | number | boolean;
}