Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use only nip 56 categories for slack buttons #50

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading