From 553e55b4d169cdf80fce5fedc0e6854bd0cd4c9e Mon Sep 17 00:00:00 2001 From: Valere Date: Mon, 24 Jan 2022 13:08:47 +0100 Subject: [PATCH] quick cleaning / code review --- .../main/java/im/vector/app/AutoRageShaker.kt | 4 +-- .../app/features/rageshake/BugReporter.kt | 27 +++++++++++-------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/vector/src/main/java/im/vector/app/AutoRageShaker.kt b/vector/src/main/java/im/vector/app/AutoRageShaker.kt index 0b72f8a57c..0238931e4c 100644 --- a/vector/src/main/java/im/vector/app/AutoRageShaker.kt +++ b/vector/src/main/java/im/vector/app/AutoRageShaker.kt @@ -67,8 +67,8 @@ class AutoRageShaker @Inject constructor( fun initialize() { observeActiveSession() - // It's a singleton... enable(vectorPreferences.labsAutoReportUISI()) + // It's a singleton... vectorPreferences.subscribeToChanges(this) // Simple rate limit, notice that order is not @@ -142,7 +142,7 @@ class AutoRageShaker @Inject constructor( withCrashLogs = true, withKeyRequestHistory = true, withScreenshot = false, - theBugDescription = "Auto-reporting decryption error (recipient)", + theBugDescription = "Auto-reporting decryption error", serverVersion = "", canContact = false, customFields = mapOf("auto_uisi" to buildString { diff --git a/vector/src/main/java/im/vector/app/features/rageshake/BugReporter.kt b/vector/src/main/java/im/vector/app/features/rageshake/BugReporter.kt index 564fa63916..46b2e9a7fe 100755 --- a/vector/src/main/java/im/vector/app/features/rageshake/BugReporter.kt +++ b/vector/src/main/java/im/vector/app/features/rageshake/BugReporter.kt @@ -265,17 +265,7 @@ class BugReporter @Inject constructor( // build the multi part request val builder = BugReporterMultipartBody.Builder() .addFormDataPart("text", text) - .apply { - when (reportType) { - ReportType.AUTO_UISI_SENDER, - ReportType.AUTO_UISI -> { - addFormDataPart("app", "element-auto-uisi") - } - else -> { - addFormDataPart("app", "riot-android") - } - } - } + .addFormDataPart("app", rageShakeAppNameForReport(reportType)) .addFormDataPart("user_agent", Matrix.getInstance(context).getUserAgent()) .addFormDataPart("user_id", userId) .addFormDataPart("can_contact", canContact.toString()) @@ -497,6 +487,21 @@ class BugReporter @Inject constructor( activity.startActivity(BugReportActivity.intent(activity, reportType)) } + private fun rageShakeAppNameForReport(reportType: ReportType): String { + // As per https://github.com/matrix-org/rageshake + // app: Identifier for the application (eg 'riot-web'). + // Should correspond to a mapping configured in the configuration file for github issue reporting to work. + // (see R.string.bug_report_url for configured RS server) + return when (reportType) { + ReportType.AUTO_UISI_SENDER, + ReportType.AUTO_UISI -> { + "element-auto-uisi" + } + else -> { + "riot-android" + } + } + } // ============================================================================================================== // crash report management // ==============================================================================================================