feat: k tag in reaction and repost

This commit is contained in:
Shusui MOYATANI
2023-12-20 02:24:08 +09:00
parent 0f150d6353
commit 0eb7a554b4
2 changed files with 10 additions and 1 deletions

View File

@@ -93,6 +93,7 @@ const ReactionAction = (props: { event: NostrEvent }) => {
pubkey: pubkeyNonNull, pubkey: pubkeyNonNull,
reactionTypes: reactionTypes ?? { type: 'LikeDislike', content: '+' }, reactionTypes: reactionTypes ?? { type: 'LikeDislike', content: '+' },
eventId: eventIdNonNull, eventId: eventIdNonNull,
kind: props.event.kind,
notifyPubkey: props.event.pubkey, notifyPubkey: props.event.pubkey,
}); });
setReacted(true); setReacted(true);
@@ -185,6 +186,7 @@ const RepostAction = (props: { event: NostrEvent }) => {
relayUrls: config().relayUrls, relayUrls: config().relayUrls,
pubkey: pubkeyNonNull, pubkey: pubkeyNonNull,
eventId: eventIdNonNull, eventId: eventIdNonNull,
kind: props.event.kind,
notifyPubkey: props.event.pubkey, notifyPubkey: props.event.pubkey,
}); });
setReposted(true); setReposted(true);
@@ -269,6 +271,7 @@ const EmojiReactions: Component<{ event: NostrEvent }> = (props) => {
pubkey: pubkeyNonNull, pubkey: pubkeyNonNull,
reactionTypes: reactionTypes ?? { type: 'LikeDislike', content: '+' }, reactionTypes: reactionTypes ?? { type: 'LikeDislike', content: '+' },
eventId: eventIdNonNull, eventId: eventIdNonNull,
kind: props.event.kind,
notifyPubkey: props.event.pubkey, notifyPubkey: props.event.pubkey,
}); });
setReacted(true); setReacted(true);

View File

@@ -123,18 +123,21 @@ const useCommands = () => {
relayUrls, relayUrls,
pubkey, pubkey,
eventId, eventId,
kind,
reactionTypes, reactionTypes,
notifyPubkey, notifyPubkey,
}: { }: {
relayUrls: string[]; relayUrls: string[];
pubkey: string; pubkey: string;
eventId: string; eventId: string;
kind: number;
reactionTypes: ReactionTypes; reactionTypes: ReactionTypes;
notifyPubkey: string; notifyPubkey: string;
}): Promise<Promise<void>[]> => { }): Promise<Promise<void>[]> => {
const tags = [ const tags = [
['e', eventId, ''], ['e', eventId, ''],
['p', notifyPubkey], ['p', notifyPubkey],
['k', kind.toString()],
]; ];
if (reactionTypes.type === 'CustomEmoji') { if (reactionTypes.type === 'CustomEmoji') {
@@ -156,20 +159,23 @@ const useCommands = () => {
relayUrls, relayUrls,
pubkey, pubkey,
eventId, eventId,
kind,
notifyPubkey, notifyPubkey,
}: { }: {
relayUrls: string[]; relayUrls: string[];
pubkey: string; pubkey: string;
eventId: string; eventId: string;
kind: number;
notifyPubkey: string; notifyPubkey: string;
}): Promise<Promise<void>[]> => { }): Promise<Promise<void>[]> => {
const preSignedEvent: UnsignedEvent = { const preSignedEvent: UnsignedEvent = {
kind: 6 as Kind, kind: kind === 1 ? Kind.Repost : 16 /* generic repost */,
pubkey, pubkey,
created_at: epoch(), created_at: epoch(),
tags: [ tags: [
['e', eventId, ''], ['e', eventId, ''],
['p', notifyPubkey], ['p', notifyPubkey],
['k', kind.toString()],
], ],
content: '', content: '',
}; };