mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-10 23:01:10 +00:00
Merge pull request #1023 from PR0M3TH3AN/codex/update-to-kind-30000-for-subscriptions
Align subscription list events with NIP-51 follow sets
This commit is contained in:
7 files changed
+116
-20
No files matched your search
@@ -295,7 +295,7 @@ const BASE_SCHEMAS = {
|
||||
[NOTE_TYPES.SUBSCRIPTION_LIST]: {
|
||||
type: NOTE_TYPES.SUBSCRIPTION_LIST,
|
||||
label: "Subscription list",
|
||||
kind: 30002,
|
||||
kind: 30000,
|
||||
identifierTag: {
|
||||
name: "d",
|
||||
value: SUBSCRIPTION_LIST_IDENTIFIER,
|
||||
@@ -1399,7 +1399,7 @@ export function buildSubscriptionListEvent({
|
||||
}
|
||||
appendSchemaTags(tags, schema);
|
||||
return {
|
||||
kind: schema?.kind ?? 30002,
|
||||
kind: schema?.kind ?? 30000,
|
||||
pubkey,
|
||||
created_at,
|
||||
tags,
|
||||
|
||||
+16
-5
@@ -14,7 +14,9 @@ import {
|
||||
import { DEFAULT_RELAY_URLS } from "./nostr/toolkit.js";
|
||||
import {
|
||||
buildSubscriptionListEvent,
|
||||
SUBSCRIPTION_LIST_IDENTIFIER
|
||||
SUBSCRIPTION_LIST_IDENTIFIER,
|
||||
getNostrEventSchema,
|
||||
NOTE_TYPES,
|
||||
} from "./nostrEventSchemas.js";
|
||||
import { getSidebarLoadingMarkup } from "./sidebarLoading.js";
|
||||
import {
|
||||
@@ -28,6 +30,10 @@ import { devLogger, userLogger } from "./utils/logger.js";
|
||||
import moderationService from "./services/moderationService.js";
|
||||
import nostrService from "./services/nostrService.js";
|
||||
|
||||
const SUBSCRIPTION_SET_KIND =
|
||||
getNostrEventSchema(NOTE_TYPES.SUBSCRIPTION_LIST)?.kind ?? 30000;
|
||||
const LEGACY_SUBSCRIPTION_SET_KIND = 30002;
|
||||
|
||||
function normalizeHexPubkey(value) {
|
||||
if (typeof value !== "string") {
|
||||
return "";
|
||||
@@ -210,7 +216,7 @@ const subscribeVideoViewEventsApi = (pointer, options) =>
|
||||
subscribeVideoViewEvents(nostrClient, pointer, options);
|
||||
|
||||
/**
|
||||
* Manages the user's subscription list (kind=30002) *privately*,
|
||||
* Manages the user's subscription list (kind=30000 follow set) *privately*,
|
||||
* using encrypted NIP-51 tag arrays (NIP-04/NIP-44) for the content field.
|
||||
* Also handles fetching and rendering subscribed channels' videos
|
||||
* in the same card style as your home page.
|
||||
@@ -234,7 +240,7 @@ class SubscriptionsManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Decrypt the subscription list from kind=30002 (d="subscriptions").
|
||||
* Decrypt the subscription list from kind=30000 (d="subscriptions").
|
||||
*/
|
||||
async loadSubscriptions(userPubkey) {
|
||||
if (!userPubkey) {
|
||||
@@ -260,8 +266,13 @@ class SubscriptionsManager {
|
||||
authors.push(userPubkey);
|
||||
}
|
||||
|
||||
const subscriptionKinds = [SUBSCRIPTION_SET_KIND];
|
||||
if (!subscriptionKinds.includes(LEGACY_SUBSCRIPTION_SET_KIND)) {
|
||||
subscriptionKinds.push(LEGACY_SUBSCRIPTION_SET_KIND);
|
||||
}
|
||||
|
||||
const filter = {
|
||||
kinds: [30002],
|
||||
kinds: subscriptionKinds,
|
||||
authors,
|
||||
"#d": [SUBSCRIPTION_LIST_IDENTIFIER],
|
||||
limit: 1
|
||||
@@ -566,7 +577,7 @@ class SubscriptionsManager {
|
||||
|
||||
/**
|
||||
* Encrypt (NIP-04) + publish the updated subscription set
|
||||
* as kind=30002 with ["d", "subscriptions"] to be replaceable.
|
||||
* as kind=30000 with ["d", "subscriptions"] to be replaceable.
|
||||
*/
|
||||
async publishSubscriptionList(userPubkey) {
|
||||
if (!userPubkey) {
|
||||
|
||||
Reference in new issue
Block a user