diff --git a/js/watchHistoryService.js b/js/watchHistoryService.js index 499b525a..04274f4b 100644 --- a/js/watchHistoryService.js +++ b/js/watchHistoryService.js @@ -687,12 +687,22 @@ async function publishView(pointerInput, createdAt) { return viewResult; } - const actorCandidate = + let actorCandidate = viewResult?.event?.pubkey || nostrClient?.pubkey || nostrClient?.sessionActor?.pubkey || ""; - const actorKey = normalizeActorKey(actorCandidate); + let actorKey = normalizeActorKey(actorCandidate); + let usedSessionFallback = false; + if (!actorKey && typeof nostrClient?.ensureSessionActor === "function") { + await nostrClient.ensureSessionActor(); + const sessionActorKey = normalizeActorKey(nostrClient?.sessionActor?.pubkey); + if (sessionActorKey) { + actorKey = sessionActorKey; + actorCandidate = nostrClient?.sessionActor?.pubkey || ""; + usedSessionFallback = true; + } + } if (!actorKey) { userLogger.warn( "[watchHistoryService] Unable to resolve actor for watch list update.", @@ -700,6 +710,12 @@ async function publishView(pointerInput, createdAt) { ); return viewResult; } + if (usedSessionFallback) { + devLogger.info( + "[watchHistoryService] Using session actor fallback for watch history update.", + { actor: actorKey } + ); + } const queue = ensureQueue(actorKey); if (!queue) {