mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-19 19:18:27 +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
|
||||
|
||||
import org.session.libsession.messaging.MessagingConfiguration
|
||||
import org.session.libsession.messaging.threads.Address
|
||||
import org.session.libsession.utilities.GroupUtil
|
||||
|
||||
sealed class Destination {
|
||||
|
||||
class Contact(val publicKey: String) : Destination()
|
||||
@ -7,9 +11,19 @@ sealed class Destination {
|
||||
class OpenGroup(val channel: Long, val server: String) : Destination()
|
||||
|
||||
companion object {
|
||||
//TODO need to implement the equivalent to TSThread and then implement from(...)
|
||||
fun from(threadID: String): Destination {
|
||||
return Contact(threadID) // Fake for dev
|
||||
fun from(address: Address): Destination {
|
||||
if (address.isContact) {
|
||||
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