This commit is contained in:
andrew
2023-07-26 14:36:06 +09:30
parent 55216875ac
commit d3ea4e2e30
18 changed files with 99 additions and 85 deletions

View File

@@ -94,7 +94,7 @@ fun MessageSender.create(
// Add the group to the config now that it was successfully created
storage.createInitialConfigGroup(groupPublicKey, name, GroupUtil.createConfigMemberMap(members, admins), sentTime, encryptionKeyPair)
// Notify the PN server
PushManagerV1.register(publicKey = userPublicKey, device = device)
PushManagerV1.register(device = device, publicKey = userPublicKey)
// Start polling
ClosedGroupPollerV2.shared.startPolling(groupPublicKey)
// Fulfill the promise

View File

@@ -556,7 +556,7 @@ private fun handleNewClosedGroup(sender: String, sentTimestamp: Long, groupPubli
// Set expiration timer
storage.setExpirationTimer(groupID, expireTimer)
// Notify the PN server
PushManagerV1.register(publicKey = userPublicKey, device = MessagingModuleConfiguration.shared.device)
PushManagerV1.register(device = MessagingModuleConfiguration.shared.device, publicKey = userPublicKey)
// Notify the user
if (userPublicKey == sender && !groupExists) {
val threadID = storage.getOrCreateThreadIdFor(Address.fromSerialized(groupID))

View File

@@ -27,18 +27,19 @@ object PushManagerV1 {
private val server = Server.LEGACY
fun register(
device: Device,
isUsingFCM: Boolean = TextSecurePreferences.isUsingFCM(context),
token: String? = TextSecurePreferences.getFCMToken(context),
publicKey: String? = TextSecurePreferences.getLocalNumber(context),
device: Device,
legacyGroupPublicKeys: Collection<String> = MessagingModuleConfiguration.shared.storage.getAllClosedGroupPublicKeys()
): Promise<*, Exception> =
if (!isUsingFCM) {
emptyPromise()
} else retryIfNeeded(maxRetryCount) {
doRegister(token, publicKey, device, legacyGroupPublicKeys)
} fail { exception ->
Log.d(TAG, "Couldn't register for FCM due to error: $exception.")
when {
isUsingFCM -> retryIfNeeded(maxRetryCount) {
doRegister(token, publicKey, device, legacyGroupPublicKeys)
} fail { exception ->
Log.d(TAG, "Couldn't register for FCM due to error: $exception.")
}
else -> emptyPromise()
}
private fun doRegister(token: String?, publicKey: String?, device: Device, legacyGroupPublicKeys: Collection<String>): Promise<*, Exception> {
@@ -50,7 +51,7 @@ object PushManagerV1 {
val parameters = mapOf(
"token" to token,
"pubKey" to publicKey,
"device" to device,
"device" to device.value,
"legacyGroupPublicKeys" to legacyGroupPublicKeys
)

View File

@@ -1,6 +1,6 @@
package org.session.libsession.utilities
enum class Device(val value: String) {
ANDROID("android"),
enum class Device(val value: String, val service: String = value) {
ANDROID("android", "firebase"),
HUAWEI("huawei");
}