diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 00000000..e69de29b diff --git a/package.json b/package.json index 1330131e..66769c84 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "impro", - "version": "0.6.15", + "version": "0.6.17", "type": "module", "scripts": { "start": "rm -rf build && NODE_ENV=development eleventy --serve", diff --git a/src/js/components/report-dialog.js b/src/js/components/report-dialog.js index 0519121d..0e5c8bcb 100644 --- a/src/js/components/report-dialog.js +++ b/src/js/components/report-dialog.js @@ -2,8 +2,8 @@ import { html, render } from "/js/lib/lit-html.js"; import { Component } from "/js/components/component.js"; import { ScrollLock } from "/js/scrollLock.js"; import { avatarTemplate } from "/js/templates/avatar.template.js"; +import { BSKY_LABELER_DID } from "/js/config.js"; -const BSKY_LABELER_DID = "did:plc:ar7c4by46qjdydhdevvrndac"; const BSKY_ONLY_CATEGORIES = ["childSafety"]; const BSKY_ONLY_REASON_TYPES = [ "tools.ozone.report.defs#reasonViolenceExtremistContent", diff --git a/src/js/config.js b/src/js/config.js index 7bdaa9e1..67f53c36 100644 --- a/src/js/config.js +++ b/src/js/config.js @@ -8,3 +8,4 @@ export const AUTHOR_FEED_PAGE_SIZE = 40; export const DISCOVER_FEED_URI = "at://did:plc:z72i7hdynmk6r22z27h6tvur/app.bsky.feed.generator/whats-hot"; export const CHAT_MESSAGES_PAGE_SIZE = 100; +export const BSKY_LABELER_DID = "did:plc:ar7c4by46qjdydhdevvrndac"; diff --git a/src/js/dataHelpers.js b/src/js/dataHelpers.js index f7b6ecde..887bd64f 100644 --- a/src/js/dataHelpers.js +++ b/src/js/dataHelpers.js @@ -532,6 +532,10 @@ export function getGlobalLabelDefinition(labelValue) { return GLOBAL_LABELS.find((label) => label.identifier === labelValue) ?? null; } +export function isGlobalLabel(labelValue) { + return GLOBAL_LABELS.some((label) => label.identifier === labelValue); +} + export function isPinnedPost(feedItem) { return feedItem.reason?.$type === "app.bsky.feed.defs#reasonPin"; } diff --git a/src/js/preferences.js b/src/js/preferences.js index 1e0c86cd..f91b4891 100644 --- a/src/js/preferences.js +++ b/src/js/preferences.js @@ -6,9 +6,10 @@ import { getLabelNameAndDescription, getGlobalLabelDefinition, getDefaultLabelSetting, + isGlobalLabel, } from "/js/dataHelpers.js"; import { deepClone } from "/js/utils.js"; -import { DISCOVER_FEED_URI } from "/js/config.js"; +import { DISCOVER_FEED_URI, BSKY_LABELER_DID } from "/js/config.js"; import { getTagsFromFacets } from "/js/facetHelpers.js"; function getContentTextFromEmbed(embed) { @@ -215,7 +216,7 @@ export class Preferences { } const pref = this.getContentLabelPref({ label: label.val, - labelerDid: label.src, + labelerDid: isGlobalLabel(label.val) ? BSKY_LABELER_DID : label.src, }); return pref?.visibility ?? getDefaultLabelSetting(labelDefinition); } diff --git a/tests/specs/preferences.test.js b/tests/specs/preferences.test.js index 32672d2f..cc870b0e 100644 --- a/tests/specs/preferences.test.js +++ b/tests/specs/preferences.test.js @@ -1460,7 +1460,7 @@ t.describe("Preferences.getMediaLabel", (it) => { policies: { labelValueDefinitions: [ { - identifier: "nudity", + identifier: "nudity_custom", blurs: "media", defaultSetting: "warn", locales: [{ lang: "en", name: "Nudity" }], @@ -1472,7 +1472,7 @@ t.describe("Preferences.getMediaLabel", (it) => { const obj = [ { $type: "app.bsky.actor.defs#contentLabelPref", - label: "nudity", + label: "nudity_custom", labelerDid: "did:labeler1", visibility: "hide", }, @@ -1480,12 +1480,12 @@ t.describe("Preferences.getMediaLabel", (it) => { const preferences = new Preferences(obj, labelerDefs); const post = { - labels: [{ src: "did:labeler1", val: "nudity" }], + labels: [{ src: "did:labeler1", val: "nudity_custom" }], }; const result = preferences.getMediaLabel(post); assertEquals(result.visibility, "hide"); - assertEquals(result.labelDefinition.identifier, "nudity"); + assertEquals(result.labelDefinition.identifier, "nudity_custom"); }); it("should ignore content labels (blurs: content)", () => { @@ -1968,12 +1968,12 @@ t.describe("Preferences.getMediaLabel - global self-labels", (it) => { }); it("should allow user to change self-label visibility", () => { - // User sets porn to "warn" instead of default "hide" + // User sets porn to "warn" instead of default "hide" on the global labeler const obj = [ { $type: "app.bsky.actor.defs#contentLabelPref", label: "porn", - labelerDid: "did:plc:author123", + labelerDid: "did:plc:ar7c4by46qjdydhdevvrndac", visibility: "warn", }, ]; @@ -2218,7 +2218,7 @@ t.describe( { $type: "app.bsky.actor.defs#contentLabelPref", label: "porn", - labelerDid: "did:plc:author123", + labelerDid: "did:plc:ar7c4by46qjdydhdevvrndac", visibility: "warn", }, {