diff --git a/src/main/kotlin/io/github/mojira/arisa/Executor.kt b/src/main/kotlin/io/github/mojira/arisa/Executor.kt index a5430687..bcfd4bdb 100644 --- a/src/main/kotlin/io/github/mojira/arisa/Executor.kt +++ b/src/main/kotlin/io/github/mojira/arisa/Executor.kt @@ -130,11 +130,17 @@ private fun getSearchResultsFromJira( return searchResult .issues - .map { - it.toDomain( - jiraClient, - ProjectCache.getProjectFromTicketId(it.key), - config - ) + .mapNotNull { + @Suppress("TooGenericExceptionCaught") + try { + it.toDomain( + jiraClient, + ProjectCache.getProjectFromTicketId(it.key), + config + ) + } catch (exception: Exception) { + log.error("Error mapping bug report ${it.key}:" + exception.message + "\n" + exception.stackTrace) + null + } } } diff --git a/src/main/kotlin/io/github/mojira/arisa/domain/Comment.kt b/src/main/kotlin/io/github/mojira/arisa/domain/Comment.kt index f12048d5..fd4b3a62 100644 --- a/src/main/kotlin/io/github/mojira/arisa/domain/Comment.kt +++ b/src/main/kotlin/io/github/mojira/arisa/domain/Comment.kt @@ -5,7 +5,7 @@ import java.time.Instant data class Comment( val id: String, val body: String?, - val author: User, + val author: User?, val getAuthorGroups: () -> List?, val created: Instant, val updated: Instant, diff --git a/src/main/kotlin/io/github/mojira/arisa/modules/CommandModule.kt b/src/main/kotlin/io/github/mojira/arisa/modules/CommandModule.kt index ef7716f5..a2d74dc0 100644 --- a/src/main/kotlin/io/github/mojira/arisa/modules/CommandModule.kt +++ b/src/main/kotlin/io/github/mojira/arisa/modules/CommandModule.kt @@ -98,7 +98,7 @@ class CommandModule( ) { val issueKey = issue.key val commentId = comment.id - val user = comment.author.name + val user = comment.author?.name val commandStr = command.command commandResult.fold( { exception -> @@ -162,7 +162,7 @@ class CommandModule( private fun userIsVolunteer(comment: Comment): Boolean { // Ignore comments from the bot itself to prevent accidental infinite recursion and command // injection by malicious user - if (ignoreOwnCommands && comment.author.name == botUserName) { + if (ignoreOwnCommands && comment.author?.name == botUserName) { return false } diff --git a/src/main/kotlin/io/github/mojira/arisa/modules/HideImpostorsModule.kt b/src/main/kotlin/io/github/mojira/arisa/modules/HideImpostorsModule.kt index b858b45a..73baf8b5 100644 --- a/src/main/kotlin/io/github/mojira/arisa/modules/HideImpostorsModule.kt +++ b/src/main/kotlin/io/github/mojira/arisa/modules/HideImpostorsModule.kt @@ -30,7 +30,7 @@ class HideImpostorsModule : Module { .plus(1, ChronoUnit.DAYS) .isAfter(Instant.now()) - private fun userContainsBrackets(comment: Comment) = with(comment.author.displayName) { + private fun userContainsBrackets(comment: Comment) = with(comment.author?.displayName) { this != null && matches("""\[(?:\p{L}|\p{N}|\s)+]\s.+""".toRegex()) } diff --git a/src/main/kotlin/io/github/mojira/arisa/modules/RemoveBotCommentModule.kt b/src/main/kotlin/io/github/mojira/arisa/modules/RemoveBotCommentModule.kt index f906ebf0..32eb0a1b 100644 --- a/src/main/kotlin/io/github/mojira/arisa/modules/RemoveBotCommentModule.kt +++ b/src/main/kotlin/io/github/mojira/arisa/modules/RemoveBotCommentModule.kt @@ -38,7 +38,7 @@ class RemoveBotCommentModule( listOf("staff", "global-moderators").contains(comment.visibilityValue) private fun shouldBeRemoved(comment: Comment) = - comment.author.name == botUserName && + comment.author?.name == botUserName && isVolunteerRestricted(comment) && comment.body.equals(removalTag) } diff --git a/src/main/kotlin/io/github/mojira/arisa/modules/ReopenAwaitingModule.kt b/src/main/kotlin/io/github/mojira/arisa/modules/ReopenAwaitingModule.kt index d6f109fe..33bcee9f 100644 --- a/src/main/kotlin/io/github/mojira/arisa/modules/ReopenAwaitingModule.kt +++ b/src/main/kotlin/io/github/mojira/arisa/modules/ReopenAwaitingModule.kt @@ -69,7 +69,7 @@ class ReopenAwaitingModule( // regular users can reopen and have commented OR (!onlyOp && isSoftAR) || // reporter has commented - validComments.any { it.author.name == reporter?.name } + validComments.any { it.author?.name == reporter?.name } } private fun isOPTag(comment: Comment) = comment.visibilityType == "group" && @@ -80,7 +80,7 @@ class ReopenAwaitingModule( comment.visibilityValue == "staff" && (comment.body?.contains(keepARTag) ?: false) - private fun isKeepARMessage(comment: Comment, project: Project) = comment.author.name == "arisabot" && + private fun isKeepARMessage(comment: Comment, project: Project) = comment.author?.name == "arisabot" && ( comment.body?.contains( HelperMessageService.getMessageWithBotSignature( @@ -99,7 +99,7 @@ class ReopenAwaitingModule( lastRun: Instant ): List = comments .filter { it.created.isAfter(resolveTime) && it.created.isAfter(lastRun) } - .filter { !it.author.isNewUser() || it.author.name == reporter?.name } + .filter { it.author != null && (!it.author.isNewUser() || it.author.name == reporter?.name) } .filter { val roles = it.getAuthorGroups() roles == null || roles.intersect(blacklistedRoles).isEmpty() diff --git a/src/main/kotlin/io/github/mojira/arisa/modules/ShadowbanModule.kt b/src/main/kotlin/io/github/mojira/arisa/modules/ShadowbanModule.kt index 20258d11..9c7a300f 100644 --- a/src/main/kotlin/io/github/mojira/arisa/modules/ShadowbanModule.kt +++ b/src/main/kotlin/io/github/mojira/arisa/modules/ShadowbanModule.kt @@ -59,9 +59,9 @@ class ShadowbanModule : Module { private fun Issue.checkCommentsForShadowban(timeframe: ExecutionTimeframe): Int = comments .filter { it.isNotStaffRestricted() } - .filter { it.author.isNotVolunteer() } + .filter { it.author != null && it.author.isNotVolunteer() } .filter { - timeframe.shadowbans[it.author.name]?.banTimeContains(it.created) ?: false + timeframe.shadowbans[it.author?.name]?.banTimeContains(it.created) ?: false } .map { it.restrict("${it.body}\n\n_Removed by Arisa -- User is shadowbanned_") } .size diff --git a/src/main/kotlin/io/github/mojira/arisa/modules/commands/DeleteCommentsCommand.kt b/src/main/kotlin/io/github/mojira/arisa/modules/commands/DeleteCommentsCommand.kt index 342fbd92..51c38df7 100644 --- a/src/main/kotlin/io/github/mojira/arisa/modules/commands/DeleteCommentsCommand.kt +++ b/src/main/kotlin/io/github/mojira/arisa/modules/commands/DeleteCommentsCommand.kt @@ -14,7 +14,7 @@ class DeleteCommentsCommand { operator fun invoke(issue: Issue, userName: String): Int { val comments = issue.comments .filter { it.visibilityValue != "staff" } - .filter { it.author.name == userName } + .filter { it.author?.name == userName } Thread { comments