Skip to content

Commit

Permalink
Merge pull request #2043 from Infomaniak/message-parents
Browse files Browse the repository at this point in the history
Fix the "Message several Folders" Sentry for the 13th time (at least)
  • Loading branch information
KevinBoulongne authored Sep 11, 2024
2 parents f0eb6ca + 23a7a82 commit 424ad97
Showing 1 changed file with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,24 +165,22 @@ class Message : RealmObject {
runCatching {
_folders.single { _folders.count() == 1 || it.id != SEARCH_FOLDER_ID }
}.getOrElse {
val sentryMessage = if (_folders.isEmpty()) {
"Message has 0 parent folders, it should not be possible"
val reason = if (_folders.isEmpty()) {
"no parents" // Message has 0 parent folders
} else {
val allFoldersAreSearch = _folders.all { it.id == SEARCH_FOLDER_ID }
val allFoldersAreTheSame = _folders.all { it.id == _folders.firstOrNull()?.id }
when {
allFoldersAreSearch -> {
"Message has multiple times the Search folder as parent, it should not be possible"
}
allFoldersAreTheSame -> {
"Message has multiple times the same parent folder, it should not be possible"
}
else -> {
"Message has multiple parent folders, it should not be possible"
}
allFoldersAreSearch -> "multiple SEARCH folder" // Message has multiple times the Search folder as parent
allFoldersAreTheSame -> "multiple same parent" // Message has multiple times the same parent folder
else -> "multiple parents" // Message has multiple parent folders
}
}
Sentry.captureMessage(sentryMessage, SentryLevel.ERROR) { scope ->
Sentry.captureMessage(
"Message doesn't have a unique parent Folder, it should not be possible",
SentryLevel.ERROR,
) { scope ->
scope.setTag("issueType", reason)
scope.setExtra("messageUid", uid)
scope.setExtra("email", AccountUtils.currentMailboxEmail.toString())
scope.setExtra("folders", "${_folders.map { "role:[${it.role?.name}] (id:[${it.id}])" }}")
Expand Down

0 comments on commit 424ad97

Please sign in to comment.