mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-21 09:38:27 +00:00
Clean
This commit is contained in:
parent
e5b1174879
commit
281d921849
@ -21,6 +21,7 @@ object ClosedGroupsProtocol {
|
|||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun shouldIgnoreContentMessage(context: Context, conversation: Recipient, groupID: String?, content: SignalServiceContent): Boolean {
|
fun shouldIgnoreContentMessage(context: Context, conversation: Recipient, groupID: String?, content: SignalServiceContent): Boolean {
|
||||||
if (!conversation.address.isClosedGroup || groupID == null) { return false }
|
if (!conversation.address.isClosedGroup || groupID == null) { return false }
|
||||||
|
// A closed group's members should never include slave devices
|
||||||
val senderPublicKey = content.sender
|
val senderPublicKey = content.sender
|
||||||
val senderMasterPublicKey = MultiDeviceProtocol.shared.getMasterDevice(senderPublicKey)
|
val senderMasterPublicKey = MultiDeviceProtocol.shared.getMasterDevice(senderPublicKey)
|
||||||
val publicKeyToCheckFor = senderMasterPublicKey ?: senderPublicKey
|
val publicKeyToCheckFor = senderMasterPublicKey ?: senderPublicKey
|
||||||
|
@ -34,7 +34,7 @@ class MultiDeviceOpenGroupUpdateJob private constructor(parameters: Parameters)
|
|||||||
|
|
||||||
override fun getFactoryKey(): String { return KEY }
|
override fun getFactoryKey(): String { return KEY }
|
||||||
|
|
||||||
override fun serialize(): Data { return Data.EMPTY } // TODO: Should we implement this?
|
override fun serialize(): Data { return Data.EMPTY }
|
||||||
|
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
public override fun onRun() {
|
public override fun onRun() {
|
||||||
|
@ -31,7 +31,6 @@ class PushEphemeralMessageSendJob private constructor(parameters: Parameters, pr
|
|||||||
message)
|
message)
|
||||||
|
|
||||||
override fun serialize(): Data {
|
override fun serialize(): Data {
|
||||||
// TODO: Is this correct?
|
|
||||||
return Data.Builder()
|
return Data.Builder()
|
||||||
.putString(KEY_MESSAGE, message.serialize())
|
.putString(KEY_MESSAGE, message.serialize())
|
||||||
.build()
|
.build()
|
||||||
@ -41,23 +40,17 @@ class PushEphemeralMessageSendJob private constructor(parameters: Parameters, pr
|
|||||||
|
|
||||||
public override fun onRun() {
|
public override fun onRun() {
|
||||||
val recipient = message.get<String?>("recipient", null) ?: throw IllegalStateException()
|
val recipient = message.get<String?>("recipient", null) ?: throw IllegalStateException()
|
||||||
val dataMessage = SignalServiceDataMessage.newBuilder()
|
val dataMessage = SignalServiceDataMessage.newBuilder().withTimestamp(System.currentTimeMillis())
|
||||||
.withTimestamp(System.currentTimeMillis())
|
|
||||||
.withBody(message.get<String?>("body", null))
|
|
||||||
// Attach a pre key bundle if needed
|
// Attach a pre key bundle if needed
|
||||||
if (message.get("friendRequest", false)) {
|
if (message.get("friendRequest", false)) {
|
||||||
val bundle = DatabaseFactory.getLokiPreKeyBundleDatabase(context).generatePreKeyBundle(recipient)
|
val bundle = DatabaseFactory.getLokiPreKeyBundleDatabase(context).generatePreKeyBundle(recipient)
|
||||||
dataMessage.withPreKeyBundle(bundle).asFriendRequest(true)
|
dataMessage.withPreKeyBundle(bundle).asFriendRequest(true)
|
||||||
}
|
}
|
||||||
// Set flags if needed
|
// Set flags if needed (these are mutually exclusive)
|
||||||
if (message.get("unpairingRequest", false)) {
|
when {
|
||||||
dataMessage.asUnlinkingRequest(true)
|
message.get("unpairingRequest", false) -> dataMessage.asUnlinkingRequest(true)
|
||||||
}
|
message.get("sessionRestore", false) -> dataMessage.asSessionRestorationRequest(true)
|
||||||
if (message.get("sessionRestore", false)) {
|
message.get("sessionRequest", false) -> dataMessage.asSessionRequest(true)
|
||||||
dataMessage.asSessionRestorationRequest(true)
|
|
||||||
}
|
|
||||||
if (message.get("sessionRequest", false)) {
|
|
||||||
dataMessage.asSessionRequest(true)
|
|
||||||
}
|
}
|
||||||
// Send the message
|
// Send the message
|
||||||
val messageSender = ApplicationContext.getInstance(context).communicationModule.provideSignalMessageSender()
|
val messageSender = ApplicationContext.getInstance(context).communicationModule.provideSignalMessageSender()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user