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

feat(reports): ability to restrict reports server wide #1171

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"eslint.workingDirectories": [{ "pattern": "./packages/*" }],
"unocss.root": "./packages/website",
"i18n-ally.localesPaths": "./packages/yuudachi/locales",
"i18n-ally.localesPaths": ["./packages/yuudachi/locales", "apps/yuudachi/locales"],
"i18n-ally.enabledFrameworks": ["i18next"],
"i18n-ally.sourceLanguage": "en-US",
"i18n-ally.displayLanguage": "en-US",
Expand Down
29 changes: 25 additions & 4 deletions apps/yuudachi/locales/en-US/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@
"no_reason": "No reason",
"show_history_target": "Show history for target {{- user}}",
"show_history_author": "Show history for author {{- user}}"
},
"update_restriction_level": {
"errors": {
"no_change": "The restriction level has not been changed.",
"no_reason": "No reason provided for updating the restriction level. Reason is required when changing to `Restricted` or `Blocked`."
},
"base": "Successfully changed the report restriction level to `{{- level}}`.",
"enabled": "- All the restrictions to create reports have been lifted.",
"restricted": "- The creation of reports have been restricted. Members will be required to confirm their report before proceeding.\n\n**Reason:** ```{{- reason}}```",
"blocked": "- The creation of reports have been blocked. Members will not be able to create reports.\n\n**Reason:** ```{{- reason}}```"
}
},
"warn": {
Expand Down Expand Up @@ -358,14 +368,17 @@
"invalid_attachment": "Invalid attachment, only images are allowed.",
"timed_out": "The report has timed out, please try again.",
"bot": "You cannot report bots.",
"no_attachment_forward": "This user has already been recently reported, you must specify an attachment to forward if it helps the context of the report."
"no_attachment_forward": "This user has already been recently reported, you must specify an attachment to forward if it helps the context of the report.",
"disabled": "The creation of reports has been disabled by the server moderators for the following reason:\n```{{- reason}}```"
},
"warnings": "**Attention:** We are not Discord and we **cannot** moderate {{- trust_and_safety}} issues.\n**Creating false reports may lead to moderation actions.**",
"trust_and_safety_sub": "Trust & Safety",
"restriction": "The reports have been restricted by the moderators for the following reason:\n```{{- reason}}```\nIf your report does not fall under this category, please proceed with the report creation.",
"buttons": {
"forward": "Forward Message",
"forward_attachment": "Forward Attachment",
"execute": "Create Report",
"proceed": "Proceed with Report",
"cancel": "Cancel",
"discord_report": "Report to Discord"
},
Expand Down Expand Up @@ -763,8 +776,16 @@
}
},
"table": {
"success_titles": ["Case id", "Member id", "Username"],
"fail_titles": ["Member id", "Username", "Error"]
"success_titles": [
"Case id",
"Member id",
"Username"
],
"fail_titles": [
"Member id",
"Username",
"Error"
]
}
},
"report_log": {
Expand All @@ -788,4 +809,4 @@
}
}
}
}
}
17 changes: 17 additions & 0 deletions apps/yuudachi/migrations/1673411947-reports-restriction-level.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @param {import('postgres').Sql} sql
*/
export async function up(sql) {
await sql.unsafe(`
create type guild_reports_restriction_level as enum ('enabled', 'restricted', 'blocked');

alter table guild_settings
add column reports_restriction_level guild_reports_restriction_level not null default 'enabled';

alter table guild_settings
add column reports_restriction_reason text default null;

comment on column guild_settings.reports_restriction_reason is 'The reason why reports are blocked/restricted in this guild';
comment on column guild_settings.reports_restriction_level is 'The restriction_level of reports in this guild, whether they are enabled, restricted (requires confirmation), or blocked';
`);
}
9 changes: 9 additions & 0 deletions apps/yuudachi/src/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ export const REPORT_DUPLICATE_PRE_EXPIRE_SECONDS = 3;
export const REPORT_DUPLICATE_EXPIRE_SECONDS = 12 * 60 * 60;
export const REPORT_MESSAGE_CONTEXT_LIMIT = 20;

export enum ReportsRestrictionLevel {
Blocked = "blocked",
Enabled = "enabled",
Restricted = "restricted",
}

export const REPORTS_RESTRICTION_REASON_MIN_LENGTH = 3;
export const REPORTS_RESTRICTION_REASON_MAX_LENGTH = 1_000;

export const APPEAL_REASON_MAX_LENGTH = 1_500;
export const APPEAL_REASON_MIN_LENGTH = 160;

Expand Down
Loading
Loading