chore: random fixes

This commit is contained in:
2023-11-22 15:34:46 +00:00
parent a67263e5e1
commit 2884a35b5c
9 changed files with 75 additions and 66 deletions

View File

@ -27,9 +27,20 @@ enum EventKind {
MuteList = 10_000, // NIP-51
PinList = 10_001, // NIP-51
BookmarksList = 10_003, // NIP-51
CommunitiesList = 10_004, // NIP-51
PublicChatsList = 10_005, // NIP-51
BlockedRelaysList = 10_006, // NIP-51
SearchRelaysList = 10_007, // NIP-51
InterestsList = 10_015, // NIP-51
EmojisList = 10_030, // NIP-51
CategorizedPeople = 30000, // NIP-51a
CategorizedBookmarks = 30001, // NIP-51b
FollowSet = 30_000, // NIP-51
RelaySet = 30_002, // NIP-51
BookmarkSet = 30_003, // NIP-51
CurationSet = 30_004, // NIP-51
InterestSet = 30_015, // NIP-15
EmojiSet = 30_030, // NIP-51
Badge = 30009, // NIP-58
ProfileBadges = 30008, // NIP-58

View File

@ -137,9 +137,8 @@ export class EventPublisher {
* Build a categorized bookmarks event with a given label
* @param notes List of bookmarked links
*/
async bookmarks(notes: Array<ToNostrEventTag>, list: "bookmark" | "follow") {
const eb = this.#eb(EventKind.CategorizedBookmarks);
eb.tag(["d", list]);
async bookmarks(notes: Array<ToNostrEventTag>) {
const eb = this.#eb(EventKind.BookmarksList);
notes.forEach(n => {
eb.tag(unwrap(n.toEventTag()));
});

View File

@ -400,7 +400,7 @@ export class NostrSystem extends EventEmitter<NostrSystemEvents> implements Syst
}
return;
}),
...replyRelays.filter(a => !socks.some(b => b.Address === a)).map(a => this.WriteOnceToRelay(a, ev)),
...replyRelays.filter(a => !this.#sockets.has(a)).map(a => this.WriteOnceToRelay(a, ev)),
]);
return removeUndefined(oks);
}

View File

@ -1,5 +1,14 @@
import { EventKind, FullRelaySettings, NostrEvent, ReqFilter, RequestBuilder, SystemInterface, UsersRelays } from ".";
import { dedupe, sanitizeRelayUrl, unixNowMs, unwrap } from "@snort/shared";
import {
EventKind,
FullRelaySettings,
NostrEvent,
ReqFilter,
RequestBuilder,
SystemInterface,
TaggedNostrEvent,
UsersRelays,
} from ".";
import { dedupe, removeUndefined, sanitizeRelayUrl, unixNowMs, unwrap } from "@snort/shared";
import debug from "debug";
import { FlatReqFilter } from "./query-optimizer";
import { RelayListCacheExpire } from "./const";
@ -193,7 +202,7 @@ export async function pickRelaysForReply(ev: NostrEvent, system: SystemInterface
const recipients = dedupe(ev.tags.filter(a => a[0] === "p").map(a => a[1]));
await updateRelayLists(recipients, system);
const relays = pickTopRelays(system.RelayCache, recipients, 2, "read");
const ret = dedupe(relays.map(a => a.relays).flat());
const ret = removeUndefined(dedupe(relays.map(a => a.relays).flat()));
logger("Picked %O from authors %O", ret, recipients);
return ret;
}