Quick fixes on auto uisi RS

This commit is contained in:
Valere 2022-01-21 10:27:33 +01:00
parent a085b4db21
commit 4d7e46b751
2 changed files with 41 additions and 20 deletions

View File

@ -68,6 +68,7 @@ class AutoRageShaker @Inject constructor(
fun initialize() { fun initialize() {
observeActiveSession() observeActiveSession()
// It's a singleton... // It's a singleton...
enable(vectorPreferences.labsAutoReportUISI())
vectorPreferences.subscribeToChanges(this) vectorPreferences.subscribeToChanges(this)
// Simple rate limit, notice that order is not // Simple rate limit, notice that order is not
@ -141,17 +142,19 @@ class AutoRageShaker @Inject constructor(
withCrashLogs = true, withCrashLogs = true,
withKeyRequestHistory = true, withKeyRequestHistory = true,
withScreenshot = false, withScreenshot = false,
theBugDescription = "UISI detected", theBugDescription = "Auto-reporting decryption error (recipient)",
serverVersion = "", serverVersion = "",
canContact = false, canContact = false,
customFields = mapOf("auto-uisi" to buildString { customFields = mapOf("auto_uisi" to buildString {
append("\neventId: ${target.eventId}") append("{")
append("\nroomId: ${target.roomId}") append("\"event_id\": \"${target.eventId}\",")
append("\nsenderKey: ${target.senderKey}") append("\"room_id\": \"${target.roomId}\",")
append("\nsource: ${target.source}") append("\"sender_key\": \"${target.senderKey}\",")
append("\ndeviceId: ${target.senderDeviceId}") append("\"device_id\": \"${target.senderDeviceId}\",")
append("\nuserId: ${target.senderUserId}") append("\"source\": \"${target.source}\",")
append("\nsessionId: ${target.sessionId}") append("\"user_id\": \"${target.senderUserId}\",")
append("\"session_id\": \"${target.sessionId}\"")
append("}")
}), }),
listener = object : BugReporter.IMXBugReportListener { listener = object : BugReporter.IMXBugReportListener {
override fun onUploadCancelled() { override fun onUploadCancelled() {
@ -221,17 +224,19 @@ class AutoRageShaker @Inject constructor(
withCrashLogs = true, withCrashLogs = true,
withKeyRequestHistory = true, withKeyRequestHistory = true,
withScreenshot = false, withScreenshot = false,
theBugDescription = "UISI detected $matchingIssue", theBugDescription = "Auto-reporting decryption error \nRecipient rageshake: $matchingIssue",
serverVersion = "", serverVersion = "",
canContact = false, canContact = false,
customFields = mapOf( customFields = mapOf(
"auto-uisi" to buildString { "auto_uisi" to buildString {
append("\neventId: $eventId") append("{")
append("\nroomId: $roomId") append("\"event_id\": \"$eventId\",")
append("\nsenderKey: $senderKey") append("\"room_id\": \"$roomId\",")
append("\ndeviceId: $deviceId") append("\"sender_key\": \"$senderKey\",")
append("\nuserId: $userId") append("\"device_id\": \"$deviceId\",")
append("\nsessionId: $sessionId") append("\"user_id\": \"$userId\",")
append("\"session_id\": \"$sessionId\"")
append("}")
}, },
"recipient_rageshake" to matchingIssue "recipient_rageshake" to matchingIssue
), ),

View File

@ -259,13 +259,23 @@ class BugReporter @Inject constructor(
ReportType.SUGGESTION -> "[Element] [Suggestion] $bugDescription" ReportType.SUGGESTION -> "[Element] [Suggestion] $bugDescription"
ReportType.SPACE_BETA_FEEDBACK -> "[Element] [spaces-feedback] $bugDescription" ReportType.SPACE_BETA_FEEDBACK -> "[Element] [spaces-feedback] $bugDescription"
ReportType.AUTO_UISI_SENDER, ReportType.AUTO_UISI_SENDER,
ReportType.AUTO_UISI -> "[AutoUISI] $bugDescription" ReportType.AUTO_UISI -> bugDescription
} }
// build the multi part request // build the multi part request
val builder = BugReporterMultipartBody.Builder() val builder = BugReporterMultipartBody.Builder()
.addFormDataPart("text", text) .addFormDataPart("text", text)
.addFormDataPart("app", "riot-android") .apply {
when (reportType) {
ReportType.AUTO_UISI_SENDER,
ReportType.AUTO_UISI -> {
addFormDataPart("app", "element-auto-uisi")
}
else -> {
addFormDataPart("app", "riot-android")
}
}
}
.addFormDataPart("user_agent", Matrix.getInstance(context).getUserAgent()) .addFormDataPart("user_agent", Matrix.getInstance(context).getUserAgent())
.addFormDataPart("user_id", userId) .addFormDataPart("user_id", userId)
.addFormDataPart("can_contact", canContact.toString()) .addFormDataPart("can_contact", canContact.toString())
@ -340,9 +350,15 @@ class BugReporter @Inject constructor(
} }
ReportType.SUGGESTION -> builder.addFormDataPart("label", "[Suggestion]") ReportType.SUGGESTION -> builder.addFormDataPart("label", "[Suggestion]")
ReportType.SPACE_BETA_FEEDBACK -> builder.addFormDataPart("label", "spaces-feedback") ReportType.SPACE_BETA_FEEDBACK -> builder.addFormDataPart("label", "spaces-feedback")
ReportType.AUTO_UISI, ReportType.AUTO_UISI -> {
builder.addFormDataPart("label", "Z-UISI")
builder.addFormDataPart("label", "android")
builder.addFormDataPart("label", "uisi-recipient")
}
ReportType.AUTO_UISI_SENDER -> { ReportType.AUTO_UISI_SENDER -> {
builder.addFormDataPart("label", "Z-UISI") builder.addFormDataPart("label", "Z-UISI")
builder.addFormDataPart("label", "android")
builder.addFormDataPart("label", "uisi-sender")
} }
} }