mirror of
https://github.com/hzrd149/nostrudel.git
synced 2025-04-11 21:29:26 +02:00
use nevent when quote reposting notes
This commit is contained in:
parent
2eeb79c92f
commit
17d51601c6
5
.changeset/modern-rivers-exist.md
Normal file
5
.changeset/modern-rivers-exist.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"nostrudel": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Use nevent when quote reposting note
|
@ -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(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user