forked from coracle/flotilla
Use space url as relay hint
This commit is contained in:
+24
-15
@@ -99,16 +99,16 @@ export const getPubkeyHints = (pubkey: string) => {
|
|||||||
return hints
|
return hints
|
||||||
}
|
}
|
||||||
|
|
||||||
export const prependParent = (parent: TrustedEvent | undefined, {content, tags}: EventContent) => {
|
export const prependParent = (
|
||||||
|
parent: TrustedEvent | undefined,
|
||||||
|
{content, tags}: EventContent,
|
||||||
|
url?: string,
|
||||||
|
) => {
|
||||||
if (parent) {
|
if (parent) {
|
||||||
const nevent = nip19.neventEncode({
|
const relays = url ? [url] : Router.get().Event(parent).limit(3).getUrls()
|
||||||
id: parent.id,
|
const nevent = nip19.neventEncode({...parent, relays})
|
||||||
kind: parent.kind,
|
|
||||||
author: parent.pubkey,
|
|
||||||
relays: Router.get().Event(parent).limit(3).getUrls(),
|
|
||||||
})
|
|
||||||
|
|
||||||
tags = [...tags, tagEventForQuote(parent), tagPubkey(parent.pubkey)]
|
tags = [...tags, tagEventForQuote(parent, url), tagPubkey(parent.pubkey)]
|
||||||
content = toNostrURI(nevent) + "\n\n" + content
|
content = toNostrURI(nevent) + "\n\n" + content
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,11 +303,18 @@ export type ReactionParams = {
|
|||||||
protect: boolean
|
protect: boolean
|
||||||
event: TrustedEvent
|
event: TrustedEvent
|
||||||
content: string
|
content: string
|
||||||
|
url?: string
|
||||||
tags?: string[][]
|
tags?: string[][]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const makeReaction = ({protect, content, event, tags: paramTags = []}: ReactionParams) => {
|
export const makeReaction = ({
|
||||||
const tags = [...paramTags, ...tagEventForReaction(event)]
|
url,
|
||||||
|
protect,
|
||||||
|
content,
|
||||||
|
event,
|
||||||
|
tags: paramTags = [],
|
||||||
|
}: ReactionParams) => {
|
||||||
|
const tags = [...paramTags, ...tagEventForReaction(event, url)]
|
||||||
const groupTag = getTag("h", event.tags)
|
const groupTag = getTag("h", event.tags)
|
||||||
|
|
||||||
if (groupTag) {
|
if (groupTag) {
|
||||||
@@ -321,8 +328,9 @@ export const makeReaction = ({protect, content, event, tags: paramTags = []}: Re
|
|||||||
return makeEvent(REACTION, {content, tags})
|
return makeEvent(REACTION, {content, tags})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const publishReaction = ({relays, ...params}: ReactionParams & {relays: string[]}) =>
|
export const publishReaction = ({relays, ...params}: ReactionParams & {relays: string[]}) => {
|
||||||
publishThunk({event: makeReaction(params), relays})
|
publishThunk({event: makeReaction({url: relays[0], ...params}), relays})
|
||||||
|
}
|
||||||
|
|
||||||
// Comments
|
// Comments
|
||||||
|
|
||||||
@@ -330,13 +338,14 @@ export type CommentParams = {
|
|||||||
event: TrustedEvent
|
event: TrustedEvent
|
||||||
content: string
|
content: string
|
||||||
tags?: string[][]
|
tags?: string[][]
|
||||||
|
url?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const makeComment = ({event, content, tags = []}: CommentParams) =>
|
export const makeComment = ({url, event, content, tags = []}: CommentParams) =>
|
||||||
makeEvent(COMMENT, {content, tags: [...tags, ...tagEventForComment(event)]})
|
makeEvent(COMMENT, {content, tags: [...tags, ...tagEventForComment(event, url)]})
|
||||||
|
|
||||||
export const publishComment = ({relays, ...params}: CommentParams & {relays: string[]}) =>
|
export const publishComment = ({relays, ...params}: CommentParams & {relays: string[]}) =>
|
||||||
publishThunk({event: makeComment(params), relays})
|
publishThunk({event: makeComment({url: relays[0], ...params}), relays})
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
|
|
||||||
|
|||||||
@@ -129,11 +129,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (share) {
|
if (share) {
|
||||||
template = prependParent(share, template)
|
template = prependParent(share, template, url)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parent) {
|
if (parent) {
|
||||||
template = prependParent(parent, template)
|
template = prependParent(parent, template, url)
|
||||||
}
|
}
|
||||||
|
|
||||||
const thunk = publishThunk({
|
const thunk = publishThunk({
|
||||||
|
|||||||
@@ -67,11 +67,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (share) {
|
if (share) {
|
||||||
template = prependParent(share, template)
|
template = prependParent(share, template, url)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parent) {
|
if (parent) {
|
||||||
template = prependParent(parent, template)
|
template = prependParent(parent, template, url)
|
||||||
}
|
}
|
||||||
|
|
||||||
const thunk = publishThunk({
|
const thunk = publishThunk({
|
||||||
|
|||||||
Reference in New Issue
Block a user