Adds support for Harassment reports.

This commit is contained in:
Vitor Pamplona
2025-03-12 15:51:17 -04:00
parent ba6786cdcf
commit 1603a7473a
5 changed files with 14 additions and 8 deletions
@@ -63,6 +63,7 @@ fun RenderReport(
ReportType.MALWARE -> stringRes(R.string.malware)
ReportType.MOD -> stringRes(R.string.mod)
ReportType.OTHER -> stringRes(R.string.other)
ReportType.HARASSMENT -> stringRes(R.string.harassment)
null -> stringRes(R.string.other)
}
}.toSet()
+1
View File
@@ -21,6 +21,7 @@
<string name="impersonation">Impersonation</string>
<string name="illegal_behavior">Illegal Behavior</string>
<string name="other">Other</string>
<string name="harassment">Harassment</string>
<string name="unknown">Unknown</string>
<string name="relay_icon">Relay Icon</string>
<string name="unknown_author">Unknown Author</string>
@@ -52,14 +52,15 @@ class ReportEvent(
private fun defaultReportType(): ReportType {
defaultType?.let { return it }
// Works with old and new structures for report.
var reportType = defaultReportTypes().firstOrNull()
if (reportType == null) {
reportType = tags.mapNotNull { it.getOrNull(2) }.map { ReportType.parseOrNull(it, emptyArray()) }.firstOrNull()
}
if (reportType == null) {
reportType = ReportType.SPAM
}
// search for any type in any tag.
val reportType =
defaultReportTypes().firstOrNull()
?: tags.firstNotNullOfOrNull {
ReportedAuthorTag.parse(it)?.type
?: ReportedEventTag.parse(it)?.type
?: ReportedAddressTag.parse(it)?.type
} ?: ReportType.SPAM
defaultType = reportType
return reportType
}
@@ -33,6 +33,7 @@ enum class ReportType(
PROFANITY("profanity"),
MALWARE("malware"),
MOD("mod"),
HARASSMENT("Harrassment"),
OTHER("other"),
;
@@ -51,6 +52,7 @@ enum class ReportType(
MALWARE.code -> MALWARE
MOD.code -> MOD
"MOD" -> MOD
HARASSMENT.code -> HARASSMENT
OTHER.code -> OTHER
else -> {
Log.w("ReportedEventTag", "Report type not supported: $code ${tag.joinToString(", ")}")
@@ -27,6 +27,7 @@ import com.vitorpamplona.quartz.utils.arrayOfNotNull
import com.vitorpamplona.quartz.utils.ensure
@Immutable
@Deprecated("Old version had [`report`, `<reason>`] tags")
class DefaultReportTag {
companion object {
const val TAG_NAME = "report"