Align subscription lists with NIP-51 follow set kind

This commit is contained in:
thePR0M3TH3AN committed 2025-10-31 08:33:39 -04:00
1 parent 3d60d865fa
commit e496376236
6 files changed
+30 -19

No files matched your search

@@ -100,7 +100,7 @@ Add placeholders for different views in `index.html`:
- Fetch videos (`kind 30078`) filtered by the user's `npub`.
### **Subscriptions**
- Use `kind 30002` to manage the subscription list:
- Use `kind 30000` to manage the subscription follow set:
- Subscribe: Add user to the list.
- Unsubscribe: Remove user.
@@ -47,8 +47,8 @@ This document describes how to implement **Block Lists**, **Subscription Lists**
A **Subscription List** lets users follow video creators independently of their main “following” list on Nostr. It supports categorization and can be made private via encryption.
### Event Kind
- **Kind**: `30002`
- **Description**: “Video Subscription List” (inspired by NIP-51 but for custom lists)
- **Kind**: `30000`
- **Description**: “Video Subscription Follow Set” aligned with [NIP-51 follow sets](../../docs/nips/51.md#sets)
### JSON Structure
**Public Tags**
@@ -64,7 +64,7 @@ A **Subscription List** lets users follow video creators independently of their
### Example
```json
{
"kind": 30002,
"kind": 30000,
"tags": [
["d", "favorite-creators"],
["p", "npub1creator1pubkey"],
@@ -208,7 +208,7 @@ The `p` tag references a pubkey, and the `e` tag references a note. The third el
## Implementation Details
### Replaceable Events
- **Subscription Lists** (`30002`) and **Block Lists** (`10001`) can be implemented as replaceable events by using a deterministic `d` tag.
- **Subscription Lists** (`30000`) and **Block Lists** (`10001`) can be implemented as replaceable events by using a deterministic `d` tag.
- For example, `["d","my-blocklist"]` ensures older events with the same `d` are replaced when new ones arrive.
### Encryption
@@ -220,7 +220,7 @@ The `p` tag references a pubkey, and the `e` tag references a note. The third el
- Query each relay for events matching:
```jsonc
{
"kinds": [10001, 30002],
"kinds": [10001, 30000],
"authors": [<user-pubkey>]
}
```
@@ -275,7 +275,7 @@ The `p` tag references a pubkey, and the `e` tag references a note. The third el
## Future Considerations
1. **Paid Subscriptions**
- Could layer subscription tiers on top of `30002` events.
- Could layer subscription tiers on top of `30000` events.
2. **Global Block Lists**
- Let users publish or subscribe to a curated blocklist (or share one in a group).
3. **Web of Trust**
@@ -284,4 +284,4 @@ The `p` tag references a pubkey, and the `e` tag references a note. The third el
---
### Summary
By leveraging Nostr event kinds (`30002` for subscriptions, `10001` for blocks, and `1984` for reports), bitvid can maintain a decentralized, user-controlled moderation system. Users can sync their lists across devices through relays, while administrators can choose how to handle flagged content on a platform level. This approach keeps moderation flexible and transparent.
By leveraging Nostr event kinds (`30000` for subscriptions, `10001` for blocks, and `1984` for reports), bitvid can maintain a decentralized, user-controlled moderation system. Users can sync their lists across devices through relays, while administrators can choose how to handle flagged content on a platform level. This approach keeps moderation flexible and transparent.
@@ -87,7 +87,7 @@ Rather than measuring active peers, bitvid now counts views by logging them as N
- Compare the count of new views against a previous period, or calculate the rate of increase.
3. **For You**
- Look at what the user watched or subscribed to (via kind `30002` subscription lists).
- Look at what the user watched or subscribed to (via kind `30000` subscription follow sets).
- Track the user’s or session’s recent view tags, then recommend videos with overlapping tags or from the same channels.
---
@@ -124,7 +124,7 @@ Your `index.html` might include placeholders for each section:
1. **Fetch Data**
- Pull video metadata from kind `30078` events that contain video info or from your existing approach.
- Pull subscription data (kind `30002`).
- Pull subscription data (kind `30000`).
- Pull view events (kind `30078` with `"t", "view"`).
2. **Process Rankings**
+8 -2
View File
@@ -147,13 +147,19 @@ import { updateWatchHistoryListWithDefaultClient } from "./nostrWatchHistoryFaca
| View counter (`NOTE_TYPES.VIEW_EVENT`) | `WATCH_HISTORY_KIND` (default `30079`, clients also read legacy `30078`) | Canonical tag set: `['t','view']`, a pointer tag (`['e', <eventId>]` or `['a', <address>]`), and a stable dedupe tag `['d', <view identifier>]`, with optional `['session','true']` when a session actor signs; schema overrides may append extra tags. `['video', ...]` is supported for legacy overrides only. | Optional plaintext message |
| Watch history index (`NOTE_TYPES.WATCH_HISTORY_INDEX`) | `WATCH_HISTORY_KIND` (default `30079`, clients also read legacy `30078`) | `['d', WATCH_HISTORY_LIST_IDENTIFIER]`, `['snapshot', <id>]`, `['chunks', <total>]`, repeated `['a', <chunk address>]` pointers plus schema append tags | JSON payload `{ snapshot, totalChunks }` (may be empty when using tags only) |
| Watch history chunk (`NOTE_TYPES.WATCH_HISTORY_CHUNK`) | `WATCH_HISTORY_KIND` (default `30079`, clients also read legacy `30078`) | `['d', <snapshotId:index>]`, `['encrypted','nip04']`, `['snapshot', <id>]`, `['chunk', <index>, <total>]`, optional leading `['head','1']` on the first chunk, pointer tags for each item, plus schema append tags | NIP-04 encrypted JSON chunk (`{ version, snapshot, chunkIndex, totalChunks, items[] }`) |
| Subscription list (`NOTE_TYPES.SUBSCRIPTION_LIST`) | `30002` | `['d', 'subscriptions']` | NIP-04 encrypted JSON `{ subPubkeys: string[] }` |
| User block list (`NOTE_TYPES.USER_BLOCK_LIST`) | `30002` | `['d', 'user-blocks']` | NIP-04 encrypted JSON `{ blockedPubkeys: string[] }` |
| Subscription list (`NOTE_TYPES.SUBSCRIPTION_LIST`) | `30000` | `['d', 'subscriptions']` | NIP-04/NIP-44 encrypted JSON array of NIP-51 follow-set tuples (e.g., `[['p', <hex>], …]`) |
| User block list (`NOTE_TYPES.USER_BLOCK_LIST`) | `10000` | `['d', 'user-blocks']` | NIP-04/NIP-44 encrypted JSON `{ blockedPubkeys: string[] }` |
| Hashtag preferences (`NOTE_TYPES.HASHTAG_PREFERENCES`) | `30005` | `['d', 'bitvid:tag-preferences']` plus schema-appended `['encrypted','nip44_v2']` | NIP-44 encrypted JSON `{ version, interests: string[], disinterests: string[] }` |
| Admin moderation list (`NOTE_TYPES.ADMIN_MODERATION_LIST`) | `30000` | `['d', 'bitvid:admin:editors']`, repeated `['p', <pubkey>]` entries | Empty content |
| Admin blacklist (`NOTE_TYPES.ADMIN_BLACKLIST`) | `30000` | `['d', 'bitvid:admin:blacklist']`, repeated `['p', <pubkey>]` entries | Empty content |
| Admin whitelist (`NOTE_TYPES.ADMIN_WHITELIST`) | `30000` | `['d', 'bitvid:admin:whitelist']`, repeated `['p', <pubkey>]` entries | Empty content |
Subscription lists therefore match the
[NIP-51 follow-set specification](./nips/51.md#sets) by emitting kind `30000`
events with the shared `['d','subscriptions']` identifier. Builders continue to
encrypt the payload so individual follows stay private unless explicitly
revealed by the author.
NIP-94 compliance: mirror events now normalize the `['m', <mime>]` tag to lowercase—covering both user input and inferred values—so they satisfy [NIP-94's lowercase MIME requirement](./nips/94.md). Related helpers reuse the same normalization to keep future publishers aligned.
### Direct messages
+2 -2
View File
@@ -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,
+10 -5
View File
@@ -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,9 @@ 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;
function normalizeHexPubkey(value) {
if (typeof value !== "string") {
return "";
@@ -210,7 +215,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 +239,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) {
@@ -261,7 +266,7 @@ class SubscriptionsManager {
}
const filter = {
kinds: [30002],
kinds: [SUBSCRIPTION_SET_KIND],
authors,
"#d": [SUBSCRIPTION_LIST_IDENTIFIER],
limit: 1
@@ -566,7 +571,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) {