mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-30 13:35:18 +00:00
fix: slight UI and handling protocols at onion request level
This commit is contained in:
parent
2999c138aa
commit
fe8dc2d392
@ -4,8 +4,7 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:theme="@style/Theme.MaterialComponents.DayNight"
|
android:theme="@style/Theme.MaterialComponents.DayNight"
|
||||||
style="?attr/chipStyle"
|
style="?attr/chipStyle"
|
||||||
app:textStartPadding="10dp"
|
app:chipStartPadding="6dp"
|
||||||
app:textEndPadding="10dp"
|
|
||||||
android:layout_columnWeight="1"
|
android:layout_columnWeight="1"
|
||||||
android:layout_marginHorizontal="2dp"
|
android:layout_marginHorizontal="2dp"
|
||||||
tools:text="Main Group"
|
tools:text="Main Group"
|
||||||
|
@ -17,6 +17,8 @@ import org.session.libsession.messaging.MessagingModuleConfiguration
|
|||||||
import org.session.libsession.messaging.open_groups.OpenGroupAPIV2.Error
|
import org.session.libsession.messaging.open_groups.OpenGroupAPIV2.Error
|
||||||
import org.session.libsession.snode.OnionRequestAPI
|
import org.session.libsession.snode.OnionRequestAPI
|
||||||
import org.session.libsession.utilities.AESGCM
|
import org.session.libsession.utilities.AESGCM
|
||||||
|
import org.session.libsession.utilities.GroupUtil
|
||||||
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
import org.session.libsignal.service.loki.api.utilities.HTTP
|
import org.session.libsignal.service.loki.api.utilities.HTTP
|
||||||
import org.session.libsignal.service.loki.api.utilities.HTTP.Verb.*
|
import org.session.libsignal.service.loki.api.utilities.HTTP.Verb.*
|
||||||
import org.session.libsignal.service.loki.utilities.removing05PrefixIfNeeded
|
import org.session.libsignal.service.loki.utilities.removing05PrefixIfNeeded
|
||||||
@ -29,13 +31,11 @@ import org.session.libsignal.utilities.logging.Log
|
|||||||
import org.whispersystems.curve25519.Curve25519
|
import org.whispersystems.curve25519.Curve25519
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
typealias DeletionList = List<OpenGroupAPIV2.MessageDeletion>
|
|
||||||
|
|
||||||
object OpenGroupAPIV2 {
|
object OpenGroupAPIV2 {
|
||||||
|
|
||||||
private val moderators: HashMap<String, Set<String>> = hashMapOf() // Server URL to (channel ID to set of moderator IDs)
|
private val moderators: HashMap<String, Set<String>> = hashMapOf() // Server URL to (channel ID to set of moderator IDs)
|
||||||
const val DEFAULT_SERVER = "https://sog.ibolpap.finance"
|
const val DEFAULT_SERVER = "http://116.203.70.33"
|
||||||
private const val DEFAULT_SERVER_PUBLIC_KEY = "b464aa186530c97d6bcf663a3a3b7465a5f782beaa67c83bee99468824b4aa10"
|
private const val DEFAULT_SERVER_PUBLIC_KEY = "a03c383cf63c3c4efe67acc52112a6dd734b3a946b9545f488aaa93da7991238"
|
||||||
|
|
||||||
val defaultRooms = MutableSharedFlow<List<DefaultGroup>>(replay = 1)
|
val defaultRooms = MutableSharedFlow<List<DefaultGroup>>(replay = 1)
|
||||||
|
|
||||||
|
@ -62,8 +62,8 @@ data class OpenGroupMessageV2(
|
|||||||
return jsonMap
|
return jsonMap
|
||||||
}
|
}
|
||||||
|
|
||||||
fun toProto(): SignalServiceProtos.DataMessage = decode(base64EncodedData).let(PushTransportDetails::getStrippedPaddingMessageBody).let { bytes ->
|
fun toProto(): SignalServiceProtos.Content = decode(base64EncodedData).let(PushTransportDetails::getStrippedPaddingMessageBody).let { bytes ->
|
||||||
SignalServiceProtos.DataMessage.parseFrom(bytes)
|
SignalServiceProtos.Content.parseFrom(bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -262,7 +262,7 @@ object MessageSender {
|
|||||||
val openGroupMessage = OpenGroupMessageV2(
|
val openGroupMessage = OpenGroupMessageV2(
|
||||||
sender = message.sender,
|
sender = message.sender,
|
||||||
sentTimestamp = message.sentTimestamp!!,
|
sentTimestamp = message.sentTimestamp!!,
|
||||||
base64EncodedData = Base64.encodeBytes(PushTransportDetails.getPaddedMessageBody(proto.dataMessage!!.toByteArray())),
|
base64EncodedData = Base64.encodeBytes(proto.toByteArray()),
|
||||||
)
|
)
|
||||||
|
|
||||||
OpenGroupAPIV2.send(openGroupMessage,room,server).success {
|
OpenGroupAPIV2.send(openGroupMessage,room,server).success {
|
||||||
|
@ -170,7 +170,8 @@ fun MessageReceiver.handleVisibleMessage(message: VisibleMessage, proto: SignalS
|
|||||||
if (displayName.isNotEmpty()) {
|
if (displayName.isNotEmpty()) {
|
||||||
profileManager.setDisplayName(context, recipient, displayName)
|
profileManager.setDisplayName(context, recipient, displayName)
|
||||||
}
|
}
|
||||||
if (newProfile.profileKey?.isNotEmpty() == true && !MessageDigest.isEqual(recipient.profileKey, newProfile.profileKey)) {
|
if (newProfile.profileKey?.isNotEmpty() == true
|
||||||
|
&& (recipient.profileKey == null || !MessageDigest.isEqual(recipient.profileKey, newProfile.profileKey))) {
|
||||||
profileManager.setProfileKey(context, recipient, newProfile.profileKey!!)
|
profileManager.setProfileKey(context, recipient, newProfile.profileKey!!)
|
||||||
profileManager.setUnidentifiedAccessMode(context, recipient, Recipient.UnidentifiedAccessMode.UNKNOWN)
|
profileManager.setUnidentifiedAccessMode(context, recipient, Recipient.UnidentifiedAccessMode.UNKNOWN)
|
||||||
val newUrl = newProfile.profilePictureURL
|
val newUrl = newProfile.profilePictureURL
|
||||||
|
@ -90,16 +90,12 @@ class OpenGroupV2Poller(private val openGroups: List<OpenGroupV2>, private val e
|
|||||||
try {
|
try {
|
||||||
val senderPublicKey = message.sender!!
|
val senderPublicKey = message.sender!!
|
||||||
// Main message
|
// Main message
|
||||||
val dataMessageProto = message.toProto()
|
|
||||||
// Content
|
|
||||||
val content = SignalServiceProtos.Content.newBuilder()
|
|
||||||
content.dataMessage = dataMessageProto
|
|
||||||
// Envelope
|
// Envelope
|
||||||
val builder = SignalServiceProtos.Envelope.newBuilder()
|
val builder = SignalServiceProtos.Envelope.newBuilder()
|
||||||
builder.type = SignalServiceProtos.Envelope.Type.SESSION_MESSAGE
|
builder.type = SignalServiceProtos.Envelope.Type.SESSION_MESSAGE
|
||||||
builder.source = senderPublicKey
|
builder.source = senderPublicKey
|
||||||
builder.sourceDevice = 1
|
builder.sourceDevice = 1
|
||||||
builder.content = content.build().toByteString()
|
builder.content = message.toProto().toByteString()
|
||||||
builder.timestamp = message.sentTimestamp
|
builder.timestamp = message.sentTimestamp
|
||||||
val envelope = builder.build()
|
val envelope = builder.build()
|
||||||
val job = MessageReceiveJob(envelope.toByteArray(), isBackgroundPoll, message.serverID, serverRoomId)
|
val job = MessageReceiveJob(envelope.toByteArray(), isBackgroundPoll, message.serverID, serverRoomId)
|
||||||
|
@ -79,7 +79,7 @@ object OnionRequestAPI {
|
|||||||
|
|
||||||
internal sealed class Destination {
|
internal sealed class Destination {
|
||||||
class Snode(val snode: org.session.libsignal.service.loki.Snode) : Destination()
|
class Snode(val snode: org.session.libsignal.service.loki.Snode) : Destination()
|
||||||
class Server(val host: String, val target: String, val x25519PublicKey: String) : Destination()
|
class Server(val host: String, val target: String, val x25519PublicKey: String, val scheme: String, val port: Int) : Destination()
|
||||||
}
|
}
|
||||||
|
|
||||||
// region Private API
|
// region Private API
|
||||||
@ -461,7 +461,8 @@ object OnionRequestAPI {
|
|||||||
"method" to request.method(),
|
"method" to request.method(),
|
||||||
"headers" to headers
|
"headers" to headers
|
||||||
)
|
)
|
||||||
val destination = Destination.Server(host, target, x25519PublicKey)
|
url.isHttps
|
||||||
|
val destination = Destination.Server(host, target, x25519PublicKey, url.scheme(), url.port())
|
||||||
return sendOnionRequest(destination, payload, isJSONRequired).recover { exception ->
|
return sendOnionRequest(destination, payload, isJSONRequired).recover { exception ->
|
||||||
Log.d("Loki", "Couldn't reach server: $urlAsString due to error: $exception.")
|
Log.d("Loki", "Couldn't reach server: $urlAsString due to error: $exception.")
|
||||||
throw exception
|
throw exception
|
||||||
|
@ -70,7 +70,13 @@ object OnionRequestEncryption {
|
|||||||
payload = mutableMapOf( "destination" to rhs.snode.publicKeySet!!.ed25519Key )
|
payload = mutableMapOf( "destination" to rhs.snode.publicKeySet!!.ed25519Key )
|
||||||
}
|
}
|
||||||
is OnionRequestAPI.Destination.Server -> {
|
is OnionRequestAPI.Destination.Server -> {
|
||||||
payload = mutableMapOf( "host" to rhs.host, "target" to rhs.target, "method" to "POST" )
|
payload = mutableMapOf(
|
||||||
|
"host" to rhs.host,
|
||||||
|
"target" to rhs.target,
|
||||||
|
"method" to "POST",
|
||||||
|
"protocol" to rhs.scheme,
|
||||||
|
"port" to rhs.port
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
payload["ephemeral_key"] = previousEncryptionResult.ephemeralPublicKey.toHexString()
|
payload["ephemeral_key"] = previousEncryptionResult.ephemeralPublicKey.toHexString()
|
||||||
|
Loading…
Reference in New Issue
Block a user