mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-28 20:45:17 +00:00
Added the legacy group 'joined_at' value
This commit is contained in:
parent
422f53c86a
commit
3a035482e4
@ -564,7 +564,7 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co
|
|||||||
val admins = group.members.filter { it.value /*admin = true*/ }.keys.map { Address.fromSerialized(it) }
|
val admins = group.members.filter { it.value /*admin = true*/ }.keys.map { Address.fromSerialized(it) }
|
||||||
val groupId = GroupUtil.doubleEncodeGroupID(group.sessionId)
|
val groupId = GroupUtil.doubleEncodeGroupID(group.sessionId)
|
||||||
val title = group.name
|
val title = group.name
|
||||||
val formationTimestamp = SnodeAPI.nowWithOffset // TODO: formation timestamp for legacy ? current time?
|
val formationTimestamp = group.joinedAt
|
||||||
createGroup(groupId, title, members, null, null, admins, formationTimestamp)
|
createGroup(groupId, title, members, null, null, admins, formationTimestamp)
|
||||||
setProfileSharing(Address.fromSerialized(groupId), true)
|
setProfileSharing(Address.fromSerialized(groupId), true)
|
||||||
// Add the group to the user's set of public keys to poll for
|
// Add the group to the user's set of public keys to poll for
|
||||||
@ -835,7 +835,8 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co
|
|||||||
priority = ConfigBase.PRIORITY_VISIBLE,
|
priority = ConfigBase.PRIORITY_VISIBLE,
|
||||||
encPubKey = encryptionKeyPair.publicKey.serialize(),
|
encPubKey = encryptionKeyPair.publicKey.serialize(),
|
||||||
encSecKey = encryptionKeyPair.privateKey.serialize(),
|
encSecKey = encryptionKeyPair.privateKey.serialize(),
|
||||||
disappearingTimer = 0L
|
disappearingTimer = 0L,
|
||||||
|
joinedAt = formationTimestamp
|
||||||
)
|
)
|
||||||
// shouldn't exist, don't use getOrConstruct + copy
|
// shouldn't exist, don't use getOrConstruct + copy
|
||||||
userGroups.set(groupInfo)
|
userGroups.set(groupInfo)
|
||||||
|
@ -256,7 +256,8 @@ object ConfigurationMessageUtilities {
|
|||||||
priority = if (isPinned) ConfigBase.PRIORITY_PINNED else ConfigBase.PRIORITY_VISIBLE,
|
priority = if (isPinned) ConfigBase.PRIORITY_PINNED else ConfigBase.PRIORITY_VISIBLE,
|
||||||
encPubKey = encryptionKeyPair.publicKey.serialize(),
|
encPubKey = encryptionKeyPair.publicKey.serialize(),
|
||||||
encSecKey = encryptionKeyPair.privateKey.serialize(),
|
encSecKey = encryptionKeyPair.privateKey.serialize(),
|
||||||
disappearingTimer = recipient.expireMessages.toLong()
|
disappearingTimer = recipient.expireMessages.toLong(),
|
||||||
|
joinedAt = group.formationTimestamp
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
(allOpenGroups + allLgc).forEach { groupInfo ->
|
(allOpenGroups + allLgc).forEach { groupInfo ->
|
||||||
|
@ -51,12 +51,14 @@ inline session::config::legacy_group_info deserialize_legacy_group_info(JNIEnv *
|
|||||||
auto enc_sec_key_field = env->GetFieldID(clazz, "encSecKey", "[B");
|
auto enc_sec_key_field = env->GetFieldID(clazz, "encSecKey", "[B");
|
||||||
auto priority_field = env->GetFieldID(clazz, "priority", "I");
|
auto priority_field = env->GetFieldID(clazz, "priority", "I");
|
||||||
auto disappearing_timer_field = env->GetFieldID(clazz, "disappearingTimer", "J");
|
auto disappearing_timer_field = env->GetFieldID(clazz, "disappearingTimer", "J");
|
||||||
|
auto joined_at_field = env->GetFieldID(clazz, "joinedAt", "L");
|
||||||
jstring id = static_cast<jstring>(env->GetObjectField(info, id_field));
|
jstring id = static_cast<jstring>(env->GetObjectField(info, id_field));
|
||||||
jstring name = static_cast<jstring>(env->GetObjectField(info, name_field));
|
jstring name = static_cast<jstring>(env->GetObjectField(info, name_field));
|
||||||
jobject members_map = env->GetObjectField(info, members_field);
|
jobject members_map = env->GetObjectField(info, members_field);
|
||||||
jbyteArray enc_pub_key = static_cast<jbyteArray>(env->GetObjectField(info, enc_pub_key_field));
|
jbyteArray enc_pub_key = static_cast<jbyteArray>(env->GetObjectField(info, enc_pub_key_field));
|
||||||
jbyteArray enc_sec_key = static_cast<jbyteArray>(env->GetObjectField(info, enc_sec_key_field));
|
jbyteArray enc_sec_key = static_cast<jbyteArray>(env->GetObjectField(info, enc_sec_key_field));
|
||||||
int priority = env->GetIntField(info, priority_field);
|
int priority = env->GetIntField(info, priority_field);
|
||||||
|
long joined_at = env->GetLongField(info, joined_at_field);
|
||||||
|
|
||||||
auto id_bytes = env->GetStringUTFChars(id, nullptr);
|
auto id_bytes = env->GetStringUTFChars(id, nullptr);
|
||||||
auto name_bytes = env->GetStringUTFChars(name, nullptr);
|
auto name_bytes = env->GetStringUTFChars(name, nullptr);
|
||||||
@ -75,6 +77,7 @@ inline session::config::legacy_group_info deserialize_legacy_group_info(JNIEnv *
|
|||||||
info_deserialized.enc_seckey = enc_sec_key_bytes;
|
info_deserialized.enc_seckey = enc_sec_key_bytes;
|
||||||
info_deserialized.priority = priority;
|
info_deserialized.priority = priority;
|
||||||
info_deserialized.disappearing_timer = std::chrono::seconds(env->GetLongField(info, disappearing_timer_field));
|
info_deserialized.disappearing_timer = std::chrono::seconds(env->GetLongField(info, disappearing_timer_field));
|
||||||
|
info_deserialized.joined_at = joined_at;
|
||||||
env->ReleaseStringUTFChars(id, id_bytes);
|
env->ReleaseStringUTFChars(id, id_bytes);
|
||||||
env->ReleaseStringUTFChars(name, name_bytes);
|
env->ReleaseStringUTFChars(name, name_bytes);
|
||||||
return info_deserialized;
|
return info_deserialized;
|
||||||
@ -116,10 +119,11 @@ inline jobject serialize_legacy_group_info(JNIEnv *env, session::config::legacy_
|
|||||||
jbyteArray enc_pubkey = util::bytes_from_ustring(env, info.enc_pubkey);
|
jbyteArray enc_pubkey = util::bytes_from_ustring(env, info.enc_pubkey);
|
||||||
jbyteArray enc_seckey = util::bytes_from_ustring(env, info.enc_seckey);
|
jbyteArray enc_seckey = util::bytes_from_ustring(env, info.enc_seckey);
|
||||||
int priority = info.priority;
|
int priority = info.priority;
|
||||||
|
long joined_at = info.joined_at;
|
||||||
|
|
||||||
jclass legacy_group_class = env->FindClass("network/loki/messenger/libsession_util/util/GroupInfo$LegacyGroupInfo");
|
jclass legacy_group_class = env->FindClass("network/loki/messenger/libsession_util/util/GroupInfo$LegacyGroupInfo");
|
||||||
jmethodID constructor = env->GetMethodID(legacy_group_class, "<init>", "(Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;[B[BIJ)V");
|
jmethodID constructor = env->GetMethodID(legacy_group_class, "<init>", "(Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;[B[BIJL)V");
|
||||||
jobject serialized = env->NewObject(legacy_group_class, constructor, session_id, name, members, enc_pubkey, enc_seckey, priority, (jlong) info.disappearing_timer.count());
|
jobject serialized = env->NewObject(legacy_group_class, constructor, session_id, name, members, enc_pubkey, enc_seckey, priority, joined_at, (jlong) info.disappearing_timer.count());
|
||||||
return serialized;
|
return serialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,8 @@ sealed class GroupInfo {
|
|||||||
val encPubKey: ByteArray,
|
val encPubKey: ByteArray,
|
||||||
val encSecKey: ByteArray,
|
val encSecKey: ByteArray,
|
||||||
val priority: Int,
|
val priority: Int,
|
||||||
val disappearingTimer: Long
|
val disappearingTimer: Long,
|
||||||
|
val joinedAt: Long
|
||||||
): GroupInfo() {
|
): GroupInfo() {
|
||||||
companion object {
|
companion object {
|
||||||
@Suppress("FunctionName")
|
@Suppress("FunctionName")
|
||||||
@ -30,6 +31,8 @@ sealed class GroupInfo {
|
|||||||
if (!encPubKey.contentEquals(other.encPubKey)) return false
|
if (!encPubKey.contentEquals(other.encPubKey)) return false
|
||||||
if (!encSecKey.contentEquals(other.encSecKey)) return false
|
if (!encSecKey.contentEquals(other.encSecKey)) return false
|
||||||
if (priority != other.priority) return false
|
if (priority != other.priority) return false
|
||||||
|
if (disappearingTimer != other.disappearingTimer) return false
|
||||||
|
if (joinedAt != other.joinedAt) return false
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -41,6 +44,8 @@ sealed class GroupInfo {
|
|||||||
result = 31 * result + encPubKey.contentHashCode()
|
result = 31 * result + encPubKey.contentHashCode()
|
||||||
result = 31 * result + encSecKey.contentHashCode()
|
result = 31 * result + encSecKey.contentHashCode()
|
||||||
result = 31 * result + priority
|
result = 31 * result + priority
|
||||||
|
result = 31 * result + disappearingTimer.hashCode()
|
||||||
|
result = 31 * result + joinedAt.hashCode()
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user