From 089fa3ad8484bdb77e07534e9ba56c0e871478d7 Mon Sep 17 00:00:00 2001
From: Fornax
Date: Thu, 11 Apr 2024 14:40:39 +0200
Subject: [PATCH] Add type filters for abuse report window
---
svelte/src/file_viewer/ReportWindow.svelte | 50 +++++++++++++++++----
svelte/src/file_viewer/viewers/Abuse.svelte | 12 ++---
svelte/src/util/Formatting.svelte | 2 +-
3 files changed, 50 insertions(+), 14 deletions(-)
diff --git a/svelte/src/file_viewer/ReportWindow.svelte b/svelte/src/file_viewer/ReportWindow.svelte
index bbc8530..5257416 100644
--- a/svelte/src/file_viewer/ReportWindow.svelte
+++ b/svelte/src/file_viewer/ReportWindow.svelte
@@ -5,12 +5,29 @@ export let file = {
id: "",
name: "",
get_href: "",
+ mime_type: "",
}
export let list = {
id: "",
files: [],
}
+const filter_visual = type => {
+ return type.startsWith("image/") ||
+ type.startsWith("video/") ||
+ type === "application/pdf"
+}
+const filter_audiovisual = type => {
+ return type.startsWith("image/") ||
+ type.startsWith("video/") ||
+ type.startsWith("audio/") ||
+ type === "application/pdf"
+}
+const filter_app = type => {
+ return type.startsWith("application/") ||
+ type.startsWith("text/")
+}
+
const abuse_categories = [
{
type: "copyright", name: "Copyright",
@@ -19,14 +36,17 @@ const abuse_categories = [
}, {
type: "porn", name: "Porn",
desc: `Sexually explicit videos or images`,
+ filter: filter_visual,
}, {
type: "terrorism", name: "Terrorism",
desc: `Videos, images or audio fragments showing or promoting the use
of intentional violence to achieve political aims`,
+ filter: filter_audiovisual,
}, {
type: "gore", name: "Gore",
desc: `Graphic and shocking videos or images depicting severe harm to
humans (or animals)`,
+ filter: filter_visual,
}, {
type: "child_abuse", name: "Child abuse",
desc: `Videos or images depicting inappropriate touching or nudity of
@@ -35,6 +55,10 @@ const abuse_categories = [
type: "zoophilia", name: "Zoophilia",
desc: `Videos or images depicting of sexual acts being performed on
animals`,
+ }, {
+ type: "revenge_porn", name: "Revenge porn",
+ desc: `The distribution of sexually explicit images or videos of
+ individuals without their consent`,
}, {
type: "doxing", name: "Doxing",
desc: `Personally identifiable information being shared without the
@@ -43,10 +67,7 @@ const abuse_categories = [
}, {
type: "malware", name: "Malware",
desc: `Software programs designed to cause harm to computer systems`,
- }, {
- type: "revenge_porn", name: "Revenge porn",
- desc: `The distribution of sexually explicit images or videos of
- individuals without their consent`,
+ filter: filter_app,
},
]
@@ -160,10 +181,12 @@ const report_description = () => {
{#each abuse_categories as cat}
-
-
- {cat.name} : {cat.desc}
-
+ {#if cat.filter === undefined || cat.filter(file.mime_type) }
+
+
+ {cat.name} : {cat.desc}
+
+ {/if}
{/each}
{#if list.id !== "" && file.id !== ""}
@@ -271,4 +294,15 @@ label {
.report_form > textarea {
height: 5em;
}
+.type_label {
+ display: flex;
+ flex-direction: row;
+}
+.type_button {
+ flex: 0 0 auto;
+ margin-right: 1em;
+}
+.type_label {
+ flex: 1 1 auto;
+}
diff --git a/svelte/src/file_viewer/viewers/Abuse.svelte b/svelte/src/file_viewer/viewers/Abuse.svelte
index 3327f03..f37a12f 100644
--- a/svelte/src/file_viewer/viewers/Abuse.svelte
+++ b/svelte/src/file_viewer/viewers/Abuse.svelte
@@ -37,11 +37,13 @@ let file = {
{/if}
-
- Pixeldrain has zero tolerance towards abuse. The IP address this file
- originated from has been banned and is no longer able to upload files to
- pixeldrain.
-
+ {#if file.abuse_type !== "porn"}
+
+ Pixeldrain has zero tolerance towards abuse. The IP address this file
+ originated from has been banned and is no longer able to upload files to
+ pixeldrain.
+
+ {/if}
{#if file.can_download}
diff --git a/svelte/src/util/Formatting.svelte b/svelte/src/util/Formatting.svelte
index dcae533..19489cb 100644
--- a/svelte/src/util/Formatting.svelte
+++ b/svelte/src/util/Formatting.svelte
@@ -6,7 +6,7 @@ export const formatNumber = (amt, precision) => {
} else if (amt >= 1e3) {
return (amt/1e3).toPrecision(precision) + "k";
}
- return amt
+ return amt.toPrecision(precision)
}
export const formatThousands = (x) => {