mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-30 13:35:18 +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) {
|
retryIfNeeded(maxRetryCount) {
|
||||||
getResponseBody<UnsubscribeResponse>(request.build()).map { response ->
|
getResponseBody<UnsubscribeResponse>(request.build()).map { response ->
|
||||||
if (response.success == true) {
|
if (response.success == true) {
|
||||||
TextSecurePreferences.setIsUsingFCM(context, false)
|
|
||||||
TextSecurePreferences.setFCMToken(context, null)
|
TextSecurePreferences.setFCMToken(context, null)
|
||||||
Log.d("Loki", "Unsubscribe FCM success")
|
Log.d("Loki", "Unsubscribe FCM success")
|
||||||
} else {
|
} else {
|
||||||
|
@ -478,7 +478,7 @@ private fun handleNewClosedGroup(sender: String, sentTimestamp: Long, groupPubli
|
|||||||
// Set expiration timer
|
// Set expiration timer
|
||||||
storage.setExpirationTimer(groupID, expireTimer)
|
storage.setExpirationTimer(groupID, expireTimer)
|
||||||
// Notify the PN server
|
// Notify the PN server
|
||||||
PushNotificationAPI.subscribeGroup(groupPublicKey, userPublicKey)
|
PushNotificationAPI.subscribeGroup(groupPublicKey)
|
||||||
// Notify the user
|
// Notify the user
|
||||||
if (userPublicKey == sender && !groupExists) {
|
if (userPublicKey == sender && !groupExists) {
|
||||||
val threadID = storage.getOrCreateThreadIdFor(Address.fromSerialized(groupID))
|
val threadID = storage.getOrCreateThreadIdFor(Address.fromSerialized(groupID))
|
||||||
|
@ -59,38 +59,22 @@ object PushNotificationAPI {
|
|||||||
fun subscribeGroup(
|
fun subscribeGroup(
|
||||||
closedGroupPublicKey: String,
|
closedGroupPublicKey: String,
|
||||||
publicKey: String = MessagingModuleConfiguration.shared.storage.getUserPublicKey()!!
|
publicKey: String = MessagingModuleConfiguration.shared.storage.getUserPublicKey()!!
|
||||||
) {
|
) = performGroupOperation(ClosedGroupOperation.Subscribe, closedGroupPublicKey, publicKey)
|
||||||
performGroupOperation(ClosedGroupOperation.Subscribe, closedGroupPublicKey, publicKey)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun subscribeGroups(
|
private fun subscribeGroups(
|
||||||
closedGroupPublicKeys: Collection<String> = MessagingModuleConfiguration.shared.storage.getAllClosedGroupPublicKeys(),
|
closedGroupPublicKeys: Collection<String> = MessagingModuleConfiguration.shared.storage.getAllClosedGroupPublicKeys(),
|
||||||
publicKey: String = MessagingModuleConfiguration.shared.storage.getUserPublicKey()!!
|
publicKey: String = MessagingModuleConfiguration.shared.storage.getUserPublicKey()!!
|
||||||
) {
|
) = closedGroupPublicKeys.forEach { performGroupOperation(ClosedGroupOperation.Subscribe, it, publicKey) }
|
||||||
performGroupOperations(ClosedGroupOperation.Subscribe, closedGroupPublicKeys, publicKey)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun unsubscribeGroup(
|
fun unsubscribeGroup(
|
||||||
closedGroupPublicKey: String,
|
closedGroupPublicKey: String,
|
||||||
publicKey: String = MessagingModuleConfiguration.shared.storage.getUserPublicKey()!!
|
publicKey: String = MessagingModuleConfiguration.shared.storage.getUserPublicKey()!!
|
||||||
) {
|
) = performGroupOperation(ClosedGroupOperation.Unsubscribe, closedGroupPublicKey, publicKey)
|
||||||
performGroupOperation(ClosedGroupOperation.Unsubscribe, closedGroupPublicKey, publicKey)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun unsubscribeGroups(
|
private fun unsubscribeGroups(
|
||||||
closedGroupPublicKeys: Collection<String> = MessagingModuleConfiguration.shared.storage.getAllClosedGroupPublicKeys(),
|
closedGroupPublicKeys: Collection<String> = MessagingModuleConfiguration.shared.storage.getAllClosedGroupPublicKeys(),
|
||||||
publicKey: String = MessagingModuleConfiguration.shared.storage.getUserPublicKey()!!
|
publicKey: String = MessagingModuleConfiguration.shared.storage.getUserPublicKey()!!
|
||||||
) {
|
) = closedGroupPublicKeys.forEach { performGroupOperation(ClosedGroupOperation.Unsubscribe, it, publicKey) }
|
||||||
performGroupOperations(ClosedGroupOperation.Unsubscribe, closedGroupPublicKeys, publicKey)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun performGroupOperations(
|
|
||||||
operation: ClosedGroupOperation,
|
|
||||||
closedGroupPublicKeys: Collection<String>,
|
|
||||||
publicKey: String
|
|
||||||
) {
|
|
||||||
closedGroupPublicKeys.forEach { performGroupOperation(operation, it, publicKey) }
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun performGroupOperation(
|
private fun performGroupOperation(
|
||||||
operation: ClosedGroupOperation,
|
operation: ClosedGroupOperation,
|
||||||
|
@ -986,7 +986,6 @@ interface TextSecurePreferences {
|
|||||||
fun clearAll(context: Context) {
|
fun clearAll(context: Context) {
|
||||||
getDefaultSharedPreferences(context).edit().clear().commit()
|
getDefaultSharedPreferences(context).edit().clear().commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user