mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
Use uppercase tags for comment events
This commit is contained in:
1 parent
90e5c745d3
commit
5979d4e25f
8 files changed
+139
-219
No files matched your search
@@ -137,11 +137,10 @@ import { updateWatchHistoryListWithDefaultClient } from "./nostrWatchHistoryFaca
|
|||||||
| Video post (`NOTE_TYPES.VIDEO_POST`) | `30078` | `['t','video']`, `['d', <stable video identifier>]` plus optional schema append tags | JSON payload using Content Schema v3 (`version`, `title`, optional `url`, `magnet`, `thumbnail`, `description`, `mode`, `videoRootId`, `deleted`, `isPrivate`, `isNsfw`, `isForKids`, `enableComments`, `ws`, `xs`) |
|
| Video post (`NOTE_TYPES.VIDEO_POST`) | `30078` | `['t','video']`, `['d', <stable video identifier>]` plus optional schema append tags | JSON payload using Content Schema v3 (`version`, `title`, optional `url`, `magnet`, `thumbnail`, `description`, `mode`, `videoRootId`, `deleted`, `isPrivate`, `isNsfw`, `isForKids`, `enableComments`, `ws`, `xs`) |
|
||||||
| NIP-94 mirror (`NOTE_TYPES.VIDEO_MIRROR`) | `1063` | Tags forwarded from `publishVideo` (URL, mime type, thumbnail, alt text, magnet) | Plain text alt description |
|
| NIP-94 mirror (`NOTE_TYPES.VIDEO_MIRROR`) | `1063` | Tags forwarded from `publishVideo` (URL, mime type, thumbnail, alt text, magnet) | Plain text alt description |
|
||||||
| Repost (`NOTE_TYPES.REPOST`) | `6` | `['e', <event id>, <relay?>]` with optional address pointer `['a', <kind:pubkey:identifier>, <relay?>]`, and `['p', <pubkey>]` when the origin author is known; inherits schema append tags | Empty content |
|
| Repost (`NOTE_TYPES.REPOST`) | `6` | `['e', <event id>, <relay?>]` with optional address pointer `['a', <kind:pubkey:identifier>, <relay?>]`, and `['p', <pubkey>]` when the origin author is known; inherits schema append tags | Empty content |
|
||||||
| Video comment (`NOTE_TYPES.VIDEO_COMMENT`) | `1111` | NIP-22 root scope tags `['A'\|`E`\|`I`, <pointer>, <relay?>?], `['K', <root kind>]`, and `['P', <root author pubkey>, <relay?>?]` plus parent metadata `['a'\|`e`\|`i`, <parent pointer>, <relay?>?, <author?>], `['k', <parent kind>]`, `['p', <parent author>, <relay?>?]`; builder retains legacy lowercase fallbacks (`['a', ...]`/`['e', ...]`/`['p', ...]`) alongside the uppercase set for compatibility; inherits schema append tags | Plain text body sanitized to valid UTF-8 |
|
| Video comment (`NOTE_TYPES.VIDEO_COMMENT`) | `1111` | NIP-22 root scope tags `['A'\|`E`\|`I`, <pointer>, <relay?>?], `['K', <root kind>]`, and `['P', <root author pubkey>, <relay?>?]` plus parent metadata `['E'\|`I`, <parent pointer>, <relay?>?, <author?>], `['K', <parent kind>]`, `['P', <parent author>, <relay?>?]`; inherits schema append tags | Plain text body sanitized to valid UTF-8 |
|
||||||
|
|
||||||
> **Publishing note:** Session actors only emit passive telemetry (for example, view counters) and must **not** sign video comments. Require a logged-in Nostr signer for comment publishing via [`commentEvents`](../js/nostr/commentEvents.js).
|
> **Publishing note:** Session actors only emit passive telemetry (for example, view counters) and must **not** sign video comments. Require a logged-in Nostr signer for comment publishing via [`commentEvents`](../js/nostr/commentEvents.js).
|
||||||
|
|
||||||
> **Compatibility tip:** When a comment anchors itself to a video definition address, emit both the uppercase root pointer and a legacy `['e', <root event id>]` tag. This mirrors the [NIP-22 addressable events example](./nips/22.md#addressable-events) so clients that only understand `#e` tags can still follow the thread.
|
|
||||||
| NIP-71 video (`NOTE_TYPES.NIP71_VIDEO`) | `21` | `['title', <title>]`, optional `['published_at', <unix seconds>]`, optional `['alt', <text>]`, repeated `['imeta', ...]` entries describing NIP-92 media variants, optional `['duration', <seconds>]`, repeated `['text-track', <url>, <kind>, <language>]`, optional `['content-warning', <reason>]`, repeated `['segment', <start>, <end>, <title>, <thumbnail>]`, repeated hashtags `['t', <tag>]`, repeated participants `['p', <pubkey>, <relay?>]`, repeated references `['r', <url>]` | Plain text summary carried in the content field. Publishing is gated by the `FEATURE_PUBLISH_NIP71` runtime flag while the rollout stabilizes. |
|
| NIP-71 video (`NOTE_TYPES.NIP71_VIDEO`) | `21` | `['title', <title>]`, optional `['published_at', <unix seconds>]`, optional `['alt', <text>]`, repeated `['imeta', ...]` entries describing NIP-92 media variants, optional `['duration', <seconds>]`, repeated `['text-track', <url>, <kind>, <language>]`, optional `['content-warning', <reason>]`, repeated `['segment', <start>, <end>, <title>, <thumbnail>]`, repeated hashtags `['t', <tag>]`, repeated participants `['p', <pubkey>, <relay?>]`, repeated references `['r', <url>]` | Plain text summary carried in the content field. Publishing is gated by the `FEATURE_PUBLISH_NIP71` runtime flag while the rollout stabilizes. |
|
||||||
| NIP-71 short video (`NOTE_TYPES.NIP71_SHORT_VIDEO`) | `22` | Same as `NOTE_TYPES.NIP71_VIDEO`; the kind differentiates short-form presentations. | Plain text summary; gated by `FEATURE_PUBLISH_NIP71`. |
|
| NIP-71 short video (`NOTE_TYPES.NIP71_SHORT_VIDEO`) | `22` | Same as `NOTE_TYPES.NIP71_VIDEO`; the kind differentiates short-form presentations. | Plain text summary; gated by `FEATURE_PUBLISH_NIP71`. |
|
||||||
| Relay list (`NOTE_TYPES.RELAY_LIST`) | `10002` | Repeating `['r', <relay url>]` tags, optionally with a marker of `'read'` or `'write'` to scope the relay; marker omitted for read/write relays | Empty content |
|
| Relay list (`NOTE_TYPES.RELAY_LIST`) | `10002` | Repeating `['r', <relay url>]` tags, optionally with a marker of `'read'` or `'write'` to scope the relay; marker omitted for read/write relays | Empty content |
|
||||||
|
|||||||
+27
-86
@@ -799,16 +799,10 @@ function createVideoCommentFilters(targetInput, options = {}) {
|
|||||||
const filters = [];
|
const filters = [];
|
||||||
|
|
||||||
const eventFilter = {
|
const eventFilter = {
|
||||||
kinds: getAllowedCommentKinds(),
|
|
||||||
"#e": [descriptor.videoEventId],
|
|
||||||
};
|
|
||||||
filters.push(applyFilterOptions(eventFilter, options));
|
|
||||||
|
|
||||||
const uppercaseEventFilter = {
|
|
||||||
kinds: getAllowedCommentKinds(),
|
kinds: getAllowedCommentKinds(),
|
||||||
"#E": [descriptor.videoEventId],
|
"#E": [descriptor.videoEventId],
|
||||||
};
|
};
|
||||||
filters.push(applyFilterOptions(uppercaseEventFilter, options));
|
filters.push(applyFilterOptions(eventFilter, options));
|
||||||
|
|
||||||
const uppercaseFilter = { kinds: getAllowedCommentKinds() };
|
const uppercaseFilter = { kinds: getAllowedCommentKinds() };
|
||||||
let hasUppercasePointer = false;
|
let hasUppercasePointer = false;
|
||||||
@@ -817,12 +811,6 @@ function createVideoCommentFilters(targetInput, options = {}) {
|
|||||||
uppercaseFilter["#I"] = [descriptor.rootIdentifier];
|
uppercaseFilter["#I"] = [descriptor.rootIdentifier];
|
||||||
hasUppercasePointer = true;
|
hasUppercasePointer = true;
|
||||||
|
|
||||||
const lowercaseRootFilter = {
|
|
||||||
kinds: getAllowedCommentKinds(),
|
|
||||||
"#i": [descriptor.rootIdentifier],
|
|
||||||
};
|
|
||||||
|
|
||||||
filters.push(applyFilterOptions(lowercaseRootFilter, options));
|
|
||||||
} else if (
|
} else if (
|
||||||
typeof descriptor.videoDefinitionAddress === "string" &&
|
typeof descriptor.videoDefinitionAddress === "string" &&
|
||||||
descriptor.videoDefinitionAddress
|
descriptor.videoDefinitionAddress
|
||||||
@@ -859,12 +847,6 @@ function createVideoCommentFilters(targetInput, options = {}) {
|
|||||||
descriptor.parentCommentId &&
|
descriptor.parentCommentId &&
|
||||||
descriptor.parentCommentId !== descriptor.videoEventId
|
descriptor.parentCommentId !== descriptor.videoEventId
|
||||||
) {
|
) {
|
||||||
const parentFilter = {
|
|
||||||
kinds: getAllowedCommentKinds(),
|
|
||||||
"#e": [descriptor.parentCommentId],
|
|
||||||
};
|
|
||||||
filters.push(applyFilterOptions(parentFilter, options));
|
|
||||||
|
|
||||||
const parentUppercaseFilter = {
|
const parentUppercaseFilter = {
|
||||||
kinds: getAllowedCommentKinds(),
|
kinds: getAllowedCommentKinds(),
|
||||||
"#E": [descriptor.parentCommentId],
|
"#E": [descriptor.parentCommentId],
|
||||||
@@ -873,17 +855,6 @@ function createVideoCommentFilters(targetInput, options = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (descriptor.videoDefinitionAddress) {
|
if (descriptor.videoDefinitionAddress) {
|
||||||
const definitionFilter = {
|
|
||||||
kinds: getAllowedCommentKinds(),
|
|
||||||
"#a": [descriptor.videoDefinitionAddress],
|
|
||||||
};
|
|
||||||
|
|
||||||
if (descriptor.parentCommentId) {
|
|
||||||
definitionFilter["#e"] = [descriptor.parentCommentId];
|
|
||||||
}
|
|
||||||
|
|
||||||
filters.push(applyFilterOptions(definitionFilter, options));
|
|
||||||
|
|
||||||
const definitionUppercaseFilter = {
|
const definitionUppercaseFilter = {
|
||||||
kinds: getAllowedCommentKinds(),
|
kinds: getAllowedCommentKinds(),
|
||||||
"#A": [descriptor.videoDefinitionAddress],
|
"#A": [descriptor.videoDefinitionAddress],
|
||||||
@@ -976,21 +947,8 @@ function isVideoCommentEvent(event, descriptor) {
|
|||||||
targetDescriptor.parentAuthorPubkey,
|
targetDescriptor.parentAuthorPubkey,
|
||||||
);
|
);
|
||||||
|
|
||||||
let sawRootKindTag = false;
|
const kindTagValues = [];
|
||||||
let rootKindMatches = !expectedRootKind;
|
const authorTagValues = [];
|
||||||
let rootKindMismatch = false;
|
|
||||||
|
|
||||||
let sawRootAuthorTag = false;
|
|
||||||
let rootAuthorMatches = !expectedRootAuthor;
|
|
||||||
let rootAuthorMismatch = false;
|
|
||||||
|
|
||||||
let sawParentKindTag = false;
|
|
||||||
let parentKindMatches = !expectedParentKind;
|
|
||||||
let parentKindMismatch = false;
|
|
||||||
|
|
||||||
let sawParentAuthorTag = false;
|
|
||||||
let parentAuthorMatches = !expectedParentAuthor;
|
|
||||||
let parentAuthorMismatch = false;
|
|
||||||
|
|
||||||
for (const tag of tags) {
|
for (const tag of tags) {
|
||||||
if (!Array.isArray(tag) || tag.length < 2) {
|
if (!Array.isArray(tag) || tag.length < 2) {
|
||||||
@@ -998,20 +956,20 @@ function isVideoCommentEvent(event, descriptor) {
|
|||||||
}
|
}
|
||||||
const [rawName, rawValue] = tag;
|
const [rawName, rawValue] = tag;
|
||||||
const trimmedName = typeof rawName === "string" ? rawName.trim() : "";
|
const trimmedName = typeof rawName === "string" ? rawName.trim() : "";
|
||||||
const lowerName = trimmedName.toLowerCase();
|
const upperName = trimmedName.toUpperCase();
|
||||||
const normalizedValue = normalizeTagValue(rawValue);
|
const normalizedValue = normalizeTagValue(rawValue);
|
||||||
if (!lowerName || !normalizedValue) {
|
if (!upperName || !normalizedValue) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lowerName === "i") {
|
if (upperName === "I") {
|
||||||
if (
|
if (
|
||||||
normalizedRootIdentifier &&
|
normalizedRootIdentifier &&
|
||||||
normalizedValue === normalizedRootIdentifier
|
normalizedValue === normalizedRootIdentifier
|
||||||
) {
|
) {
|
||||||
hasIdentifierTag = true;
|
hasIdentifierTag = true;
|
||||||
}
|
}
|
||||||
} else if (lowerName === "a") {
|
} else if (upperName === "A") {
|
||||||
if (
|
if (
|
||||||
normalizedVideoDefinitionAddress &&
|
normalizedVideoDefinitionAddress &&
|
||||||
normalizedValue === normalizedVideoDefinitionAddress
|
normalizedValue === normalizedVideoDefinitionAddress
|
||||||
@@ -1019,7 +977,7 @@ function isVideoCommentEvent(event, descriptor) {
|
|||||||
hasDefinitionTag = true;
|
hasDefinitionTag = true;
|
||||||
matchedDefinitionPointer = true;
|
matchedDefinitionPointer = true;
|
||||||
}
|
}
|
||||||
} else if (lowerName === "e") {
|
} else if (upperName === "E") {
|
||||||
if (
|
if (
|
||||||
normalizedVideoEventId &&
|
normalizedVideoEventId &&
|
||||||
normalizedValue === normalizedVideoEventId
|
normalizedValue === normalizedVideoEventId
|
||||||
@@ -1033,37 +991,28 @@ function isVideoCommentEvent(event, descriptor) {
|
|||||||
) {
|
) {
|
||||||
hasParentTag = true;
|
hasParentTag = true;
|
||||||
}
|
}
|
||||||
} else if (trimmedName === "K") {
|
} else if (upperName === "K") {
|
||||||
sawRootKindTag = true;
|
kindTagValues.push(normalizedValue);
|
||||||
if (!expectedRootKind || normalizedValue === expectedRootKind) {
|
} else if (upperName === "P") {
|
||||||
rootKindMatches = true;
|
authorTagValues.push(normalizedValue);
|
||||||
} else {
|
|
||||||
rootKindMismatch = true;
|
|
||||||
}
|
|
||||||
} else if (trimmedName === "P") {
|
|
||||||
sawRootAuthorTag = true;
|
|
||||||
if (!expectedRootAuthor || normalizedValue === expectedRootAuthor) {
|
|
||||||
rootAuthorMatches = true;
|
|
||||||
} else {
|
|
||||||
rootAuthorMismatch = true;
|
|
||||||
}
|
|
||||||
} else if (trimmedName === "k") {
|
|
||||||
sawParentKindTag = true;
|
|
||||||
if (!expectedParentKind || normalizedValue === expectedParentKind) {
|
|
||||||
parentKindMatches = true;
|
|
||||||
} else {
|
|
||||||
parentKindMismatch = true;
|
|
||||||
}
|
|
||||||
} else if (trimmedName === "p") {
|
|
||||||
sawParentAuthorTag = true;
|
|
||||||
if (!expectedParentAuthor || normalizedValue === expectedParentAuthor) {
|
|
||||||
parentAuthorMatches = true;
|
|
||||||
} else {
|
|
||||||
parentAuthorMismatch = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const sawRootKindTag = kindTagValues.length > 0 && Boolean(expectedRootKind);
|
||||||
|
const sawRootAuthorTag = authorTagValues.length > 0 && Boolean(expectedRootAuthor);
|
||||||
|
const sawParentKindTag = kindTagValues.length > 0 && Boolean(expectedParentKind);
|
||||||
|
const sawParentAuthorTag =
|
||||||
|
authorTagValues.length > 0 && Boolean(expectedParentAuthor);
|
||||||
|
|
||||||
|
const rootKindMatches =
|
||||||
|
!expectedRootKind || kindTagValues.includes(expectedRootKind);
|
||||||
|
const rootAuthorMatches =
|
||||||
|
!expectedRootAuthor || authorTagValues.includes(expectedRootAuthor);
|
||||||
|
const parentKindMatches =
|
||||||
|
!expectedParentKind || kindTagValues.includes(expectedParentKind);
|
||||||
|
const parentAuthorMatches =
|
||||||
|
!expectedParentAuthor || authorTagValues.includes(expectedParentAuthor);
|
||||||
|
|
||||||
if (!hasDefinitionTag && requiresAddressMatch && matchedEventPointer) {
|
if (!hasDefinitionTag && requiresAddressMatch && matchedEventPointer) {
|
||||||
hasDefinitionTag = true;
|
hasDefinitionTag = true;
|
||||||
}
|
}
|
||||||
@@ -1107,14 +1056,6 @@ function isVideoCommentEvent(event, descriptor) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((sawRootKindTag && rootKindMismatch) || (sawRootAuthorTag && rootAuthorMismatch)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((sawParentKindTag && parentKindMismatch) || (sawParentAuthorTag && parentAuthorMismatch)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sawRootKindTag && expectedRootKind && !rootKindMatches) {
|
if (sawRootKindTag && expectedRootKind && !rootKindMatches) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-11
@@ -334,16 +334,16 @@ const BASE_SCHEMAS = {
|
|||||||
type: NOTE_TYPES.VIDEO_COMMENT,
|
type: NOTE_TYPES.VIDEO_COMMENT,
|
||||||
label: "Video comment",
|
label: "Video comment",
|
||||||
kind: 1111,
|
kind: 1111,
|
||||||
videoEventTagName: "e",
|
videoEventTagName: "E",
|
||||||
videoDefinitionTagName: "a",
|
videoDefinitionTagName: "A",
|
||||||
parentCommentTagName: "e",
|
parentCommentTagName: "E",
|
||||||
parentAuthorTagName: "p",
|
parentAuthorTagName: "P",
|
||||||
rootEventPointerTagName: "E",
|
rootEventPointerTagName: "E",
|
||||||
rootDefinitionPointerTagName: "A",
|
rootDefinitionPointerTagName: "A",
|
||||||
rootIdentifierPointerTagName: "I",
|
rootIdentifierPointerTagName: "I",
|
||||||
rootKindTagName: "K",
|
rootKindTagName: "K",
|
||||||
rootAuthorTagName: "P",
|
rootAuthorTagName: "P",
|
||||||
parentKindTagName: "k",
|
parentKindTagName: "K",
|
||||||
appendTags: DEFAULT_APPEND_TAGS,
|
appendTags: DEFAULT_APPEND_TAGS,
|
||||||
content: {
|
content: {
|
||||||
format: "text",
|
format: "text",
|
||||||
@@ -1199,11 +1199,12 @@ export function buildCommentEvent({
|
|||||||
const rootIdentifierPointerTagName = schema?.rootIdentifierPointerTagName || "I";
|
const rootIdentifierPointerTagName = schema?.rootIdentifierPointerTagName || "I";
|
||||||
const rootKindTagName = schema?.rootKindTagName || "K";
|
const rootKindTagName = schema?.rootKindTagName || "K";
|
||||||
const rootAuthorTagName = schema?.rootAuthorTagName || "P";
|
const rootAuthorTagName = schema?.rootAuthorTagName || "P";
|
||||||
const videoDefinitionTagName = schema?.videoDefinitionTagName || "a";
|
const parentIdentifierTagName = schema?.parentIdentifierTagName || "I";
|
||||||
const videoEventTagName = schema?.videoEventTagName || "e";
|
const videoDefinitionTagName = schema?.videoDefinitionTagName || "A";
|
||||||
const parentCommentTagName = schema?.parentCommentTagName || "e";
|
const videoEventTagName = schema?.videoEventTagName || "E";
|
||||||
const parentAuthorTagName = schema?.parentAuthorTagName || "p";
|
const parentCommentTagName = schema?.parentCommentTagName || "E";
|
||||||
const parentKindTagName = schema?.parentKindTagName || "k";
|
const parentAuthorTagName = schema?.parentAuthorTagName || "P";
|
||||||
|
const parentKindTagName = schema?.parentKindTagName || "K";
|
||||||
|
|
||||||
const appendPointerTag = (tagName, value, relay, authorHint) => {
|
const appendPointerTag = (tagName, value, relay, authorHint) => {
|
||||||
if (!tagName || !value) {
|
if (!tagName || !value) {
|
||||||
@@ -1272,7 +1273,11 @@ export function buildCommentEvent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (normalizedParentIdentifier) {
|
if (normalizedParentIdentifier) {
|
||||||
appendPointerTag("i", normalizedParentIdentifier, normalizedParentIdentifierRelay);
|
appendPointerTag(
|
||||||
|
parentIdentifierTagName,
|
||||||
|
normalizedParentIdentifier,
|
||||||
|
normalizedParentIdentifierRelay,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parentCommentTagName && normalizedParentCommentId) {
|
if (parentCommentTagName && normalizedParentCommentId) {
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ export default class DiscussionCountService {
|
|||||||
const filters = [];
|
const filters = [];
|
||||||
const eventId = typeof video.id === "string" ? video.id.trim() : "";
|
const eventId = typeof video.id === "string" ? video.id.trim() : "";
|
||||||
if (eventId) {
|
if (eventId) {
|
||||||
filters.push({ kinds: [COMMENT_EVENT_KIND], "#e": [eventId] });
|
filters.push({ kinds: [COMMENT_EVENT_KIND], "#E": [eventId] });
|
||||||
}
|
}
|
||||||
|
|
||||||
const address = buildVideoAddressPointer(video);
|
const address = buildVideoAddressPointer(video);
|
||||||
@@ -181,7 +181,7 @@ export default class DiscussionCountService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (address) {
|
if (address) {
|
||||||
filters.push({ kinds: [COMMENT_EVENT_KIND], "#a": [address] });
|
filters.push({ kinds: [COMMENT_EVENT_KIND], "#A": [address] });
|
||||||
}
|
}
|
||||||
|
|
||||||
return filters;
|
return filters;
|
||||||
|
|||||||
@@ -48,10 +48,9 @@ test("buildCommentEvent emits NIP-22 root metadata while keeping legacy fallback
|
|||||||
["A", "30078:deadbeefcafebabe:clip-1"],
|
["A", "30078:deadbeefcafebabe:clip-1"],
|
||||||
["K", "30078"],
|
["K", "30078"],
|
||||||
["P", "deadbeefcafebabe"],
|
["P", "deadbeefcafebabe"],
|
||||||
["e", "video-event-id"],
|
["E", "video-event-id"],
|
||||||
["a", "30078:deadbeefcafebabe:clip-1"],
|
["A", "30078:deadbeefcafebabe:clip-1"],
|
||||||
["k", "30078"],
|
["K", "30078"],
|
||||||
["p", "deadbeefcafebabe"],
|
|
||||||
]);
|
]);
|
||||||
assert.equal(event.content, "Great video!");
|
assert.equal(event.content, "Great video!");
|
||||||
});
|
});
|
||||||
@@ -72,11 +71,11 @@ test("buildCommentEvent includes parent pointers, kinds, and authors for replies
|
|||||||
["A", "30078:deadbeefcafebabe:clip-1"],
|
["A", "30078:deadbeefcafebabe:clip-1"],
|
||||||
["K", "30078"],
|
["K", "30078"],
|
||||||
["P", "deadbeefcafebabe"],
|
["P", "deadbeefcafebabe"],
|
||||||
["e", "video-event-id"],
|
["E", "video-event-id"],
|
||||||
["a", "30078:deadbeefcafebabe:clip-1"],
|
["A", "30078:deadbeefcafebabe:clip-1"],
|
||||||
["e", "parent-comment-id", "parent-author"],
|
["E", "parent-comment-id", "parent-author"],
|
||||||
["k", String(VIDEO_COMMENT_KIND)],
|
["K", String(VIDEO_COMMENT_KIND)],
|
||||||
["p", "parent-author"],
|
["P", "parent-author"],
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -101,11 +100,11 @@ test("buildCommentEvent normalizes relays and preserves explicit overrides", ()
|
|||||||
["A", "30078:deadbeefcafebabe:clip-2", "wss://video.def"],
|
["A", "30078:deadbeefcafebabe:clip-2", "wss://video.def"],
|
||||||
["K", "30078"],
|
["K", "30078"],
|
||||||
["P", "deadbeefcafebabe", "wss://video.def"],
|
["P", "deadbeefcafebabe", "wss://video.def"],
|
||||||
["e", "event123", "wss://comments.main"],
|
["E", "event123", "wss://comments.main"],
|
||||||
["a", "30078:deadbeefcafebabe:clip-2", "wss://video.def"],
|
["A", "30078:deadbeefcafebabe:clip-2", "wss://video.def"],
|
||||||
["e", "root-comment", "wss://parent", "cafecafe"],
|
["E", "root-comment", "wss://parent", "cafecafe"],
|
||||||
["k", String(VIDEO_COMMENT_KIND)],
|
["K", String(VIDEO_COMMENT_KIND)],
|
||||||
["p", "cafecafe", "wss://profile"],
|
["P", "cafecafe", "wss://profile"],
|
||||||
["client", "bitvid"],
|
["client", "bitvid"],
|
||||||
]);
|
]);
|
||||||
assert.equal(event.content, " Appreciated! ");
|
assert.equal(event.content, " Appreciated! ");
|
||||||
@@ -128,9 +127,9 @@ test("buildCommentEvent falls back to event pointers when no address is supplied
|
|||||||
["E", "legacy-event", "wss://legacy.example", "legacy-author"],
|
["E", "legacy-event", "wss://legacy.example", "legacy-author"],
|
||||||
["K", "1063"],
|
["K", "1063"],
|
||||||
["P", "legacy-author"],
|
["P", "legacy-author"],
|
||||||
["e", "legacy-event", "wss://legacy.example"],
|
["E", "legacy-event", "wss://legacy.example"],
|
||||||
["k", "1063"],
|
["K", "1063"],
|
||||||
["p", "legacy-pubkey"],
|
["P", "legacy-pubkey"],
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -152,10 +151,10 @@ test("buildCommentEvent accepts partial metadata for parent overrides", () => {
|
|||||||
assert.deepStrictEqual(event.tags, [
|
assert.deepStrictEqual(event.tags, [
|
||||||
["E", "file-event"],
|
["E", "file-event"],
|
||||||
["K", "1063"],
|
["K", "1063"],
|
||||||
["e", "file-event"],
|
["E", "file-event"],
|
||||||
["e", "parent-comment", "wss://parent", "parent-only"],
|
["E", "parent-comment", "wss://parent", "parent-only"],
|
||||||
["k", "1111"],
|
["K", "1111"],
|
||||||
["p", "parent-only", "wss://parent-author"],
|
["P", "parent-only", "wss://parent-author"],
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -608,18 +608,18 @@ test(
|
|||||||
topLevelEvent.tags.some(
|
topLevelEvent.tags.some(
|
||||||
(tag) =>
|
(tag) =>
|
||||||
Array.isArray(tag) &&
|
Array.isArray(tag) &&
|
||||||
tag[0] === "e" &&
|
tag[0] === "E" &&
|
||||||
tag[1] === videoEventId &&
|
tag[1] === videoEventId &&
|
||||||
tag[2] === relayUrl,
|
tag[2] === relayUrl,
|
||||||
),
|
),
|
||||||
"builder should retain legacy #e tag for the root event when address pointer is present",
|
"builder should retain uppercase #E tag for the root event when address pointer is present",
|
||||||
);
|
);
|
||||||
assert.ok(
|
assert.ok(
|
||||||
topLevelEvent.tags.some(
|
topLevelEvent.tags.some(
|
||||||
(tag) =>
|
(tag) =>
|
||||||
Array.isArray(tag) && tag[0] === "a" && tag[1] === videoDefinitionAddress,
|
Array.isArray(tag) && tag[0] === "A" && tag[1] === videoDefinitionAddress,
|
||||||
),
|
),
|
||||||
"builder should include #a pointer for the scoped video definition",
|
"builder should include #A pointer for the scoped video definition",
|
||||||
);
|
);
|
||||||
|
|
||||||
const replyEvent = {
|
const replyEvent = {
|
||||||
@@ -645,18 +645,18 @@ test(
|
|||||||
replyEvent.tags.some(
|
replyEvent.tags.some(
|
||||||
(tag) =>
|
(tag) =>
|
||||||
Array.isArray(tag) &&
|
Array.isArray(tag) &&
|
||||||
tag[0] === "e" &&
|
tag[0] === "E" &&
|
||||||
tag[1] === videoEventId &&
|
tag[1] === videoEventId &&
|
||||||
tag[2] === relayUrl,
|
tag[2] === relayUrl,
|
||||||
),
|
),
|
||||||
"reply builder should include root #e tag alongside #a pointer",
|
"reply builder should include root #E tag alongside #A pointer",
|
||||||
);
|
);
|
||||||
assert.ok(
|
assert.ok(
|
||||||
replyEvent.tags.some(
|
replyEvent.tags.some(
|
||||||
(tag) =>
|
(tag) =>
|
||||||
Array.isArray(tag) && tag[0] === "a" && tag[1] === videoDefinitionAddress,
|
Array.isArray(tag) && tag[0] === "A" && tag[1] === videoDefinitionAddress,
|
||||||
),
|
),
|
||||||
"reply builder should preserve #a pointer",
|
"reply builder should preserve #A pointer",
|
||||||
);
|
);
|
||||||
|
|
||||||
const listCalls = [];
|
const listCalls = [];
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ async function testRefreshCountsCachesResults() {
|
|||||||
const [eventFilter, uppercaseFilter, addressFilter] = filters;
|
const [eventFilter, uppercaseFilter, addressFilter] = filters;
|
||||||
assert.deepEqual(eventFilter, {
|
assert.deepEqual(eventFilter, {
|
||||||
kinds: [COMMENT_EVENT_KIND],
|
kinds: [COMMENT_EVENT_KIND],
|
||||||
"#e": ["count-video-1"],
|
"#E": ["count-video-1"],
|
||||||
});
|
});
|
||||||
assert.deepEqual(uppercaseFilter, {
|
assert.deepEqual(uppercaseFilter, {
|
||||||
kinds: [COMMENT_EVENT_KIND],
|
kinds: [COMMENT_EVENT_KIND],
|
||||||
@@ -50,7 +50,7 @@ async function testRefreshCountsCachesResults() {
|
|||||||
});
|
});
|
||||||
assert.deepEqual(addressFilter, {
|
assert.deepEqual(addressFilter, {
|
||||||
kinds: [COMMENT_EVENT_KIND],
|
kinds: [COMMENT_EVENT_KIND],
|
||||||
"#a": ["30078:pubkey-1:identifier-1"],
|
"#A": ["30078:pubkey-1:identifier-1"],
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
total: 5,
|
total: 5,
|
||||||
@@ -123,7 +123,7 @@ async function testUnsupportedRelaysUpdateDomState() {
|
|||||||
const [eventFilter, uppercaseFilter, addressFilter] = filters;
|
const [eventFilter, uppercaseFilter, addressFilter] = filters;
|
||||||
assert.deepEqual(eventFilter, {
|
assert.deepEqual(eventFilter, {
|
||||||
kinds: [COMMENT_EVENT_KIND],
|
kinds: [COMMENT_EVENT_KIND],
|
||||||
"#e": ["unsupported-video"],
|
"#E": ["unsupported-video"],
|
||||||
});
|
});
|
||||||
assert.deepEqual(uppercaseFilter, {
|
assert.deepEqual(uppercaseFilter, {
|
||||||
kinds: [COMMENT_EVENT_KIND],
|
kinds: [COMMENT_EVENT_KIND],
|
||||||
@@ -133,7 +133,7 @@ async function testUnsupportedRelaysUpdateDomState() {
|
|||||||
});
|
});
|
||||||
assert.deepEqual(addressFilter, {
|
assert.deepEqual(addressFilter, {
|
||||||
kinds: [COMMENT_EVENT_KIND],
|
kinds: [COMMENT_EVENT_KIND],
|
||||||
"#a": ["30078:pubkey-2:identifier-2"],
|
"#A": ["30078:pubkey-2:identifier-2"],
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
total: 7,
|
total: 7,
|
||||||
|
|||||||
@@ -118,13 +118,13 @@ test("publishComment prefers active signer when available", async () => {
|
|||||||
["A", "30078:deadbeef:clip", "wss://definition-relay"],
|
["A", "30078:deadbeef:clip", "wss://definition-relay"],
|
||||||
["K", "30078"],
|
["K", "30078"],
|
||||||
["P", "deadbeef", "wss://definition-relay"],
|
["P", "deadbeef", "wss://definition-relay"],
|
||||||
["e", "video-event-id", "wss://video-relay"],
|
["E", "video-event-id", "wss://video-relay"],
|
||||||
["a", "30078:deadbeef:clip", "wss://definition-relay"],
|
["A", "30078:deadbeef:clip", "wss://definition-relay"],
|
||||||
["e", "parent-comment-id", "thread-participant"],
|
["E", "parent-comment-id", "thread-participant"],
|
||||||
["k", String(COMMENT_EVENT_KIND)],
|
["K", String(COMMENT_EVENT_KIND)],
|
||||||
["p", "thread-participant"],
|
["P", "thread-participant"],
|
||||||
],
|
],
|
||||||
"comment event should include NIP-22 root tags while preserving fallback markers",
|
"comment event should include uppercase pointers and participant metadata",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -193,9 +193,9 @@ test("publishComment accepts legacy targets with only an event id", async () =>
|
|||||||
[
|
[
|
||||||
["E", "legacy-event-id"],
|
["E", "legacy-event-id"],
|
||||||
["K", String(COMMENT_EVENT_KIND)],
|
["K", String(COMMENT_EVENT_KIND)],
|
||||||
["e", "legacy-event-id"],
|
["E", "legacy-event-id"],
|
||||||
["e", "parent-legacy"],
|
["E", "parent-legacy"],
|
||||||
["k", String(COMMENT_EVENT_KIND)],
|
["K", String(COMMENT_EVENT_KIND)],
|
||||||
],
|
],
|
||||||
"legacy publish should emit uppercase root metadata with lowercase fallbacks",
|
"legacy publish should emit uppercase root metadata with lowercase fallbacks",
|
||||||
);
|
);
|
||||||
@@ -213,10 +213,10 @@ test("publishComment derives root and parent metadata from parent comment tags",
|
|||||||
["K", "30078"],
|
["K", "30078"],
|
||||||
["P", "videopk", "wss://author"],
|
["P", "videopk", "wss://author"],
|
||||||
["A", "30078:videopk:root", "wss://definition"],
|
["A", "30078:videopk:root", "wss://definition"],
|
||||||
["e", "video-event", "wss://root"],
|
["E", "video-event", "wss://root"],
|
||||||
["e", "parent-comment", "wss://parent", "parentpk"],
|
["E", "parent-comment", "wss://parent", "parentpk"],
|
||||||
["k", String(COMMENT_EVENT_KIND)],
|
["K", String(COMMENT_EVENT_KIND)],
|
||||||
["p", "parentpk", "wss://parent"],
|
["P", "parentpk", "wss://parent"],
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -240,11 +240,11 @@ test("publishComment derives root and parent metadata from parent comment tags",
|
|||||||
["A", "30078:videopk:root", "wss://definition"],
|
["A", "30078:videopk:root", "wss://definition"],
|
||||||
["K", "30078"],
|
["K", "30078"],
|
||||||
["P", "videopk", "wss://author"],
|
["P", "videopk", "wss://author"],
|
||||||
["e", "video-event", "wss://root"],
|
["E", "video-event", "wss://root"],
|
||||||
["a", "30078:videopk:root", "wss://definition"],
|
["A", "30078:videopk:root", "wss://definition"],
|
||||||
["e", "parent-comment", "wss://parent", "parentpk"],
|
["E", "parent-comment", "wss://parent", "parentpk"],
|
||||||
["k", String(COMMENT_EVENT_KIND)],
|
["K", String(COMMENT_EVENT_KIND)],
|
||||||
["p", "parentpk", "wss://parent"],
|
["P", "parentpk", "wss://parent"],
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -255,11 +255,11 @@ test("listVideoComments matches comments even when tag casing and whitespace dif
|
|||||||
created_at: 1700000300,
|
created_at: 1700000300,
|
||||||
tags: [
|
tags: [
|
||||||
[" A ", " 30078:AUTHOR:CLIP ", " WSS://Definition "],
|
[" A ", " 30078:AUTHOR:CLIP ", " WSS://Definition "],
|
||||||
["e", " VIDEO-1 "],
|
["E", " VIDEO-1 "],
|
||||||
[" E ", " VIDEO-1 "],
|
[" E ", " VIDEO-1 "],
|
||||||
["e", " PARENT-1 "],
|
["E", " PARENT-1 "],
|
||||||
["k", String(COMMENT_EVENT_KIND)],
|
["K", String(COMMENT_EVENT_KIND)],
|
||||||
["p", " THREAD-PARTICIPANT "],
|
["P", " THREAD-PARTICIPANT "],
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -293,7 +293,7 @@ test("listVideoComments matches uppercase definition addresses without lowering"
|
|||||||
created_at: 1700000400,
|
created_at: 1700000400,
|
||||||
tags: [
|
tags: [
|
||||||
["A", uppercasePointer],
|
["A", uppercasePointer],
|
||||||
["e", "video-1"],
|
["E", "video-1"],
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -324,11 +324,11 @@ test("listVideoComments matches comments even when tag casing and whitespace dif
|
|||||||
created_at: 1700000300,
|
created_at: 1700000300,
|
||||||
tags: [
|
tags: [
|
||||||
[" A ", " 30078:AUTHOR:CLIP ", " WSS://Definition "],
|
[" A ", " 30078:AUTHOR:CLIP ", " WSS://Definition "],
|
||||||
["e", " VIDEO-1 "],
|
["E", " VIDEO-1 "],
|
||||||
[" E ", " VIDEO-1 "],
|
[" E ", " VIDEO-1 "],
|
||||||
["e", " PARENT-1 "],
|
["E", " PARENT-1 "],
|
||||||
["k", String(COMMENT_EVENT_KIND)],
|
["K", String(COMMENT_EVENT_KIND)],
|
||||||
["p", " THREAD-PARTICIPANT "],
|
["P", " THREAD-PARTICIPANT "],
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -354,11 +354,11 @@ test("listVideoComments matches comments even when tag casing and whitespace dif
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
["p", "parentpk", "wss://parent"],
|
["P", "parentpk", "wss://parent"],
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("publishComment emits only video event #e tag when address and parent are absent", async () => {
|
test("publishComment emits only uppercase video event pointer when address and parent are absent", async () => {
|
||||||
const { client, publishCalls } = createMockClient();
|
const { client, publishCalls } = createMockClient();
|
||||||
|
|
||||||
const signer = {
|
const signer = {
|
||||||
@@ -389,9 +389,8 @@ test("publishComment emits only video event #e tag when address and parent are a
|
|||||||
tags,
|
tags,
|
||||||
[
|
[
|
||||||
["E", "video-only"],
|
["E", "video-only"],
|
||||||
["e", "video-only"],
|
|
||||||
],
|
],
|
||||||
"event should include an uppercase root pointer along with the legacy #e tag",
|
"event should include a single uppercase pointer",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -404,9 +403,9 @@ test("listVideoComments builds filters with uppercase roots plus legacy fallback
|
|||||||
["A", "30078:author:clip"],
|
["A", "30078:author:clip"],
|
||||||
["K", "30078"],
|
["K", "30078"],
|
||||||
["P", "author"],
|
["P", "author"],
|
||||||
["e", "parent-1"],
|
["E", "parent-1"],
|
||||||
["k", String(COMMENT_EVENT_KIND)],
|
["K", String(COMMENT_EVENT_KIND)],
|
||||||
["p", "thread-participant"],
|
["P", "thread-participant"],
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -415,8 +414,8 @@ test("listVideoComments builds filters with uppercase roots plus legacy fallback
|
|||||||
kind: COMMENT_EVENT_KIND,
|
kind: COMMENT_EVENT_KIND,
|
||||||
created_at: 1690000000,
|
created_at: 1690000000,
|
||||||
tags: [
|
tags: [
|
||||||
["a", "30078:author:clip"],
|
["A", "30078:author:clip"],
|
||||||
["e", "parent-1"],
|
["E", "parent-1"],
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -424,7 +423,7 @@ test("listVideoComments builds filters with uppercase roots plus legacy fallback
|
|||||||
id: "comment-3",
|
id: "comment-3",
|
||||||
kind: COMMENT_EVENT_KIND,
|
kind: COMMENT_EVENT_KIND,
|
||||||
created_at: 1700000100,
|
created_at: 1700000100,
|
||||||
tags: [["a", "30078:author:clip"]],
|
tags: [["A", "30078:author:clip"]],
|
||||||
};
|
};
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@@ -473,9 +472,9 @@ test("listVideoComments builds filters with uppercase roots plus legacy fallback
|
|||||||
"event filter should target comment kind",
|
"event filter should target comment kind",
|
||||||
);
|
);
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
eventFilter["#e"],
|
eventFilter["#E"],
|
||||||
["video-1"],
|
["video-1"],
|
||||||
"event filter should target the video via #e",
|
"event filter should target the video via #E",
|
||||||
);
|
);
|
||||||
assert.equal(
|
assert.equal(
|
||||||
uppercaseFilter.kinds[0],
|
uppercaseFilter.kinds[0],
|
||||||
@@ -511,11 +510,11 @@ test("listVideoComments builds filters with uppercase roots plus legacy fallback
|
|||||||
parentFilter,
|
parentFilter,
|
||||||
{
|
{
|
||||||
kinds: [COMMENT_EVENT_KIND],
|
kinds: [COMMENT_EVENT_KIND],
|
||||||
"#e": ["parent-1"],
|
"#E": ["parent-1"],
|
||||||
since: 1700000000,
|
since: 1700000000,
|
||||||
limit: 10,
|
limit: 10,
|
||||||
},
|
},
|
||||||
"parent filter should scope the thread via #e",
|
"parent filter should scope the thread via #E",
|
||||||
);
|
);
|
||||||
assert.equal(
|
assert.equal(
|
||||||
eventFilter.since,
|
eventFilter.since,
|
||||||
@@ -534,12 +533,12 @@ test("listVideoComments builds filters with uppercase roots plus legacy fallback
|
|||||||
"definition filter should target comment kind",
|
"definition filter should target comment kind",
|
||||||
);
|
);
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
definitionFilter["#a"],
|
definitionFilter["#A"],
|
||||||
["30078:author:clip"],
|
["30078:author:clip"],
|
||||||
"definition filter should bind the video definition via #a",
|
"definition filter should bind the video definition via #A",
|
||||||
);
|
);
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
definitionFilter["#e"],
|
definitionFilter["#E"],
|
||||||
["parent-1"],
|
["parent-1"],
|
||||||
"definition filter should continue scoping to the parent comment",
|
"definition filter should continue scoping to the parent comment",
|
||||||
);
|
);
|
||||||
@@ -555,14 +554,14 @@ test("listVideoComments builds filters with uppercase roots plus legacy fallback
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("listVideoComments adds lowercase root filters when only the identifier is known", async () => {
|
test("listVideoComments emits uppercase root filters when only the identifier is known", async () => {
|
||||||
const matchingEvent = {
|
const matchingEvent = {
|
||||||
id: "comment-root",
|
id: "comment-root",
|
||||||
kind: COMMENT_EVENT_KIND,
|
kind: COMMENT_EVENT_KIND,
|
||||||
tags: [
|
tags: [
|
||||||
["I", "root-only"],
|
["I", "root-only"],
|
||||||
["P", "root-author"],
|
["P", "root-author"],
|
||||||
["e", "video-rooted"],
|
["E", "video-rooted"],
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -589,44 +588,21 @@ test("listVideoComments adds lowercase root filters when only the identifier is
|
|||||||
assert.ok(receivedFilters, "pool.list should receive filters");
|
assert.ok(receivedFilters, "pool.list should receive filters");
|
||||||
assert.equal(
|
assert.equal(
|
||||||
receivedFilters.filters.length,
|
receivedFilters.filters.length,
|
||||||
4,
|
2,
|
||||||
"root identifier requests should include lowercase fallbacks",
|
"root identifier requests should emit uppercase filters only",
|
||||||
);
|
);
|
||||||
|
|
||||||
const [eventFilter, uppercaseEventFilter, lowercaseRootFilter, uppercaseRootFilter] =
|
const [eventFilter, uppercaseRootFilter] = receivedFilters.filters;
|
||||||
receivedFilters.filters;
|
|
||||||
|
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
eventFilter,
|
eventFilter,
|
||||||
{
|
|
||||||
kinds: [COMMENT_EVENT_KIND],
|
|
||||||
"#e": ["video-rooted"],
|
|
||||||
since: 1700000000,
|
|
||||||
limit: 5,
|
|
||||||
},
|
|
||||||
"event filter should continue targeting the video event id",
|
|
||||||
);
|
|
||||||
|
|
||||||
assert.deepEqual(
|
|
||||||
uppercaseEventFilter,
|
|
||||||
{
|
{
|
||||||
kinds: [COMMENT_EVENT_KIND],
|
kinds: [COMMENT_EVENT_KIND],
|
||||||
"#E": ["video-rooted"],
|
"#E": ["video-rooted"],
|
||||||
since: 1700000000,
|
since: 1700000000,
|
||||||
limit: 5,
|
limit: 5,
|
||||||
},
|
},
|
||||||
"uppercase event filter should continue targeting legacy #E pointers",
|
"event filter should target the video event id via #E",
|
||||||
);
|
|
||||||
|
|
||||||
assert.deepEqual(
|
|
||||||
lowercaseRootFilter,
|
|
||||||
{
|
|
||||||
kinds: [COMMENT_EVENT_KIND],
|
|
||||||
"#i": ["root-only"],
|
|
||||||
since: 1700000000,
|
|
||||||
limit: 5,
|
|
||||||
},
|
|
||||||
"root identifier filter should include lowercase #i tag queries",
|
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
@@ -660,7 +636,7 @@ test("listVideoComments supports legacy targets without a definition address", a
|
|||||||
const legacyEvent = {
|
const legacyEvent = {
|
||||||
id: "legacy-comment",
|
id: "legacy-comment",
|
||||||
kind: COMMENT_EVENT_KIND,
|
kind: COMMENT_EVENT_KIND,
|
||||||
tags: [["e", "legacy-video"]],
|
tags: [["E", "legacy-video"]],
|
||||||
};
|
};
|
||||||
|
|
||||||
const { client, pool } = createMockClient();
|
const { client, pool } = createMockClient();
|
||||||
@@ -688,14 +664,14 @@ test("listVideoComments supports legacy targets without a definition address", a
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
kinds: [COMMENT_EVENT_KIND],
|
kinds: [COMMENT_EVENT_KIND],
|
||||||
"#e": ["legacy-video"],
|
"#E": ["legacy-video"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
kinds: [COMMENT_EVENT_KIND],
|
kinds: [COMMENT_EVENT_KIND],
|
||||||
"#E": ["legacy-video"],
|
"#E": ["legacy-video"],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
"legacy listing should target the video event id via #e/#E",
|
"legacy listing should target the video event id via #E",
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -756,7 +732,7 @@ test("subscribeVideoComments forwards matching events and cleans up unsubscribe"
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
kinds: [COMMENT_EVENT_KIND],
|
kinds: [COMMENT_EVENT_KIND],
|
||||||
"#e": ["video-1"],
|
"#E": ["video-1"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
kinds: [COMMENT_EVENT_KIND],
|
kinds: [COMMENT_EVENT_KIND],
|
||||||
@@ -766,12 +742,12 @@ test("subscribeVideoComments forwards matching events and cleans up unsubscribe"
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
kinds: [COMMENT_EVENT_KIND],
|
kinds: [COMMENT_EVENT_KIND],
|
||||||
"#e": ["parent-1"],
|
"#E": ["parent-1"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
kinds: [COMMENT_EVENT_KIND],
|
kinds: [COMMENT_EVENT_KIND],
|
||||||
"#a": ["30078:author:clip"],
|
"#a": ["30078:author:clip"],
|
||||||
"#e": ["parent-1"],
|
"#E": ["parent-1"],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
"subscription should emit event, parent, and address filters",
|
"subscription should emit event, parent, and address filters",
|
||||||
@@ -784,16 +760,16 @@ test("subscribeVideoComments forwards matching events and cleans up unsubscribe"
|
|||||||
["A", "30078:author:clip"],
|
["A", "30078:author:clip"],
|
||||||
["K", "30078"],
|
["K", "30078"],
|
||||||
["P", "author"],
|
["P", "author"],
|
||||||
["e", "parent-1"],
|
["E", "parent-1"],
|
||||||
["k", String(COMMENT_EVENT_KIND)],
|
["K", String(COMMENT_EVENT_KIND)],
|
||||||
["p", "thread-participant"],
|
["P", "thread-participant"],
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
handler({
|
handler({
|
||||||
id: "comment-rejected",
|
id: "comment-rejected",
|
||||||
kind: COMMENT_EVENT_KIND,
|
kind: COMMENT_EVENT_KIND,
|
||||||
tags: [["e", "video-1"]],
|
tags: [["E", "video-1"]],
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.equal(receivedEvents.length, 1, "only matching events should reach the callback");
|
assert.equal(receivedEvents.length, 1, "only matching events should reach the callback");
|
||||||
@@ -839,7 +815,7 @@ test("subscribeVideoComments supports video targets without a definition address
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
kinds: [COMMENT_EVENT_KIND],
|
kinds: [COMMENT_EVENT_KIND],
|
||||||
"#e": ["legacy-video"],
|
"#E": ["legacy-video"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
kinds: [COMMENT_EVENT_KIND],
|
kinds: [COMMENT_EVENT_KIND],
|
||||||
@@ -854,7 +830,7 @@ test("subscribeVideoComments supports video targets without a definition address
|
|||||||
handler({
|
handler({
|
||||||
id: "legacy-comment",
|
id: "legacy-comment",
|
||||||
kind: COMMENT_EVENT_KIND,
|
kind: COMMENT_EVENT_KIND,
|
||||||
tags: [["e", "legacy-video"]],
|
tags: [["E", "legacy-video"]],
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.equal(receivedEvents.length, 1, "legacy comment should be forwarded");
|
assert.equal(receivedEvents.length, 1, "legacy comment should be forwarded");
|
||||||
|
|||||||
Reference in new issue
Block a user