Skip to content

Commit

Permalink
fix isReply function
Browse files Browse the repository at this point in the history
  • Loading branch information
hzrd149 committed Dec 4, 2023
1 parent bc71d92 commit ab88415
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/helpers/nostr/events.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import dayjs from "dayjs";
import { nip19, validateEvent } from "nostr-tools";
import { Kind, nip19, validateEvent } from "nostr-tools";

import { ATag, DraftNostrEvent, isDTag, isETag, isPTag, NostrEvent, RTag, Tag } from "../../types/nostr-event";
import { RelayConfig, RelayMode } from "../../classes/relay";
import { getMatchNostrLink } from "../regexp";
import { AddressPointer } from "nostr-tools/lib/types/nip19";
import { safeJson } from "../parse";
import { getContentMentions } from "./post";

export function truncatedId(str: string, keep = 6) {
if (str.length < keep * 2 + 3) return str;
Expand All @@ -27,15 +25,18 @@ export function getEventUID(event: NostrEvent) {
}

export function isReply(event: NostrEvent | DraftNostrEvent) {
if (event.kind === Kind.Repost) return false;
return !!getReferences(event).replyId;
}
export function isMentionedInContent(event: NostrEvent | DraftNostrEvent, pubkey: string) {
return filterTagsByContentRefs(event.content, event.tags).some((t) => t[1] === pubkey);
}

export function isRepost(event: NostrEvent | DraftNostrEvent) {
if (event.kind === Kind.Repost) return true;

const match = event.content.match(getMatchNostrLink());
return event.kind === 6 || (match && match[0].length === event.content.length);
return match && match[0].length === event.content.length;
}

/**
Expand Down

0 comments on commit ab88415

Please sign in to comment.