Small refactoring on NotificationUtils

This commit is contained in:
Vitor Pamplona
2025-09-04 21:04:43 -04:00
parent b0e27d0748
commit 2ffa029790
2 changed files with 7 additions and 9 deletions

View File

@@ -43,7 +43,7 @@ object NotificationUtils {
private const val DM_GROUP_KEY = "com.vitorpamplona.amethyst.DM_NOTIFICATION"
private const val ZAP_GROUP_KEY = "com.vitorpamplona.amethyst.ZAP_NOTIFICATION"
fun NotificationManager.getOrCreateDMChannel(applicationContext: Context): NotificationChannel {
fun getOrCreateDMChannel(applicationContext: Context): NotificationChannel {
if (dmChannel != null) return dmChannel!!
dmChannel =
@@ -65,7 +65,7 @@ object NotificationUtils {
return dmChannel!!
}
fun NotificationManager.getOrCreateZapChannel(applicationContext: Context): NotificationChannel {
fun getOrCreateZapChannel(applicationContext: Context): NotificationChannel {
if (zapChannel != null) return zapChannel!!
zapChannel =
@@ -153,7 +153,7 @@ object NotificationUtils {
val imageLoader = ImageLoader(applicationContext)
val imageResult = imageLoader.executeBlocking(request)
sendNotification(
sendNotificationInner(
id = id,
messageBody = messageBody,
messageTitle = messageTitle,
@@ -165,7 +165,7 @@ object NotificationUtils {
applicationContext = applicationContext,
)
} else {
sendNotification(
sendNotificationInner(
id = id,
messageBody = messageBody,
messageTitle = messageTitle,
@@ -179,7 +179,7 @@ object NotificationUtils {
}
}
private fun NotificationManager.sendNotification(
private fun NotificationManager.sendNotificationInner(
id: String,
messageBody: String,
messageTitle: String,

View File

@@ -28,8 +28,6 @@ import com.google.firebase.messaging.FirebaseMessagingService
import com.google.firebase.messaging.RemoteMessage
import com.vitorpamplona.amethyst.Amethyst
import com.vitorpamplona.amethyst.LocalPreferences
import com.vitorpamplona.amethyst.service.notifications.NotificationUtils.getOrCreateDMChannel
import com.vitorpamplona.amethyst.service.notifications.NotificationUtils.getOrCreateZapChannel
import com.vitorpamplona.quartz.nip01Core.core.Event
import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent
import kotlinx.coroutines.CoroutineExceptionHandler
@@ -92,8 +90,8 @@ class PushNotificationReceiverService : FirebaseMessagingService() {
PushNotificationUtils.checkAndInit(token, LocalPreferences.allSavedAccounts()) {
Amethyst.instance.okHttpClients.getHttpClient(Amethyst.instance.torManager.isSocksReady())
}
notificationManager().getOrCreateZapChannel(applicationContext)
notificationManager().getOrCreateDMChannel(applicationContext)
NotificationUtils.getOrCreateZapChannel(applicationContext)
NotificationUtils.getOrCreateDMChannel(applicationContext)
}
}