feat: emoji reactions
This commit is contained in:
@@ -67,7 +67,7 @@ export const EmbeddedNormalUrlParser: TContentParser = {
|
||||
|
||||
export const EmbeddedEmojiParser: TContentParser = {
|
||||
type: 'emoji',
|
||||
regex: /:[a-zA-Z0-9_]+:/g
|
||||
regex: /:[a-zA-Z0-9_-]+:/g
|
||||
}
|
||||
|
||||
export function parseContent(content: string, parsers: TContentParser[]) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ApplicationDataKey, ExtendedKind } from '@/constants'
|
||||
import client from '@/services/client.service'
|
||||
import { TDraftEvent, TMailboxRelay, TRelaySet } from '@/types'
|
||||
import { TDraftEvent, TEmoji, TMailboxRelay, TRelaySet } from '@/types'
|
||||
import dayjs from 'dayjs'
|
||||
import { Event, kinds } from 'nostr-tools'
|
||||
import {
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
} from './event'
|
||||
|
||||
// https://github.com/nostr-protocol/nips/blob/master/25.md
|
||||
export function createReactionDraftEvent(event: Event): TDraftEvent {
|
||||
export function createReactionDraftEvent(event: Event, emoji: TEmoji | string = '+'): TDraftEvent {
|
||||
const tags: string[][] = []
|
||||
const hint = client.getEventHint(event.id)
|
||||
tags.push(['e', event.id, hint, event.pubkey])
|
||||
@@ -27,9 +27,17 @@ export function createReactionDraftEvent(event: Event): TDraftEvent {
|
||||
tags.push(hint ? ['a', getEventCoordinate(event), hint] : ['a', getEventCoordinate(event)])
|
||||
}
|
||||
|
||||
let content: string
|
||||
if (typeof emoji === 'string') {
|
||||
content = emoji
|
||||
} else {
|
||||
content = `:${emoji.shortcode}:`
|
||||
tags.push(['emoji', emoji.shortcode, emoji.url])
|
||||
}
|
||||
|
||||
return {
|
||||
kind: kinds.Reaction,
|
||||
content: '+',
|
||||
content,
|
||||
tags,
|
||||
created_at: dayjs().unix()
|
||||
}
|
||||
|
||||
@@ -426,7 +426,8 @@ export function extractZapInfoFromReceipt(receiptEvent: Event) {
|
||||
let description: string | undefined
|
||||
let preimage: string | undefined
|
||||
try {
|
||||
receiptEvent.tags.forEach(([tagName, tagValue]) => {
|
||||
receiptEvent.tags.forEach((tag) => {
|
||||
const [tagName, tagValue] = tag
|
||||
switch (tagName) {
|
||||
case 'P':
|
||||
senderPubkey = tagValue
|
||||
@@ -435,7 +436,7 @@ export function extractZapInfoFromReceipt(receiptEvent: Event) {
|
||||
recipientPubkey = tagValue
|
||||
break
|
||||
case 'e':
|
||||
eventId = tagValue
|
||||
eventId = generateEventIdFromETag(tag)
|
||||
break
|
||||
case 'bolt11':
|
||||
invoice = tagValue
|
||||
|
||||
Reference in New Issue
Block a user