mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-07 05:13:01 +00:00
Treat session actors as logged out for zaps
This commit is contained in:
1 parent
0c211cd411
commit
ed1166c16e
2 files changed
+57
-2
No files matched your search
@@ -3038,7 +3038,19 @@ class Application {
|
||||
}
|
||||
|
||||
isUserLoggedIn() {
|
||||
return Boolean(this.normalizeHexPubkey(this.pubkey));
|
||||
const normalizedPubkey = this.normalizeHexPubkey(this.pubkey);
|
||||
if (!normalizedPubkey) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const sessionActorPubkey = this.normalizeHexPubkey(
|
||||
nostrClient?.sessionActor?.pubkey,
|
||||
);
|
||||
if (sessionActorPubkey && sessionActorPubkey === normalizedPubkey) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
async updateActiveNwcSettings(partial = {}) {
|
||||
|
||||
@@ -182,7 +182,16 @@ function createVideoModalStub() {
|
||||
return {
|
||||
setCopyEnabled: noop,
|
||||
setShareEnabled: noop,
|
||||
setZapVisibility: noop,
|
||||
setWalletPromptVisible: noop,
|
||||
zapVisibilityCalls: [],
|
||||
setZapVisibility(config) {
|
||||
const payload =
|
||||
config && typeof config === "object"
|
||||
? { ...config }
|
||||
: { visible: Boolean(config) };
|
||||
this.zapVisibilityCalls.push(payload);
|
||||
this.lastZapVisibility = payload;
|
||||
},
|
||||
dialogOpen: false,
|
||||
closeZapDialogCalls: [],
|
||||
closeZapDialog(options = {}) {
|
||||
@@ -349,6 +358,40 @@ await (async () => {
|
||||
app.destroy();
|
||||
})();
|
||||
|
||||
await (async () => {
|
||||
// Test: session actors should not be treated as logged-in users for zaps
|
||||
const { app, modalStub } = await createApp({
|
||||
splitAndZap: async () => ({ receipts: [] }),
|
||||
});
|
||||
|
||||
const { nostrClient } = await import("../js/nostr.js");
|
||||
const originalSessionActor = nostrClient.sessionActor;
|
||||
const sessionPubkey = "a".repeat(64);
|
||||
nostrClient.sessionActor = { pubkey: sessionPubkey, privateKey: "priv" };
|
||||
|
||||
app.pubkey = sessionPubkey;
|
||||
|
||||
modalStub.zapVisibilityCalls = [];
|
||||
app.zapController.setVisibility(true);
|
||||
|
||||
const lastVisibility =
|
||||
modalStub.zapVisibilityCalls[modalStub.zapVisibilityCalls.length - 1];
|
||||
assert.deepEqual(
|
||||
lastVisibility,
|
||||
{ visible: true, requiresLogin: true },
|
||||
"zap controller should require login when only a session actor is present",
|
||||
);
|
||||
assert.equal(
|
||||
app.isUserLoggedIn(),
|
||||
false,
|
||||
"session actor pubkeys should not count as logged-in users",
|
||||
);
|
||||
|
||||
app.pubkey = null;
|
||||
nostrClient.sessionActor = originalSessionActor;
|
||||
app.destroy();
|
||||
})();
|
||||
|
||||
await (async () => {
|
||||
// Test: wallet required before zapping
|
||||
const splitCalls = [];
|
||||
|
||||
Reference in new issue
Block a user