Skip to content

Commit

Permalink
Add missing p tag
Browse files Browse the repository at this point in the history
  • Loading branch information
dcadenas committed Apr 4, 2024
1 parent f04dd7c commit 5b2f70e
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 40 deletions.
5 changes: 5 additions & 0 deletions src/lib/nostr.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ export default class Nostr {

static async setTags(moderationNostrEvent, moderatedNostrEvent, moderation) {
const reportType = this.inferReportType(moderation);
moderationNostrEvent.tags.push([
"p",
moderatedNostrEvent.pubkey,
reportType,
]);
moderationNostrEvent.tags.push(["e", moderatedNostrEvent.id, reportType]);
moderationNostrEvent.tags.push(["L", "MOD"]);

Expand Down
80 changes: 40 additions & 40 deletions src/lib/openAICategories.js
Original file line number Diff line number Diff line change
@@ -1,68 +1,68 @@
const OPENAI_CATEGORIES = {
hate: {
description:
'Content that expresses, incites, or promotes hate based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste. Hateful content aimed at non-protected groups (e.g., chess players) is harassment.',
nip56_report_type: 'other',
nip69: 'IH',
"Content that expresses, incites, or promotes hate based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste. Hateful content aimed at non-protected groups (e.g., chess players) is harassment.",
nip56_report_type: "other",
nip69: "IH",
},
'hate/threatening': {
"hate/threatening": {
description:
'Hateful content that also includes violence or serious harm towards the targeted group based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste.',
nip56_report_type: 'other',
nip69: 'HC-bhd',
"Hateful content that also includes violence or serious harm towards the targeted group based on race, gender, ethnicity, religion, nationality, sexual orientation, disability status, or caste.",
nip56_report_type: "other",
nip69: "HC-bhd",
},
harassment: {
description:
'Content that expresses, incites, or promotes harassing language towards any target.',
nip56_report_type: 'other',
nip69: 'IL-har',
"Content that expresses, incites, or promotes harassing language towards any target.",
nip56_report_type: "other",
nip69: "IL-har",
},
'harassment/threatening': {
"harassment/threatening": {
description:
'Harassment content that also includes violence or serious harm towards any target.',
nip56_report_type: 'other',
nip69: 'HC-bhd',
"Harassment content that also includes violence or serious harm towards any target.",
nip56_report_type: "other",
nip69: "HC-bhd",
},
'self-harm': {
"self-harm": {
description:
'Content that promotes, encourages, or depicts acts of self-harm, such as suicide, cutting, and eating disorders.',
nip56_report_type: 'other',
nip69: 'HC-bhd',
"Content that promotes, encourages, or depicts acts of self-harm, such as suicide, cutting, and eating disorders.",
nip56_report_type: "other",
nip69: "HC-bhd",
},
'self-harm/intent': {
"self-harm/intent": {
description:
'Content where the speaker expresses that they are engaging or intend to engage in acts of self-harm, such as suicide, cutting, and eating disorders.',
nip56_report_type: 'other',
nip69: 'HC-bhd',
"Content where the speaker expresses that they are engaging or intend to engage in acts of self-harm, such as suicide, cutting, and eating disorders.",
nip56_report_type: "other",
nip69: "HC-bhd",
},
'self-harm/instructions': {
"self-harm/instructions": {
description:
'Content that encourages performing acts of self-harm, such as suicide, cutting, and eating disorders, or that gives instructions or advice on how to commit such acts.',
nip56_report_type: 'other',
nip69: 'HC-bhd',
"Content that encourages performing acts of self-harm, such as suicide, cutting, and eating disorders, or that gives instructions or advice on how to commit such acts.",
nip56_report_type: "other",
nip69: "HC-bhd",
},
sexual: {
description:
'Content meant to arouse sexual excitement, such as the description of sexual activity, or that promotes sexual services (excluding sex education and wellness).',
nip56_report_type: 'nudity',
nip69: 'NS',
"Content meant to arouse sexual excitement, such as the description of sexual activity, or that promotes sexual services (excluding sex education and wellness).",
nip56_report_type: "nudity",
nip69: "NS",
},
'sexual/minors': {
"sexual/minors": {
description:
'Sexual content that includes an individual who is under 18 years old.',
nip56_report_type: 'illegal',
nip69: 'IL-csa',
"Sexual content that includes an individual who is under 18 years old.",
nip56_report_type: "illegal",
nip69: "IL-csa",
},
violence: {
description: 'Content that depicts death, violence, or physical injury.',
nip56_report_type: 'other',
nip69: 'VI',
description: "Content that depicts death, violence, or physical injury.",
nip56_report_type: "other",
nip69: "VI",
},
'violence/graphic': {
"violence/graphic": {
description:
'Content that depicts death, violence, or physical injury in graphic detail.',
nip56_report_type: 'other',
nip69: 'VI',
"Content that depicts death, violence, or physical injury in graphic detail.",
nip56_report_type: "other",
nip69: "VI",
},
};

Expand Down
4 changes: 4 additions & 0 deletions test/moderationFunction.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ describe("Moderation Cloud Function", async () => {
sinon.assert.calledWithMatch(Nostr.publishNostrEvent, {
kind: 1984,
tags: [
["p", flaggedNostrEvent.pubkey, "other"],
["e", flaggedNostrEvent.id, "other"],
["L", "MOD"],
["l", "MOD>IH", "MOD", sinon.match.string],
Expand Down Expand Up @@ -295,6 +296,7 @@ describe("Moderation Cloud Function", async () => {
sinon.assert.calledWithMatch(Nostr.publishNostrEvent, {
kind: 1984,
tags: [
["p", flaggedNostrEvent.pubkey, "other"],
["e", flaggedNostrEvent.id, "other"],
["L", "MOD"],
["l", "MOD>IH", "MOD", sinon.match.string],
Expand Down Expand Up @@ -364,6 +366,7 @@ describe("Moderation Cloud Function", async () => {
sinon.assert.calledWithMatch(Nostr.publishNostrEvent, {
kind: 1984,
tags: [
["p", flaggedNostrEvent.pubkey, "other"],
["e", flaggedNostrEvent.id, "other"],
["L", "MOD"],
["l", "MOD>IH", "MOD", sinon.match.string],
Expand Down Expand Up @@ -430,6 +433,7 @@ describe("Moderation Cloud Function", async () => {
sinon.assert.calledWithMatch(Nostr.publishNostrEvent, {
kind: 1984,
tags: [
["p", flaggedNostrEvent.pubkey, "other"],
["e", flaggedNostrEvent.id, "other"],
["L", "MOD"],
["l", "MOD>IH", "MOD", sinon.match.string],
Expand Down

0 comments on commit 5b2f70e

Please sign in to comment.