use nevent when quote reposting notes

This commit is contained in:
hzrd149 2023-06-16 20:51:03 -05:00
parent 2eeb79c92f
commit 17d51601c6
2 changed files with 14 additions and 9 deletions

View File

@ -0,0 +1,5 @@
---
"nostrudel": patch
---
Use nevent when quote reposting note

View File

@ -5,6 +5,8 @@ import { RelayConfig, RelayMode } from "../classes/relay";
import accountService from "../services/account"; import accountService from "../services/account";
import { Kind, nip19 } from "nostr-tools"; import { Kind, nip19 } from "nostr-tools";
import { matchNostrLink } from "./regexp"; import { matchNostrLink } from "./regexp";
import { getSharableNoteId } from "./nip19";
import relayScoreboardService from "../services/relay-scoreboard";
export function isReply(event: NostrEvent | DraftNostrEvent) { export function isReply(event: NostrEvent | DraftNostrEvent) {
return event.kind === 1 && !!getReferences(event).replyId; return event.kind === 1 && !!getReferences(event).replyId;
@ -154,13 +156,14 @@ export function buildReply(event: NostrEvent, account = accountService.current.v
} }
export function buildRepost(event: NostrEvent): DraftNostrEvent { export function buildRepost(event: NostrEvent): DraftNostrEvent {
const relay = getEventRelays(event.id).value?.[0] ?? ""; const relays = getEventRelays(event.id).value;
const topRelay = relayScoreboardService.getRankedRelays(relays)[0] ?? "";
const tags: NostrEvent["tags"] = []; const tags: NostrEvent["tags"] = [];
tags.push(["e", event.id, relay]); tags.push(["e", event.id, topRelay]);
return { return {
kind: 6, //Kind.Repost kind: Kind.Repost,
tags, tags,
content: "", content: "",
created_at: dayjs().unix(), created_at: dayjs().unix(),
@ -168,15 +171,12 @@ export function buildRepost(event: NostrEvent): DraftNostrEvent {
} }
export function buildQuoteRepost(event: NostrEvent): DraftNostrEvent { export function buildQuoteRepost(event: NostrEvent): DraftNostrEvent {
const relay = getEventRelays(event.id).value?.[0] ?? ""; const nevent = getSharableNoteId(event.id);
const tags: NostrEvent["tags"] = [];
tags.push(["e", event.id, relay, "mention"]);
return { return {
kind: Kind.Text, kind: Kind.Text,
tags, tags: [],
content: "#[0]", content: "nostr:" + nevent,
created_at: dayjs().unix(), created_at: dayjs().unix(),
}; };
} }