mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-06 12:52:26 +00:00
Merge pull request #1276 from PR0M3TH3AN/codex/watch-history-v2-encryption-596800188208881719
Enforce v=2 tag and mandatory encryption for watch history
This commit is contained in:
4 files changed
+48
-25
No files matched your search
@@ -41,6 +41,8 @@ import {
|
||||
ENSURE_PRESENCE_REBROADCAST_COOLDOWN_SECONDS,
|
||||
} from "../config/instance-config.js";
|
||||
|
||||
export const WATCH_HISTORY_VERSION_TAG_VALUE = "2";
|
||||
|
||||
export const isDevMode = Boolean(IS_DEV_MODE);
|
||||
export { IS_DEV_MODE };
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
WATCH_HISTORY_PAYLOAD_MAX_BYTES,
|
||||
WATCH_HISTORY_FETCH_EVENT_LIMIT,
|
||||
WATCH_HISTORY_CACHE_TTL_MS,
|
||||
WATCH_HISTORY_VERSION_TAG_VALUE,
|
||||
} from "../config.js";
|
||||
import {
|
||||
buildWatchHistoryEvent,
|
||||
@@ -26,8 +27,8 @@ import { devLogger, userLogger } from "../utils/logger.js";
|
||||
* relay publishing, fetch/decrypt flows, and exposes a manager factory that is
|
||||
* dependency-injected with the nostr client hooks it needs.
|
||||
*/
|
||||
const WATCH_HISTORY_STORAGE_KEY = "bitvid:watch-history:v4";
|
||||
const WATCH_HISTORY_STORAGE_VERSION = 4;
|
||||
const WATCH_HISTORY_STORAGE_KEY = "bitvid:watch-history:v5";
|
||||
const WATCH_HISTORY_STORAGE_VERSION = 5;
|
||||
const WATCH_HISTORY_REPUBLISH_BASE_DELAY_MS = 2000;
|
||||
const WATCH_HISTORY_REPUBLISH_MAX_DELAY_MS = 5 * 60 * 1000;
|
||||
const WATCH_HISTORY_REPUBLISH_MAX_ATTEMPTS = 8;
|
||||
@@ -1653,6 +1654,11 @@ class WatchHistoryManager {
|
||||
}
|
||||
}
|
||||
|
||||
if (!encryptionTags.length) {
|
||||
devLogger.warn("[nostr] Aborting watch history publish: mandatory encryption failed.");
|
||||
return { ok: false, error: "encryption-failed", retryable: true };
|
||||
}
|
||||
|
||||
const event = buildWatchHistoryEvent({
|
||||
pubkey: actorPubkey,
|
||||
created_at: createdAtCursor,
|
||||
@@ -2045,7 +2051,8 @@ class WatchHistoryManager {
|
||||
{
|
||||
kinds,
|
||||
authors: [actorKey],
|
||||
// Fetch all parameterized replaceables of this kind to get history across all months
|
||||
// Filter by the new version tag to ignore older history lists
|
||||
"#v": [WATCH_HISTORY_VERSION_TAG_VALUE],
|
||||
limit,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
isDevMode,
|
||||
WATCH_HISTORY_KIND,
|
||||
WATCH_HISTORY_LIST_IDENTIFIER,
|
||||
WATCH_HISTORY_VERSION_TAG_VALUE,
|
||||
} from "./config.js";
|
||||
|
||||
export const NOTE_TYPES = Object.freeze({
|
||||
@@ -359,7 +360,7 @@ const BASE_SCHEMAS = {
|
||||
name: "d",
|
||||
},
|
||||
monthTagName: "month",
|
||||
appendTags: DEFAULT_APPEND_TAGS,
|
||||
appendTags: [["v", WATCH_HISTORY_VERSION_TAG_VALUE]],
|
||||
content: {
|
||||
format: "json",
|
||||
description:
|
||||
|
||||
Reference in new issue
Block a user