mirror of
https://github.com/oxen-io/session-android.git
synced 2025-01-11 22:13:38 +00:00
Check fcm is enabled before modifying group sub
This commit is contained in:
parent
e3f60eb5f2
commit
dc7602a1d3
@ -33,13 +33,14 @@ object PushManagerV1 {
|
|||||||
publicKey: String? = TextSecurePreferences.getLocalNumber(context),
|
publicKey: String? = TextSecurePreferences.getLocalNumber(context),
|
||||||
legacyGroupPublicKeys: Collection<String> = MessagingModuleConfiguration.shared.storage.getAllClosedGroupPublicKeys()
|
legacyGroupPublicKeys: Collection<String> = MessagingModuleConfiguration.shared.storage.getAllClosedGroupPublicKeys()
|
||||||
): Promise<*, Exception> =
|
): Promise<*, Exception> =
|
||||||
retryIfNeeded(maxRetryCount) {
|
if (!isUsingFCM) {
|
||||||
if (isUsingFCM) doRegister(token, publicKey, legacyGroupPublicKeys)
|
emptyPromise()
|
||||||
else emptyPromise()
|
} else retryIfNeeded(maxRetryCount) {
|
||||||
|
doRegister(token, publicKey, legacyGroupPublicKeys)
|
||||||
} fail { exception ->
|
} fail { exception ->
|
||||||
Log.d(TAG, "Couldn't register for FCM due to error: ${exception}.")
|
Log.d(TAG, "Couldn't register for FCM due to error: ${exception}.")
|
||||||
} success {
|
} success {
|
||||||
Log.d(TAG, "register success!!")
|
Log.d(TAG, "register success")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun doRegister(token: String?, publicKey: String?, legacyGroupPublicKeys: Collection<String>): Promise<*, Exception> {
|
private fun doRegister(token: String?, publicKey: String?, legacyGroupPublicKeys: Collection<String>): Promise<*, Exception> {
|
||||||
@ -62,7 +63,7 @@ object PushManagerV1 {
|
|||||||
return OnionRequestAPI.sendOnionRequest(request, legacyServer, legacyServerPublicKey, Version.V2).map { response ->
|
return OnionRequestAPI.sendOnionRequest(request, legacyServer, legacyServerPublicKey, Version.V2).map { response ->
|
||||||
when (response.info["code"]) {
|
when (response.info["code"]) {
|
||||||
null, 0 -> throw Exception("error: ${response.info["message"]}.")
|
null, 0 -> throw Exception("error: ${response.info["message"]}.")
|
||||||
else -> Log.d(TAG, "register() success!!")
|
else -> Log.d(TAG, "doRegister success")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -99,13 +100,19 @@ object PushManagerV1 {
|
|||||||
|
|
||||||
fun subscribeGroup(
|
fun subscribeGroup(
|
||||||
closedGroupPublicKey: String,
|
closedGroupPublicKey: String,
|
||||||
|
isUsingFCM: Boolean = TextSecurePreferences.isUsingFCM(context),
|
||||||
publicKey: String = MessagingModuleConfiguration.shared.storage.getUserPublicKey()!!
|
publicKey: String = MessagingModuleConfiguration.shared.storage.getUserPublicKey()!!
|
||||||
) = performGroupOperation("subscribe_closed_group", closedGroupPublicKey, publicKey)
|
) = if (isUsingFCM) {
|
||||||
|
performGroupOperation("subscribe_closed_group", closedGroupPublicKey, publicKey)
|
||||||
|
} else emptyPromise()
|
||||||
|
|
||||||
fun unsubscribeGroup(
|
fun unsubscribeGroup(
|
||||||
closedGroupPublicKey: String,
|
closedGroupPublicKey: String,
|
||||||
|
isUsingFCM: Boolean = TextSecurePreferences.isUsingFCM(context),
|
||||||
publicKey: String = MessagingModuleConfiguration.shared.storage.getUserPublicKey()!!
|
publicKey: String = MessagingModuleConfiguration.shared.storage.getUserPublicKey()!!
|
||||||
) = performGroupOperation("unsubscribe_closed_group", closedGroupPublicKey, publicKey)
|
) = if (isUsingFCM) {
|
||||||
|
performGroupOperation("unsubscribe_closed_group", closedGroupPublicKey, publicKey)
|
||||||
|
} else emptyPromise()
|
||||||
|
|
||||||
private fun performGroupOperation(
|
private fun performGroupOperation(
|
||||||
operation: String,
|
operation: String,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user