use subscription topic short url for notification group name

This commit is contained in:
Markus Doits 2022-12-06 22:01:31 +01:00
parent b63e5e8bfc
commit c18662dd1a
No known key found for this signature in database
GPG key ID: 4D406BBC615201D1
2 changed files with 7 additions and 4 deletions

View file

@ -71,9 +71,8 @@ class NotificationService(val context: Context) {
fun createSubscriptionNotificationChannels(subscription: Subscription) { fun createSubscriptionNotificationChannels(subscription: Subscription) {
val notificationScope = dedicatedNotificationScope(subscription) val notificationScope = dedicatedNotificationScope(subscription)
val groupId = dedicatedGroupId(subscription) val groupId = dedicatedGroupId(subscription)
val displayName = displayName(subscription)
maybeCreateNotificationGroup(groupId, displayName) maybeCreateNotificationGroup(groupId, subscriptionTopicShortUrl(subscription))
(1..5).forEach { priority -> maybeCreateNotificationChannel(notificationScope, priority, groupId) } (1..5).forEach { priority -> maybeCreateNotificationChannel(notificationScope, priority, groupId) }
} }
@ -116,7 +115,7 @@ class NotificationService(val context: Context) {
maybeAddUserActions(builder, notification) maybeAddUserActions(builder, notification)
if (groupId != null) { if (groupId != null) {
maybeCreateNotificationGroup(groupId, displayName(subscription)) maybeCreateNotificationGroup(groupId, subscriptionTopicShortUrl(subscription))
} }
maybeCreateNotificationChannel(scope, notification.priority, groupId) maybeCreateNotificationChannel(scope, notification.priority, groupId)

View file

@ -56,8 +56,12 @@ fun topicUrlAuth(baseUrl: String, topic: String) = "${topicUrl(baseUrl, topic)}/
fun topicUrlJsonPoll(baseUrl: String, topic: String, since: String) = "${topicUrl(baseUrl, topic)}/json?poll=1&since=$since" fun topicUrlJsonPoll(baseUrl: String, topic: String, since: String) = "${topicUrl(baseUrl, topic)}/json?poll=1&since=$since"
fun topicShortUrl(baseUrl: String, topic: String) = shortUrl(topicUrl(baseUrl, topic)) fun topicShortUrl(baseUrl: String, topic: String) = shortUrl(topicUrl(baseUrl, topic))
fun subscriptionTopicShortUrl(subscription: Subscription) : String {
return topicShortUrl(subscription.baseUrl, subscription.topic)
}
fun displayName(subscription: Subscription) : String { fun displayName(subscription: Subscription) : String {
return subscription.displayName ?: topicShortUrl(subscription.baseUrl, subscription.topic) return subscription.displayName ?: subscriptionTopicShortUrl(subscription)
} }
fun shortUrl(url: String) = url fun shortUrl(url: String) = url