diff --git a/js/accessControl.js b/js/accessControl.js index 5dea0ae4..bb19970d 100644 --- a/js/accessControl.js +++ b/js/accessControl.js @@ -283,6 +283,11 @@ class AccessControl { return { ok: false, error: "invalid npub" }; } + const normalizedActor = normalizeNpub(actorNpub); + if (normalizedActor && normalized === normalizedActor) { + return { ok: false, error: "self" }; + } + if (this.isSuperAdmin(normalized) || this.isAdminEditor(normalized)) { return { ok: false, error: "immutable" }; } diff --git a/js/adminListStore.js b/js/adminListStore.js index 706f893e..3b9dd969 100644 --- a/js/adminListStore.js +++ b/js/adminListStore.js @@ -448,6 +448,7 @@ async function persistNostrState(actorNpub, updates = {}) { } const sanitizedUpdates = {}; + const actorNormalized = normalizeNpub(actorNpub); if (Array.isArray(updates.editors)) { sanitizedUpdates.editors = sanitizeNpubList(updates.editors).filter((npub) => { @@ -470,6 +471,10 @@ async function persistNostrState(actorNpub, updates = {}) { ...((sanitizedUpdates.editors || []).map(normalizeNpub) || []), ]); + if (actorNormalized) { + editorGuard.add(actorNormalized); + } + sanitizedUpdates.blacklist = sanitizeNpubList(updates.blacklist).filter( (npub) => { const normalized = normalizeNpub(npub); diff --git a/js/app.js b/js/app.js index 33599efe..d9b25e6d 100644 --- a/js/app.js +++ b/js/app.js @@ -4304,6 +4304,8 @@ class bitvidApp { return "Please provide a valid npub address."; case "immutable": return "That account cannot be modified."; + case "self": + return "You cannot blacklist yourself."; case "forbidden": return "You do not have permission to perform that action."; case "nostr-unavailable": @@ -6913,6 +6915,9 @@ class bitvidApp { } else { const code = result?.error || "unknown"; switch (code) { + case "self": + this.showError("You cannot blacklist yourself."); + break; case "immutable": this.showError( "Moderators cannot blacklist the super admin or fellow moderators."