cleanup PushNotificationAPI

This commit is contained in:
andrew 2023-06-09 15:56:24 +09:30
parent 3f6229f841
commit 01d80ae54b
5 changed files with 6 additions and 24 deletions

View File

@ -143,7 +143,6 @@ class FirebasePushManager(private val context: Context, private val prefs: TextS
retryIfNeeded(maxRetryCount) {
getResponseBody<UnsubscribeResponse>(request.build()).map { response ->
if (response.success == true) {
TextSecurePreferences.setIsUsingFCM(context, false)
TextSecurePreferences.setFCMToken(context, null)
Log.d("Loki", "Unsubscribe FCM success")
} else {

View File

@ -478,7 +478,7 @@ private fun handleNewClosedGroup(sender: String, sentTimestamp: Long, groupPubli
// Set expiration timer
storage.setExpirationTimer(groupID, expireTimer)
// Notify the PN server
PushNotificationAPI.subscribeGroup(groupPublicKey, userPublicKey)
PushNotificationAPI.subscribeGroup(groupPublicKey)
// Notify the user
if (userPublicKey == sender && !groupExists) {
val threadID = storage.getOrCreateThreadIdFor(Address.fromSerialized(groupID))

View File

@ -14,4 +14,4 @@ interface MessageNotifier {
fun updateNotification(context: Context, threadId: Long, signal: Boolean)
fun updateNotification(context: Context, signal: Boolean, reminderCount: Int)
fun clearReminder(context: Context)
}
}

View File

@ -59,38 +59,22 @@ object PushNotificationAPI {
fun subscribeGroup(
closedGroupPublicKey: String,
publicKey: String = MessagingModuleConfiguration.shared.storage.getUserPublicKey()!!
) {
performGroupOperation(ClosedGroupOperation.Subscribe, closedGroupPublicKey, publicKey)
}
) = performGroupOperation(ClosedGroupOperation.Subscribe, closedGroupPublicKey, publicKey)
private fun subscribeGroups(
closedGroupPublicKeys: Collection<String> = MessagingModuleConfiguration.shared.storage.getAllClosedGroupPublicKeys(),
publicKey: String = MessagingModuleConfiguration.shared.storage.getUserPublicKey()!!
) {
performGroupOperations(ClosedGroupOperation.Subscribe, closedGroupPublicKeys, publicKey)
}
) = closedGroupPublicKeys.forEach { performGroupOperation(ClosedGroupOperation.Subscribe, it, publicKey) }
fun unsubscribeGroup(
closedGroupPublicKey: String,
publicKey: String = MessagingModuleConfiguration.shared.storage.getUserPublicKey()!!
) {
performGroupOperation(ClosedGroupOperation.Unsubscribe, closedGroupPublicKey, publicKey)
}
) = performGroupOperation(ClosedGroupOperation.Unsubscribe, closedGroupPublicKey, publicKey)
private fun unsubscribeGroups(
closedGroupPublicKeys: Collection<String> = MessagingModuleConfiguration.shared.storage.getAllClosedGroupPublicKeys(),
publicKey: String = MessagingModuleConfiguration.shared.storage.getUserPublicKey()!!
) {
performGroupOperations(ClosedGroupOperation.Unsubscribe, closedGroupPublicKeys, publicKey)
}
private fun performGroupOperations(
operation: ClosedGroupOperation,
closedGroupPublicKeys: Collection<String>,
publicKey: String
) {
closedGroupPublicKeys.forEach { performGroupOperation(operation, it, publicKey) }
}
) = closedGroupPublicKeys.forEach { performGroupOperation(ClosedGroupOperation.Unsubscribe, it, publicKey) }
private fun performGroupOperation(
operation: ClosedGroupOperation,

View File

@ -986,7 +986,6 @@ interface TextSecurePreferences {
fun clearAll(context: Context) {
getDefaultSharedPreferences(context).edit().clear().commit()
}
}
}