mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
cleanup PushNotificationAPI
This commit is contained in:
parent
3f6229f841
commit
01d80ae54b
@ -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 {
|
||||
|
@ -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))
|
||||
|
@ -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,
|
||||
|
@ -986,7 +986,6 @@ interface TextSecurePreferences {
|
||||
fun clearAll(context: Context) {
|
||||
getDefaultSharedPreferences(context).edit().clear().commit()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user