From 7519fc2f1067710b6dc8fa6a15e263ca487d4912 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Tue, 2 Jul 2024 17:30:03 -0400 Subject: [PATCH] Adds Malware Report type --- .../com/vitorpamplona/amethyst/ui/note/types/Report.kt | 1 + .../amethyst/ui/screen/loggedIn/ProfileScreen.kt | 7 +++++++ .../amethyst/ui/screen/loggedIn/ReportNoteDialog.kt | 6 ++---- amethyst/src/main/res/values/strings.xml | 2 ++ .../java/com/vitorpamplona/quartz/events/ReportEvent.kt | 8 ++++++-- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Report.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Report.kt index 01b0f1beb..9ff23be26 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Report.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/types/Report.kt @@ -58,6 +58,7 @@ fun RenderReport( ReportEvent.ReportType.SPAM -> stringRes(R.string.spam) ReportEvent.ReportType.IMPERSONATION -> stringRes(R.string.impersonation) ReportEvent.ReportType.ILLEGAL -> stringRes(R.string.illegal_behavior) + ReportEvent.ReportType.MALWARE -> stringRes(R.string.report_malware) ReportEvent.ReportType.OTHER -> stringRes(R.string.other) } }.toSet() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ProfileScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ProfileScreen.kt index a7d3e1aca..dd231bbdb 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ProfileScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ProfileScreen.kt @@ -1953,6 +1953,13 @@ fun UserProfileDropDownMenu( onDismiss() }, ) + DropdownMenuItem( + text = { Text(stringRes(id = R.string.report_malware)) }, + onClick = { + accountViewModel.report(user, ReportEvent.ReportType.MALWARE) + onDismiss() + }, + ) } } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ReportNoteDialog.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ReportNoteDialog.kt index 03121a360..9cadd746e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ReportNoteDialog.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/ReportNoteDialog.kt @@ -77,12 +77,10 @@ fun ReportNoteDialog( listOf( Pair(ReportEvent.ReportType.SPAM, stringRes(R.string.report_dialog_spam)), Pair(ReportEvent.ReportType.PROFANITY, stringRes(R.string.report_dialog_profanity)), - Pair( - ReportEvent.ReportType.IMPERSONATION, - stringRes(R.string.report_dialog_impersonation), - ), + Pair(ReportEvent.ReportType.IMPERSONATION, stringRes(R.string.report_dialog_impersonation)), Pair(ReportEvent.ReportType.NUDITY, stringRes(R.string.report_dialog_nudity)), Pair(ReportEvent.ReportType.ILLEGAL, stringRes(R.string.report_dialog_illegal)), + Pair(ReportEvent.ReportType.MALWARE, stringRes(R.string.report_malware)), ) val reasonOptions = remember { reportTypes.map { TitleExplainer(it.second) }.toImmutableList() } diff --git a/amethyst/src/main/res/values/strings.xml b/amethyst/src/main/res/values/strings.xml index 3e9cac723..11610d162 100644 --- a/amethyst/src/main/res/values/strings.xml +++ b/amethyst/src/main/res/values/strings.xml @@ -37,6 +37,7 @@ Report Impersonation Report Explicit Content Report Illegal Behaviour + Report Malware You are using a public key and public keys are read-only. Login with a Private key to be able to reply You are using a public key and public keys are read-only. Login with a Private key to be able to boost posts You are using a public key and public keys are read-only. Login with a Private key to like posts @@ -283,6 +284,7 @@ Malicious impersonation Nudity or graphic content Illegal Behavior + Malware Blocking a user will hide their content in your app. Your notes are still publicly viewable, including to people you block. Blocked users are listed on the Security Filters screen. Report Abuse diff --git a/quartz/src/main/java/com/vitorpamplona/quartz/events/ReportEvent.kt b/quartz/src/main/java/com/vitorpamplona/quartz/events/ReportEvent.kt index 0535c639d..ad2654ab3 100644 --- a/quartz/src/main/java/com/vitorpamplona/quartz/events/ReportEvent.kt +++ b/quartz/src/main/java/com/vitorpamplona/quartz/events/ReportEvent.kt @@ -25,7 +25,10 @@ import com.vitorpamplona.quartz.encoders.HexKey import com.vitorpamplona.quartz.signers.NostrSigner import com.vitorpamplona.quartz.utils.TimeUtils -@Immutable data class ReportedKey(val key: String, val reportType: ReportEvent.ReportType) +@Immutable data class ReportedKey( + val key: String, + val reportType: ReportEvent.ReportType, +) // NIP 56 event. @Immutable @@ -119,13 +122,14 @@ class ReportEvent( } } - enum class ReportType() { + enum class ReportType { EXPLICIT, // Not used anymore. ILLEGAL, SPAM, IMPERSONATION, NUDITY, PROFANITY, + MALWARE, OTHER, } }