diff --git a/src/main/kotlin/com/wire/github/EventsHandler.kt b/src/main/kotlin/com/wire/github/EventsHandler.kt index 8f19a9e..5d97eea 100644 --- a/src/main/kotlin/com/wire/github/EventsHandler.kt +++ b/src/main/kotlin/com/wire/github/EventsHandler.kt @@ -76,8 +76,8 @@ class EventsHandler : WireEventsHandlerSuspending() { private fun registerRepositories( repositories: Set, conversationId: QualifiedId - ): String { - val results = repositories.map { repository -> + ): String? { + val results = repositories.mapNotNull { repository -> runCatching { gitHubWebhookManager.ensureWebhookForConversation( repository = repository, @@ -101,7 +101,7 @@ class EventsHandler : WireEventsHandlerSuspending() { ) } - return results.joinToString(separator = "\n") + return results.takeIf { it.isNotEmpty() }?.joinToString("\n") } private fun sendMessage( diff --git a/src/main/kotlin/com/wire/github/github/GitHubWebhookManager.kt b/src/main/kotlin/com/wire/github/github/GitHubWebhookManager.kt index ac796be..69834bb 100644 --- a/src/main/kotlin/com/wire/github/github/GitHubWebhookManager.kt +++ b/src/main/kotlin/com/wire/github/github/GitHubWebhookManager.kt @@ -49,7 +49,7 @@ class GitHubWebhookManager( storage.sadd( conversationsKey(repository.fullName), conversationId.toStorageKey() - ) > 0 + ) == 1L markRepositoryActive(repository.fullName)