Skip to content

Commit

Permalink
Merge pull request #1861 from Infomaniak/message-folders
Browse files Browse the repository at this point in the history
Update Sentry to get more refined information
  • Loading branch information
KevinBoulongne committed May 17, 2024
2 parents 42104af + b083757 commit 28fd935
Showing 1 changed file with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,23 @@ class Message : RealmObject {
_folders.single { _folders.count() == 1 || it.id != SEARCH_FOLDER_ID }
}.getOrElse {
Sentry.withScope { scope ->
scope.setExtra("folders", "${_folders.map { "role:[${it.role?.name}] (id:[${it.id}])" }}")
scope.setExtra("foldersCount", "${_folders.count()}")
scope.level = SentryLevel.ERROR
scope.setExtra("messageUid", uid)
scope.setExtra("email", AccountUtils.currentMailboxEmail.toString())
Sentry.captureMessage("Message has several or 0 parent folders, it should not be possible", SentryLevel.ERROR)
val sentryMessage = if (_folders.isEmpty()) {
"Message has 0 parent folders, it should not be possible"
} else {
scope.setExtra("folders", "${_folders.map { "role:[${it.role?.name}] (id:[${it.id}])" }}")
scope.setExtra("foldersCount", "${_folders.count()}")
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"
}
}
Sentry.captureMessage(sentryMessage)
}
_folders.first()
}
Expand Down

0 comments on commit 28fd935

Please sign in to comment.