remove the kind type parameter from events and filters.

This commit is contained in:
fiatjaf
2023-12-16 10:10:37 -03:00
parent 1939c46eaa
commit 6a07e7c1cc
21 changed files with 157 additions and 211 deletions

View File

@@ -1,4 +1,5 @@
import { Event, finishEvent, Kind } from './event.ts'
import { Event, finishEvent } from './event.ts'
import { Reaction } from './kinds.ts'
import type { EventPointer } from './nip19.ts'
@@ -16,17 +17,13 @@ export type ReactionEventTemplate = {
created_at: number
}
export function finishReactionEvent(
t: ReactionEventTemplate,
reacted: Event<number>,
privateKey: string,
): Event<Kind.Reaction> {
export function finishReactionEvent(t: ReactionEventTemplate, reacted: Event, privateKey: string): Event {
const inheritedTags = reacted.tags.filter(tag => tag.length >= 2 && (tag[0] === 'e' || tag[0] === 'p'))
return finishEvent(
{
...t,
kind: Kind.Reaction,
kind: Reaction,
tags: [...(t.tags ?? []), ...inheritedTags, ['e', reacted.id], ['p', reacted.pubkey]],
content: t.content ?? '+',
},
@@ -34,8 +31,8 @@ export function finishReactionEvent(
)
}
export function getReactedEventPointer(event: Event<number>): undefined | EventPointer {
if (event.kind !== Kind.Reaction) {
export function getReactedEventPointer(event: Event): undefined | EventPointer {
if (event.kind !== Reaction) {
return undefined
}