Skip to content

Commit

Permalink
Use only nip 56 categories for slack buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
dcadenas committed Jul 10, 2024
1 parent d9df943 commit 64508a6
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 73 deletions.
35 changes: 22 additions & 13 deletions src/lib/slack.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ const token = process.env.SLACK_TOKEN;
const channelId = process.env.CHANNEL_ID;
const web = new WebClient(token);

// https://github.com/nostr-protocol/nips/blob/master/56.md
const nip56_report_type = [
"nudity",
"malware",
"profanity",
"illegal",
"spam",
"impersonation",
"other",
];

const code = (string) => `\`${string}\``;
export default class Slack {
// Check https://app.slack.com/block-kit-builder
Expand All @@ -39,19 +50,17 @@ export default class Slack {
reportRequest.reportedUserNjump || code(reportRequest.reportedNpub())
}`;

const elements = Object.entries(OPENAI_CATEGORIES).map(
([category, categoryData]) => {
return {
type: "button",
text: {
type: "plain_text",
text: category,
},
value: reportRequest.reporterPubkey,
action_id: category,
};
}
);
const elements = nip56_report_type.map((category) => {
return {
type: "button",
text: {
type: "plain_text",
text: category,
},
value: reportRequest.reporterPubkey,
action_id: category,
};
});

elements.unshift({
type: "button",
Expand Down
80 changes: 20 additions & 60 deletions test/slack.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,125 +127,85 @@ describe("Slack", () => {
type: "actions",
elements: [
{
type: "button",
action_id: "skip",
style: "danger",
text: {
type: "plain_text",
text: "Skip",
},
value:
"56d4b3d6310fadb7294b7f041aab469c5ffc8991b1b1b331981b96a246f6ae65",
action_id: "skip",
},
{
type: "button",
text: {
type: "plain_text",
text: "hate",
},
value:
"56d4b3d6310fadb7294b7f041aab469c5ffc8991b1b1b331981b96a246f6ae65",
action_id: "hate",
},
{
type: "button",
text: {
type: "plain_text",
text: "hate/threatening",
},
value:
"56d4b3d6310fadb7294b7f041aab469c5ffc8991b1b1b331981b96a246f6ae65",
action_id: "hate/threatening",
},
{
type: "button",
action_id: "nudity",
text: {
text: "nudity",
type: "plain_text",
text: "harassment",
},
value:
"56d4b3d6310fadb7294b7f041aab469c5ffc8991b1b1b331981b96a246f6ae65",
action_id: "harassment",
},
{
type: "button",
text: {
type: "plain_text",
text: "harassment/threatening",
},
value:
"56d4b3d6310fadb7294b7f041aab469c5ffc8991b1b1b331981b96a246f6ae65",
action_id: "harassment/threatening",
},
{
type: "button",
action_id: "malware",
text: {
text: "malware",
type: "plain_text",
text: "self-harm",
},
value:
"56d4b3d6310fadb7294b7f041aab469c5ffc8991b1b1b331981b96a246f6ae65",
action_id: "self-harm",
},
{
type: "button",
text: {
type: "plain_text",
text: "self-harm/intent",
},
value:
"56d4b3d6310fadb7294b7f041aab469c5ffc8991b1b1b331981b96a246f6ae65",
action_id: "self-harm/intent",
},
{
type: "button",
action_id: "profanity",
text: {
text: "profanity",
type: "plain_text",
text: "self-harm/instructions",
},
type: "button",
value:
"56d4b3d6310fadb7294b7f041aab469c5ffc8991b1b1b331981b96a246f6ae65",
action_id: "self-harm/instructions",
},
{
type: "button",
action_id: "illegal",
text: {
text: "illegal",
type: "plain_text",
text: "sexual",
},
type: "button",
value:
"56d4b3d6310fadb7294b7f041aab469c5ffc8991b1b1b331981b96a246f6ae65",
action_id: "sexual",
},
{
type: "button",
action_id: "spam",
text: {
text: "spam",
type: "plain_text",
text: "sexual/minors",
},
type: "button",
value:
"56d4b3d6310fadb7294b7f041aab469c5ffc8991b1b1b331981b96a246f6ae65",
action_id: "sexual/minors",
},
{
type: "button",
action_id: "impersonation",
text: {
text: "impersonation",
type: "plain_text",
text: "violence",
},
type: "button",
value:
"56d4b3d6310fadb7294b7f041aab469c5ffc8991b1b1b331981b96a246f6ae65",
action_id: "violence",
},
{
type: "button",
action_id: "other",
text: {
text: "other",
type: "plain_text",
text: "violence/graphic",
},
type: "button",
value:
"56d4b3d6310fadb7294b7f041aab469c5ffc8991b1b1b331981b96a246f6ae65",
action_id: "violence/graphic",
},
],
},
Expand Down

0 comments on commit 64508a6

Please sign in to comment.