mirror of
https://github.com/oxen-io/session-android.git
synced 2025-12-30 23:56:27 +00:00
fix: compile errors and moving the references to sessionId and broken hex string function
This commit is contained in:
@@ -3,6 +3,7 @@ package network.loki.messenger.libsession_util
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import network.loki.messenger.libsession_util.util.*
|
||||
import org.hamcrest.CoreMatchers.equalTo
|
||||
import org.hamcrest.CoreMatchers.not
|
||||
import org.hamcrest.CoreMatchers.notNullValue
|
||||
import org.hamcrest.MatcherAssert.assertThat
|
||||
@@ -625,10 +626,13 @@ class InstrumentedTests {
|
||||
val userCurve = Sodium.ed25519PkToCurve25519(userPublic)
|
||||
val groupConfig = UserGroupsConfig.newInstance(userSecret)
|
||||
val group = groupConfig.createGroup()
|
||||
val groupSecret = group.adminKey!!
|
||||
val groupSecret = group.adminKey
|
||||
val groupPublic = Hex.fromStringCondensed(group.groupSessionId.publicKey)
|
||||
groupConfig.set(group)
|
||||
val infoConf = GroupInfoConfig.newInstance(groupPublic, group.adminKey!!)
|
||||
val setGroup = groupConfig.getClosedGroup(group.groupSessionId.hexString())
|
||||
assertThat(setGroup, notNullValue())
|
||||
assertTrue(setGroup!!.adminKey.isNotEmpty())
|
||||
val infoConf = GroupInfoConfig.newInstance(groupPublic, group.adminKey)
|
||||
infoConf.setName("New Group")
|
||||
assertEquals("New Group", infoConf.getName())
|
||||
infoConf.setCreated(System.currentTimeMillis())
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma clang diagnostic push
|
||||
#pragma ide diagnostic ignored "bugprone-reserved-identifier"
|
||||
#include "user_groups.h"
|
||||
#include "oxenc/hex.h"
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma ide diagnostic ignored "bugprone-reserved-identifier"
|
||||
@@ -134,14 +135,8 @@ Java_network_loki_messenger_libsession_1util_UserGroupsConfig_set__Lnetwork_loki
|
||||
auto deserialized = deserialize_legacy_group_info(env, group_info, conf);
|
||||
conf->set(deserialized);
|
||||
} else if (env->IsSameObject(closed_group_info, object_class)) {
|
||||
LOGD("Closed group deserializing...")
|
||||
auto deserialized = deserialize_closed_group_info(env, group_info);
|
||||
LOGD("secret key deserialized: %d", deserialized.secretkey.size())
|
||||
conf->set(deserialized);
|
||||
auto check_group = conf->get_group(deserialized.id);
|
||||
if (check_group) {
|
||||
LOGD("after set: %d", check_group->secretkey.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,9 +8,6 @@
|
||||
#include "session/config/user_groups.hpp"
|
||||
#include <android/log.h>
|
||||
|
||||
#define APPNAME "libsession-jni"
|
||||
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, APPNAME, __VA_ARGS__);
|
||||
|
||||
inline session::config::UserGroups* ptrToUserGroups(JNIEnv *env, jobject obj) {
|
||||
jclass configClass = env->FindClass("network/loki/messenger/libsession_util/UserGroupsConfig");
|
||||
jfieldID pointerField = env->GetFieldID(configClass, "pointer", "J");
|
||||
@@ -133,7 +130,6 @@ inline jobject serialize_legacy_group_info(JNIEnv *env, session::config::legacy_
|
||||
inline jobject serialize_closed_group_info(JNIEnv* env, session::config::group_info info) {
|
||||
auto session_id = util::serialize_session_id(env, info.id);
|
||||
jbyteArray admin_bytes = util::bytes_from_ustring(env, info.secretkey);
|
||||
LOGD("admin byte length: %d", info.secretkey.size());
|
||||
jbyteArray auth_bytes = util::bytes_from_ustring(env, info.auth_data);
|
||||
|
||||
jclass group_info_class = env->FindClass("network/loki/messenger/libsession_util/util/GroupInfo$ClosedGroupInfo");
|
||||
|
||||
@@ -84,13 +84,13 @@ Java_network_loki_messenger_libsession_1util_UserProfile_setPic(JNIEnv *env, job
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_network_loki_messenger_libsession_1util_UserProfile_setNtsPriority(JNIEnv *env, jobject thiz,
|
||||
jint priority) {
|
||||
jlong priority) {
|
||||
std::lock_guard lock{util::util_mutex_};
|
||||
auto profile = ptrToProfile(env, thiz);
|
||||
profile->set_nts_priority(priority);
|
||||
}
|
||||
extern "C"
|
||||
JNIEXPORT jint JNICALL
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_network_loki_messenger_libsession_1util_UserProfile_getNtsPriority(JNIEnv *env, jobject thiz) {
|
||||
std::lock_guard lock{util::util_mutex_};
|
||||
auto profile = ptrToProfile(env, thiz);
|
||||
|
||||
@@ -36,9 +36,9 @@ sealed class ConfigBase(protected val /* yucky */ pointer: Long) {
|
||||
fun isNewConfigEnabled(forced: Boolean, currentTime: Long) =
|
||||
forced || currentTime >= ACTIVATE_TIME
|
||||
|
||||
const val PRIORITY_HIDDEN = -1
|
||||
const val PRIORITY_VISIBLE = 0
|
||||
const val PRIORITY_PINNED = 1
|
||||
const val PRIORITY_HIDDEN = -1L
|
||||
const val PRIORITY_VISIBLE = 0L
|
||||
const val PRIORITY_PINNED = 1L
|
||||
|
||||
}
|
||||
|
||||
@@ -129,8 +129,8 @@ class UserProfile(pointer: Long) : ConfigBase(pointer) {
|
||||
external fun getName(): String?
|
||||
external fun getPic(): UserPic
|
||||
external fun setPic(userPic: UserPic)
|
||||
external fun setNtsPriority(priority: Int)
|
||||
external fun getNtsPriority(): Int
|
||||
external fun setNtsPriority(priority: Long)
|
||||
external fun getNtsPriority(): Long
|
||||
external fun getCommunityMessageRequests(): Boolean
|
||||
external fun setCommunityMessageRequests(blocks: Boolean)
|
||||
external fun isBlockCommunityMessageRequestsSet(): Boolean
|
||||
|
||||
@@ -8,6 +8,6 @@ data class Contact(
|
||||
var approvedMe: Boolean = false,
|
||||
var blocked: Boolean = false,
|
||||
var profilePicture: UserPic = UserPic.DEFAULT,
|
||||
var priority: Int = 0,
|
||||
var priority: Long = 0,
|
||||
var expiryMode: ExpiryMode,
|
||||
)
|
||||
@@ -8,8 +8,8 @@ sealed class GroupInfo {
|
||||
|
||||
data class ClosedGroupInfo(
|
||||
val groupSessionId: SessionId,
|
||||
val adminKey: ByteArray?,
|
||||
val authData: ByteArray?
|
||||
val adminKey: ByteArray,
|
||||
val authData: ByteArray
|
||||
): GroupInfo() {
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
@@ -18,24 +18,19 @@ sealed class GroupInfo {
|
||||
other as ClosedGroupInfo
|
||||
|
||||
if (groupSessionId != other.groupSessionId) return false
|
||||
if (adminKey != null) {
|
||||
if (other.adminKey == null) return false
|
||||
if (!adminKey.contentEquals(other.adminKey)) return false
|
||||
} else if (other.adminKey != null) return false
|
||||
if (authData != null) {
|
||||
if (other.authData == null) return false
|
||||
if (!authData.contentEquals(other.authData)) return false
|
||||
} else if (other.authData != null) return false
|
||||
if (!adminKey.contentEquals(other.adminKey)) return false
|
||||
if (!authData.contentEquals(other.authData)) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = groupSessionId.hashCode()
|
||||
result = 31 * result + (adminKey?.contentHashCode() ?: 0)
|
||||
result = 31 * result + (authData?.contentHashCode() ?: 0)
|
||||
result = 31 * result + adminKey.contentHashCode()
|
||||
result = 31 * result + authData.contentHashCode()
|
||||
return result
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
data class LegacyGroupInfo(
|
||||
|
||||
Reference in New Issue
Block a user