mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-22 03:18:26 +00:00
implement destination from address
This commit is contained in:
parent
92b43b0fcf
commit
072aa0e7c6
@ -1,5 +1,9 @@
|
|||||||
package org.session.libsession.messaging.messages
|
package org.session.libsession.messaging.messages
|
||||||
|
|
||||||
|
import org.session.libsession.messaging.MessagingConfiguration
|
||||||
|
import org.session.libsession.messaging.threads.Address
|
||||||
|
import org.session.libsession.utilities.GroupUtil
|
||||||
|
|
||||||
sealed class Destination {
|
sealed class Destination {
|
||||||
|
|
||||||
class Contact(val publicKey: String) : Destination()
|
class Contact(val publicKey: String) : Destination()
|
||||||
@ -7,9 +11,19 @@ sealed class Destination {
|
|||||||
class OpenGroup(val channel: Long, val server: String) : Destination()
|
class OpenGroup(val channel: Long, val server: String) : Destination()
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
//TODO need to implement the equivalent to TSThread and then implement from(...)
|
fun from(address: Address): Destination {
|
||||||
fun from(threadID: String): Destination {
|
if (address.isContact) {
|
||||||
return Contact(threadID) // Fake for dev
|
return Contact(address.contactIdentifier())
|
||||||
|
} else if (address.isClosedGroup) {
|
||||||
|
val groupID = address.contactIdentifier().toByteArray()
|
||||||
|
val groupPublicKey = GroupUtil.getDecodedGroupID(groupID)
|
||||||
|
return ClosedGroup(groupPublicKey)
|
||||||
|
} else if (address.isOpenGroup) {
|
||||||
|
val openGroup = MessagingConfiguration.shared.storage.getOpenGroup(address.contactIdentifier())!!
|
||||||
|
return OpenGroup(openGroup.channel, openGroup.server)
|
||||||
|
} else {
|
||||||
|
throw Exception("TODO: Handle legacy closed groups.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user