mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
Clean
This commit is contained in:
parent
6a116100ae
commit
761c12addd
@ -49,7 +49,7 @@ import org.session.libsession.utilities.dynamiclanguage.DynamicLanguageContextWr
|
|||||||
import org.session.libsession.utilities.dynamiclanguage.LocaleParser;
|
import org.session.libsession.utilities.dynamiclanguage.LocaleParser;
|
||||||
import org.session.libsession.utilities.preferences.ProfileKeyUtil;
|
import org.session.libsession.utilities.preferences.ProfileKeyUtil;
|
||||||
import org.session.libsignal.service.api.util.StreamDetails;
|
import org.session.libsignal.service.api.util.StreamDetails;
|
||||||
import org.session.libsignal.service.loki.database.LokiAPIDatabaseProtocol;
|
import org.session.libsignal.service.loki.LokiAPIDatabaseProtocol;
|
||||||
import org.session.libsignal.utilities.logging.Log;
|
import org.session.libsignal.utilities.logging.Log;
|
||||||
import org.signal.aesgcmprovider.AesGcmProvider;
|
import org.signal.aesgcmprovider.AesGcmProvider;
|
||||||
import org.thoughtcrime.securesms.components.TypingStatusSender;
|
import org.thoughtcrime.securesms.components.TypingStatusSender;
|
||||||
@ -93,7 +93,6 @@ import org.webrtc.voiceengine.WebRtcAudioUtils;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.security.Security;
|
import java.security.Security;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -95,7 +95,7 @@ import org.session.libsession.utilities.GroupUtil;
|
|||||||
import org.session.libsession.utilities.MediaTypes;
|
import org.session.libsession.utilities.MediaTypes;
|
||||||
import org.session.libsignal.libsignal.InvalidMessageException;
|
import org.session.libsignal.libsignal.InvalidMessageException;
|
||||||
import org.session.libsignal.libsignal.util.guava.Optional;
|
import org.session.libsignal.libsignal.util.guava.Optional;
|
||||||
import org.session.libsignal.service.loki.utilities.mentions.Mention;
|
import org.session.libsignal.service.loki.Mention;
|
||||||
import org.session.libsignal.service.loki.utilities.HexEncodingKt;
|
import org.session.libsignal.service.loki.utilities.HexEncodingKt;
|
||||||
import org.session.libsignal.service.loki.utilities.PublicKeyValidation;
|
import org.session.libsignal.service.loki.utilities.PublicKeyValidation;
|
||||||
import org.thoughtcrime.securesms.ApplicationContext;
|
import org.thoughtcrime.securesms.ApplicationContext;
|
||||||
|
@ -25,7 +25,7 @@ import org.session.libsession.utilities.Util;
|
|||||||
|
|
||||||
import org.session.libsignal.libsignal.util.guava.Optional;
|
import org.session.libsignal.libsignal.util.guava.Optional;
|
||||||
import org.session.libsignal.service.api.messages.SignalServiceAttachmentPointer;
|
import org.session.libsignal.service.api.messages.SignalServiceAttachmentPointer;
|
||||||
import org.session.libsignal.service.loki.database.LokiOpenGroupDatabaseProtocol;
|
import org.session.libsignal.service.loki.LokiOpenGroupDatabaseProtocol;
|
||||||
|
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
|
@ -27,7 +27,7 @@ import kotlinx.coroutines.launch
|
|||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
import org.session.libsignal.libsignal.util.KeyHelper
|
import org.session.libsignal.libsignal.util.KeyHelper
|
||||||
import org.session.libsignal.service.loki.crypto.MnemonicCodec
|
import org.session.libsignal.service.loki.MnemonicCodec
|
||||||
import org.session.libsignal.service.loki.utilities.hexEncodedPublicKey
|
import org.session.libsignal.service.loki.utilities.hexEncodedPublicKey
|
||||||
import org.session.libsignal.utilities.Hex
|
import org.session.libsignal.utilities.Hex
|
||||||
import org.session.libsignal.utilities.logging.Log
|
import org.session.libsignal.utilities.logging.Log
|
||||||
|
@ -15,7 +15,7 @@ import kotlinx.android.synthetic.main.activity_recovery_phrase_restore.*
|
|||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
import org.session.libsignal.libsignal.util.KeyHelper
|
import org.session.libsignal.libsignal.util.KeyHelper
|
||||||
import org.session.libsignal.service.loki.crypto.MnemonicCodec
|
import org.session.libsignal.service.loki.MnemonicCodec
|
||||||
import org.session.libsignal.service.loki.utilities.hexEncodedPublicKey
|
import org.session.libsignal.service.loki.utilities.hexEncodedPublicKey
|
||||||
import org.session.libsignal.utilities.Hex
|
import org.session.libsignal.utilities.Hex
|
||||||
import org.thoughtcrime.securesms.BaseActionBarActivity
|
import org.thoughtcrime.securesms.BaseActionBarActivity
|
||||||
|
@ -16,7 +16,7 @@ import org.session.libsession.utilities.IdentityKeyUtil
|
|||||||
import org.thoughtcrime.securesms.loki.utilities.MnemonicUtilities
|
import org.thoughtcrime.securesms.loki.utilities.MnemonicUtilities
|
||||||
import org.thoughtcrime.securesms.loki.utilities.getColorWithID
|
import org.thoughtcrime.securesms.loki.utilities.getColorWithID
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
import org.session.libsignal.service.loki.crypto.MnemonicCodec
|
import org.session.libsignal.service.loki.MnemonicCodec
|
||||||
import org.session.libsignal.service.loki.utilities.hexEncodedPrivateKey
|
import org.session.libsignal.service.loki.utilities.hexEncodedPrivateKey
|
||||||
|
|
||||||
class SeedActivity : BaseActionBarActivity() {
|
class SeedActivity : BaseActionBarActivity() {
|
||||||
|
@ -8,7 +8,7 @@ import org.session.libsignal.libsignal.ecc.DjbECPrivateKey
|
|||||||
import org.session.libsignal.libsignal.ecc.DjbECPublicKey
|
import org.session.libsignal.libsignal.ecc.DjbECPublicKey
|
||||||
import org.session.libsignal.libsignal.ecc.ECKeyPair
|
import org.session.libsignal.libsignal.ecc.ECKeyPair
|
||||||
import org.session.libsignal.service.loki.Snode
|
import org.session.libsignal.service.loki.Snode
|
||||||
import org.session.libsignal.service.loki.database.LokiAPIDatabaseProtocol
|
import org.session.libsignal.service.loki.LokiAPIDatabaseProtocol
|
||||||
import org.session.libsignal.service.loki.utilities.PublicKeyValidation
|
import org.session.libsignal.service.loki.utilities.PublicKeyValidation
|
||||||
import org.session.libsignal.service.loki.utilities.removing05PrefixIfNeeded
|
import org.session.libsignal.service.loki.utilities.removing05PrefixIfNeeded
|
||||||
import org.session.libsignal.service.loki.utilities.toHexString
|
import org.session.libsignal.service.loki.utilities.toHexString
|
||||||
|
@ -2,7 +2,6 @@ package org.thoughtcrime.securesms.loki.database
|
|||||||
|
|
||||||
import android.content.ContentValues
|
import android.content.ContentValues
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import org.session.libsession.messaging.threads.Address
|
|
||||||
import org.thoughtcrime.securesms.database.Database
|
import org.thoughtcrime.securesms.database.Database
|
||||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||||
import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper
|
import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper
|
||||||
@ -10,7 +9,7 @@ import org.thoughtcrime.securesms.loki.utilities.get
|
|||||||
import org.thoughtcrime.securesms.loki.utilities.getInt
|
import org.thoughtcrime.securesms.loki.utilities.getInt
|
||||||
import org.thoughtcrime.securesms.loki.utilities.getString
|
import org.thoughtcrime.securesms.loki.utilities.getString
|
||||||
import org.thoughtcrime.securesms.loki.utilities.insertOrUpdate
|
import org.thoughtcrime.securesms.loki.utilities.insertOrUpdate
|
||||||
import org.session.libsignal.service.loki.database.LokiMessageDatabaseProtocol
|
import org.session.libsignal.service.loki.LokiMessageDatabaseProtocol
|
||||||
|
|
||||||
class LokiMessageDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(context, helper), LokiMessageDatabaseProtocol {
|
class LokiMessageDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(context, helper), LokiMessageDatabaseProtocol {
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ import org.thoughtcrime.securesms.loki.utilities.get
|
|||||||
import org.thoughtcrime.securesms.loki.utilities.insertOrUpdate
|
import org.thoughtcrime.securesms.loki.utilities.insertOrUpdate
|
||||||
import org.session.libsession.messaging.threads.recipients.Recipient
|
import org.session.libsession.messaging.threads.recipients.Recipient
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
import org.session.libsignal.service.loki.database.LokiUserDatabaseProtocol
|
import org.session.libsignal.service.loki.LokiUserDatabaseProtocol
|
||||||
|
|
||||||
class LokiUserDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(context, helper), LokiUserDatabaseProtocol {
|
class LokiUserDatabase(context: Context, helper: SQLCipherOpenHelper) : Database(context, helper), LokiUserDatabaseProtocol {
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ import kotlinx.android.synthetic.main.dialog_seed.view.*
|
|||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
import org.session.libsession.utilities.IdentityKeyUtil
|
import org.session.libsession.utilities.IdentityKeyUtil
|
||||||
import org.thoughtcrime.securesms.loki.utilities.MnemonicUtilities
|
import org.thoughtcrime.securesms.loki.utilities.MnemonicUtilities
|
||||||
import org.session.libsignal.service.loki.crypto.MnemonicCodec
|
import org.session.libsignal.service.loki.MnemonicCodec
|
||||||
import org.session.libsignal.service.loki.utilities.hexEncodedPrivateKey
|
import org.session.libsignal.service.loki.utilities.hexEncodedPrivateKey
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,8 +3,9 @@ package org.thoughtcrime.securesms.loki.utilities
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||||
|
import org.session.libsignal.service.loki.Broadcaster
|
||||||
|
|
||||||
class Broadcaster(private val context: Context) : org.session.libsignal.service.loki.utilities.Broadcaster {
|
class Broadcaster(private val context: Context) : Broadcaster {
|
||||||
|
|
||||||
override fun broadcast(event: String) {
|
override fun broadcast(event: String) {
|
||||||
val intent = Intent(event)
|
val intent = Intent(event)
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
package org.thoughtcrime.securesms.loki.utilities
|
package org.thoughtcrime.securesms.loki.utilities
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import org.session.libsignal.service.loki.crypto.MnemonicCodec
|
|
||||||
import org.session.libsignal.service.loki.utilities.removing05PrefixIfNeeded
|
|
||||||
import java.io.File
|
|
||||||
import java.io.FileOutputStream
|
|
||||||
|
|
||||||
object MnemonicUtilities {
|
object MnemonicUtilities {
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import android.widget.ListView
|
|||||||
import org.thoughtcrime.securesms.database.DatabaseFactory
|
import org.thoughtcrime.securesms.database.DatabaseFactory
|
||||||
import org.thoughtcrime.securesms.loki.utilities.toPx
|
import org.thoughtcrime.securesms.loki.utilities.toPx
|
||||||
import org.thoughtcrime.securesms.mms.GlideRequests
|
import org.thoughtcrime.securesms.mms.GlideRequests
|
||||||
import org.session.libsignal.service.loki.utilities.mentions.Mention
|
import org.session.libsignal.service.loki.Mention
|
||||||
|
|
||||||
class MentionCandidateSelectionView(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : ListView(context, attrs, defStyleAttr) {
|
class MentionCandidateSelectionView(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : ListView(context, attrs, defStyleAttr) {
|
||||||
private var mentionCandidates = listOf<Mention>()
|
private var mentionCandidates = listOf<Mention>()
|
||||||
|
@ -9,7 +9,7 @@ import android.widget.LinearLayout
|
|||||||
import kotlinx.android.synthetic.main.view_mention_candidate.view.*
|
import kotlinx.android.synthetic.main.view_mention_candidate.view.*
|
||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
import org.session.libsession.messaging.open_groups.OpenGroupAPI
|
import org.session.libsession.messaging.open_groups.OpenGroupAPI
|
||||||
import org.session.libsignal.service.loki.utilities.mentions.Mention
|
import org.session.libsignal.service.loki.Mention
|
||||||
import org.thoughtcrime.securesms.mms.GlideRequests
|
import org.thoughtcrime.securesms.mms.GlideRequests
|
||||||
|
|
||||||
class MentionCandidateView(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : LinearLayout(context, attrs, defStyleAttr) {
|
class MentionCandidateView(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : LinearLayout(context, attrs, defStyleAttr) {
|
||||||
|
@ -8,7 +8,7 @@ import org.session.libsession.snode.OnionRequestAPI
|
|||||||
import org.session.libsignal.utilities.logging.Log
|
import org.session.libsignal.utilities.logging.Log
|
||||||
import org.session.libsignal.utilities.Base64
|
import org.session.libsignal.utilities.Base64
|
||||||
import org.session.libsignal.utilities.JsonUtil
|
import org.session.libsignal.utilities.JsonUtil
|
||||||
import org.session.libsignal.service.loki.database.LokiAPIDatabaseProtocol
|
import org.session.libsignal.service.loki.LokiAPIDatabaseProtocol
|
||||||
import org.session.libsignal.service.loki.utilities.*
|
import org.session.libsignal.service.loki.utilities.*
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ import org.session.libsignal.service.internal.crypto.PaddingInputStream
|
|||||||
import org.session.libsignal.service.internal.push.PushAttachmentData
|
import org.session.libsignal.service.internal.push.PushAttachmentData
|
||||||
import org.session.libsignal.service.internal.push.http.AttachmentCipherOutputStreamFactory
|
import org.session.libsignal.service.internal.push.http.AttachmentCipherOutputStreamFactory
|
||||||
import org.session.libsignal.service.internal.util.Util
|
import org.session.libsignal.service.internal.util.Util
|
||||||
import org.session.libsignal.service.loki.utilities.PlaintextOutputStreamFactory
|
import org.session.libsignal.service.loki.PlaintextOutputStreamFactory
|
||||||
import org.session.libsignal.utilities.logging.Log
|
import org.session.libsignal.utilities.logging.Log
|
||||||
|
|
||||||
class AttachmentUploadJob(val attachmentID: Long, val threadID: String, val message: Message, val messageSendJobID: String) : Job {
|
class AttachmentUploadJob(val attachmentID: Long, val threadID: String, val message: Message, val messageSendJobID: String) : Job {
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package org.session.libsession.messaging.mentions
|
package org.session.libsession.messaging.mentions
|
||||||
|
|
||||||
import org.session.libsession.messaging.MessagingModuleConfiguration
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
import org.session.libsignal.service.loki.utilities.mentions.Mention
|
import org.session.libsignal.service.loki.Mention
|
||||||
|
|
||||||
import org.session.libsignal.service.loki.database.LokiUserDatabaseProtocol
|
import org.session.libsignal.service.loki.LokiUserDatabaseProtocol
|
||||||
|
|
||||||
class MentionsManager(private val userPublicKey: String, private val userDatabase: LokiUserDatabaseProtocol) {
|
class MentionsManager(private val userPublicKey: String, private val userDatabase: LokiUserDatabaseProtocol) {
|
||||||
var userPublicKeyCache = mutableMapOf<Long, Set<String>>() // Thread ID to set of user hex encoded public keys
|
var userPublicKeyCache = mutableMapOf<Long, Set<String>>() // Thread ID to set of user hex encoded public keys
|
||||||
|
@ -21,7 +21,6 @@ import java.util.*
|
|||||||
object OpenGroupAPI: DotNetAPI() {
|
object OpenGroupAPI: DotNetAPI() {
|
||||||
|
|
||||||
private val moderators: HashMap<String, HashMap<Long, Set<String>>> = hashMapOf() // Server URL to (channel ID to set of moderator IDs)
|
private val moderators: HashMap<String, HashMap<Long, Set<String>>> = hashMapOf() // Server URL to (channel ID to set of moderator IDs)
|
||||||
val sharedContext = Kovenant.createContext()
|
|
||||||
|
|
||||||
// region Settings
|
// region Settings
|
||||||
private val fallbackBatchCount = 64
|
private val fallbackBatchCount = 64
|
||||||
@ -61,7 +60,7 @@ object OpenGroupAPI: DotNetAPI() {
|
|||||||
parameters["count"] = fallbackBatchCount
|
parameters["count"] = fallbackBatchCount
|
||||||
parameters["include_deleted"] = 0
|
parameters["include_deleted"] = 0
|
||||||
}
|
}
|
||||||
return execute(HTTPVerb.GET, server, "channels/$channel/messages", parameters = parameters).then(sharedContext) { json ->
|
return execute(HTTPVerb.GET, server, "channels/$channel/messages", parameters = parameters).then { json ->
|
||||||
try {
|
try {
|
||||||
val data = json["data"] as List<Map<*, *>>
|
val data = json["data"] as List<Map<*, *>>
|
||||||
val messages = data.mapNotNull { message ->
|
val messages = data.mapNotNull { message ->
|
||||||
@ -166,7 +165,7 @@ object OpenGroupAPI: DotNetAPI() {
|
|||||||
} else {
|
} else {
|
||||||
parameters["count"] = fallbackBatchCount
|
parameters["count"] = fallbackBatchCount
|
||||||
}
|
}
|
||||||
return execute(HTTPVerb.GET, server, "loki/v1/channel/$channel/deletes", parameters = parameters).then(sharedContext) { json ->
|
return execute(HTTPVerb.GET, server, "loki/v1/channel/$channel/deletes", parameters = parameters).then { json ->
|
||||||
try {
|
try {
|
||||||
val deletedMessageServerIDs = (json["data"] as List<Map<*, *>>).mapNotNull { deletion ->
|
val deletedMessageServerIDs = (json["data"] as List<Map<*, *>>).mapNotNull { deletion ->
|
||||||
try {
|
try {
|
||||||
@ -202,7 +201,7 @@ object OpenGroupAPI: DotNetAPI() {
|
|||||||
retryIfNeeded(maxRetryCount) {
|
retryIfNeeded(maxRetryCount) {
|
||||||
Log.d("Loki", "Sending message to open group with ID: $channel on server: $server.")
|
Log.d("Loki", "Sending message to open group with ID: $channel on server: $server.")
|
||||||
val parameters = signedMessage.toJSON()
|
val parameters = signedMessage.toJSON()
|
||||||
execute(HTTPVerb.POST, server, "channels/$channel/messages", parameters = parameters).then(sharedContext) { json ->
|
execute(HTTPVerb.POST, server, "channels/$channel/messages", parameters = parameters).then { json ->
|
||||||
try {
|
try {
|
||||||
val data = json["data"] as Map<*, *>
|
val data = json["data"] as Map<*, *>
|
||||||
val serverID = (data["id"] as? Long) ?: (data["id"] as? Int)?.toLong() ?: (data["id"] as String).toLong()
|
val serverID = (data["id"] as? Long) ?: (data["id"] as? Int)?.toLong() ?: (data["id"] as String).toLong()
|
||||||
@ -255,7 +254,7 @@ object OpenGroupAPI: DotNetAPI() {
|
|||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun getModerators(channel: Long, server: String): Promise<Set<String>, Exception> {
|
fun getModerators(channel: Long, server: String): Promise<Set<String>, Exception> {
|
||||||
return execute(HTTPVerb.GET, server, "loki/v1/channel/$channel/get_moderators").then(sharedContext) { json ->
|
return execute(HTTPVerb.GET, server, "loki/v1/channel/$channel/get_moderators").then { json ->
|
||||||
try {
|
try {
|
||||||
@Suppress("UNCHECKED_CAST") val moderators = json["moderators"] as? List<String>
|
@Suppress("UNCHECKED_CAST") val moderators = json["moderators"] as? List<String>
|
||||||
val moderatorsAsSet = moderators.orEmpty().toSet()
|
val moderatorsAsSet = moderators.orEmpty().toSet()
|
||||||
@ -276,7 +275,7 @@ object OpenGroupAPI: DotNetAPI() {
|
|||||||
fun getChannelInfo(channel: Long, server: String): Promise<OpenGroupInfo, Exception> {
|
fun getChannelInfo(channel: Long, server: String): Promise<OpenGroupInfo, Exception> {
|
||||||
return retryIfNeeded(maxRetryCount) {
|
return retryIfNeeded(maxRetryCount) {
|
||||||
val parameters = mapOf( "include_annotations" to 1 )
|
val parameters = mapOf( "include_annotations" to 1 )
|
||||||
execute(HTTPVerb.GET, server, "/channels/$channel", parameters = parameters).then(sharedContext) { json ->
|
execute(HTTPVerb.GET, server, "/channels/$channel", parameters = parameters).then { json ->
|
||||||
try {
|
try {
|
||||||
val data = json["data"] as Map<*, *>
|
val data = json["data"] as Map<*, *>
|
||||||
val annotations = data["annotations"] as List<Map<*, *>>
|
val annotations = data["annotations"] as List<Map<*, *>>
|
||||||
@ -357,7 +356,7 @@ object OpenGroupAPI: DotNetAPI() {
|
|||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun getDisplayNames(publicKeys: Set<String>, server: String): Promise<Map<String, String>, Exception> {
|
fun getDisplayNames(publicKeys: Set<String>, server: String): Promise<Map<String, String>, Exception> {
|
||||||
return getUserProfiles(publicKeys, server, false).map(sharedContext) { json ->
|
return getUserProfiles(publicKeys, server, false).map { json ->
|
||||||
val mapping = mutableMapOf<String, String>()
|
val mapping = mutableMapOf<String, String>()
|
||||||
for (user in json) {
|
for (user in json) {
|
||||||
if (user["username"] != null) {
|
if (user["username"] != null) {
|
||||||
|
@ -23,7 +23,7 @@ import org.session.libsignal.service.internal.push.http.DigestingRequestBody
|
|||||||
import org.session.libsignal.service.internal.push.http.ProfileCipherOutputStreamFactory
|
import org.session.libsignal.service.internal.push.http.ProfileCipherOutputStreamFactory
|
||||||
import org.session.libsignal.utilities.Hex
|
import org.session.libsignal.utilities.Hex
|
||||||
import org.session.libsignal.utilities.JsonUtil
|
import org.session.libsignal.utilities.JsonUtil
|
||||||
import org.session.libsignal.service.loki.api.utilities.HTTP
|
import org.session.libsignal.service.loki.HTTP
|
||||||
import org.session.libsignal.service.loki.utilities.*
|
import org.session.libsignal.service.loki.utilities.*
|
||||||
import org.session.libsignal.utilities.*
|
import org.session.libsignal.utilities.*
|
||||||
import org.session.libsignal.utilities.Base64
|
import org.session.libsignal.utilities.Base64
|
||||||
|
@ -12,12 +12,14 @@ import org.session.libsignal.utilities.logging.Log
|
|||||||
import org.session.libsignal.utilities.Base64
|
import org.session.libsignal.utilities.Base64
|
||||||
import org.session.libsignal.utilities.*
|
import org.session.libsignal.utilities.*
|
||||||
import org.session.libsignal.service.loki.Snode
|
import org.session.libsignal.service.loki.Snode
|
||||||
import org.session.libsignal.service.loki.api.utilities.*
|
import org.session.libsignal.service.loki.*
|
||||||
import org.session.libsession.utilities.AESGCM.EncryptionResult
|
import org.session.libsession.utilities.AESGCM.EncryptionResult
|
||||||
import org.session.libsignal.utilities.ThreadUtils
|
import org.session.libsignal.utilities.ThreadUtils
|
||||||
import org.session.libsession.utilities.getBodyForOnionRequest
|
import org.session.libsession.utilities.getBodyForOnionRequest
|
||||||
import org.session.libsession.utilities.getHeadersForOnionRequest
|
import org.session.libsession.utilities.getHeadersForOnionRequest
|
||||||
import org.session.libsignal.service.loki.database.LokiAPIDatabaseProtocol
|
import org.session.libsignal.service.loki.Broadcaster
|
||||||
|
import org.session.libsignal.service.loki.HTTP
|
||||||
|
import org.session.libsignal.service.loki.LokiAPIDatabaseProtocol
|
||||||
import org.session.libsignal.service.loki.utilities.*
|
import org.session.libsignal.service.loki.utilities.*
|
||||||
|
|
||||||
private typealias Path = List<Snode>
|
private typealias Path = List<Snode>
|
||||||
|
@ -10,9 +10,9 @@ import org.session.libsession.messaging.utilities.MessageWrapper
|
|||||||
import org.session.libsession.snode.utilities.getRandomElement
|
import org.session.libsession.snode.utilities.getRandomElement
|
||||||
import org.session.libsignal.service.internal.push.SignalServiceProtos
|
import org.session.libsignal.service.internal.push.SignalServiceProtos
|
||||||
import org.session.libsignal.service.loki.Snode
|
import org.session.libsignal.service.loki.Snode
|
||||||
import org.session.libsignal.service.loki.api.utilities.HTTP
|
import org.session.libsignal.service.loki.HTTP
|
||||||
import org.session.libsignal.service.loki.database.LokiAPIDatabaseProtocol
|
import org.session.libsignal.service.loki.LokiAPIDatabaseProtocol
|
||||||
import org.session.libsignal.service.loki.utilities.Broadcaster
|
import org.session.libsignal.service.loki.Broadcaster
|
||||||
import org.session.libsignal.service.loki.utilities.prettifiedDescription
|
import org.session.libsignal.service.loki.utilities.prettifiedDescription
|
||||||
import org.session.libsignal.service.loki.utilities.removing05PrefixIfNeeded
|
import org.session.libsignal.service.loki.utilities.removing05PrefixIfNeeded
|
||||||
import org.session.libsignal.service.loki.utilities.retryIfNeeded
|
import org.session.libsignal.service.loki.utilities.retryIfNeeded
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package org.session.libsession.snode
|
package org.session.libsession.snode
|
||||||
|
|
||||||
import org.session.libsignal.service.loki.database.LokiAPIDatabaseProtocol
|
import org.session.libsignal.service.loki.LokiAPIDatabaseProtocol
|
||||||
import org.session.libsignal.service.loki.utilities.Broadcaster
|
import org.session.libsignal.service.loki.Broadcaster
|
||||||
|
|
||||||
class SnodeModule(val storage: LokiAPIDatabaseProtocol, val broadcaster: Broadcaster) {
|
class SnodeModule(val storage: LokiAPIDatabaseProtocol, val broadcaster: Broadcaster) {
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ import org.session.libsignal.service.api.messages.SignalServiceEnvelope;
|
|||||||
import org.session.libsignal.service.api.messages.SignalServiceGroup;
|
import org.session.libsignal.service.api.messages.SignalServiceGroup;
|
||||||
import org.session.libsignal.service.api.messages.SignalServiceReceiptMessage;
|
import org.session.libsignal.service.api.messages.SignalServiceReceiptMessage;
|
||||||
import org.session.libsignal.service.api.messages.SignalServiceTypingMessage;
|
import org.session.libsignal.service.api.messages.SignalServiceTypingMessage;
|
||||||
import org.session.libsignal.service.api.messages.shared.SharedContact;
|
|
||||||
import org.session.libsignal.service.api.push.SignalServiceAddress;
|
import org.session.libsignal.service.api.push.SignalServiceAddress;
|
||||||
import org.session.libsignal.service.internal.push.PushTransportDetails;
|
import org.session.libsignal.service.internal.push.PushTransportDetails;
|
||||||
import org.session.libsignal.service.internal.push.SignalServiceProtos;
|
import org.session.libsignal.service.internal.push.SignalServiceProtos;
|
||||||
@ -34,7 +33,7 @@ import org.session.libsignal.service.internal.push.SignalServiceProtos.ReceiptMe
|
|||||||
import org.session.libsignal.service.internal.push.SignalServiceProtos.TypingMessage;
|
import org.session.libsignal.service.internal.push.SignalServiceProtos.TypingMessage;
|
||||||
import org.session.libsignal.service.loki.api.crypto.SessionProtocol;
|
import org.session.libsignal.service.loki.api.crypto.SessionProtocol;
|
||||||
import org.session.libsignal.service.loki.api.crypto.SessionProtocolUtilities;
|
import org.session.libsignal.service.loki.api.crypto.SessionProtocolUtilities;
|
||||||
import org.session.libsignal.service.loki.database.LokiAPIDatabaseProtocol;
|
import org.session.libsignal.service.loki.LokiAPIDatabaseProtocol;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package org.session.libsignal.service.api.messages.shared;
|
package org.session.libsignal.service.api.messages.shared;
|
||||||
|
|
||||||
|
|
||||||
import org.session.libsignal.libsignal.util.guava.Optional;
|
import org.session.libsignal.libsignal.util.guava.Optional;
|
||||||
import org.session.libsignal.service.api.messages.SignalServiceAttachment;
|
import org.session.libsignal.service.api.messages.SignalServiceAttachment;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package org.session.libsignal.service.loki.utilities
|
package org.session.libsignal.service.loki
|
||||||
|
|
||||||
interface Broadcaster {
|
interface Broadcaster {
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package org.session.libsignal.service.loki.api.utilities
|
package org.session.libsignal.service.loki
|
||||||
|
|
||||||
import okhttp3.*
|
import okhttp3.*
|
||||||
import org.session.libsignal.utilities.logging.Log
|
import org.session.libsignal.utilities.logging.Log
|
@ -1,4 +1,4 @@
|
|||||||
package org.session.libsignal.service.loki.database
|
package org.session.libsignal.service.loki
|
||||||
|
|
||||||
import org.session.libsignal.libsignal.ecc.ECKeyPair
|
import org.session.libsignal.libsignal.ecc.ECKeyPair
|
||||||
import org.session.libsignal.service.loki.Snode
|
import org.session.libsignal.service.loki.Snode
|
@ -1,4 +1,4 @@
|
|||||||
package org.session.libsignal.service.loki.database
|
package org.session.libsignal.service.loki
|
||||||
|
|
||||||
interface LokiMessageDatabaseProtocol {
|
interface LokiMessageDatabaseProtocol {
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package org.session.libsignal.service.loki.database
|
package org.session.libsignal.service.loki
|
||||||
|
|
||||||
interface LokiOpenGroupDatabaseProtocol {
|
interface LokiOpenGroupDatabaseProtocol {
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package org.session.libsignal.service.loki.database
|
package org.session.libsignal.service.loki
|
||||||
|
|
||||||
interface LokiUserDatabaseProtocol {
|
interface LokiUserDatabaseProtocol {
|
||||||
|
|
@ -1,3 +1,3 @@
|
|||||||
package org.session.libsignal.service.loki.utilities.mentions
|
package org.session.libsignal.service.loki
|
||||||
|
|
||||||
data class Mention(val publicKey: String, val displayName: String)
|
data class Mention(val publicKey: String, val displayName: String)
|
@ -1,6 +1,5 @@
|
|||||||
package org.session.libsignal.service.loki.crypto
|
package org.session.libsignal.service.loki
|
||||||
|
|
||||||
import java.io.File
|
|
||||||
import java.util.zip.CRC32
|
import java.util.zip.CRC32
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -95,8 +94,10 @@ class MnemonicCodec(private val loadFileContents: (String) -> String) {
|
|||||||
var result = ""
|
var result = ""
|
||||||
val n = truncatedWordSet.size.toLong()
|
val n = truncatedWordSet.size.toLong()
|
||||||
// Check preconditions
|
// Check preconditions
|
||||||
if (words.size < 12) { throw DecodingError.InputTooShort }
|
if (words.size < 12) { throw DecodingError.InputTooShort
|
||||||
if (words.size % 3 == 0) { throw DecodingError.MissingLastWord }
|
}
|
||||||
|
if (words.size % 3 == 0) { throw DecodingError.MissingLastWord
|
||||||
|
}
|
||||||
// Get checksum word
|
// Get checksum word
|
||||||
val checksumWord = words.removeAt(words.lastIndex)
|
val checksumWord = words.removeAt(words.lastIndex)
|
||||||
// Decode
|
// Decode
|
||||||
@ -106,7 +107,8 @@ class MnemonicCodec(private val loadFileContents: (String) -> String) {
|
|||||||
val w2 = truncatedWordSet.indexOf(words[chunkStartIndex + 1].substring(0 until prefixLength))
|
val w2 = truncatedWordSet.indexOf(words[chunkStartIndex + 1].substring(0 until prefixLength))
|
||||||
val w3 = truncatedWordSet.indexOf(words[chunkStartIndex + 2].substring(0 until prefixLength))
|
val w3 = truncatedWordSet.indexOf(words[chunkStartIndex + 2].substring(0 until prefixLength))
|
||||||
val x = w1 + n * ((n - w1 + w2) % n) + n * n * ((n - w2 + w3) % n)
|
val x = w1 + n * ((n - w1 + w2) % n) + n * n * ((n - w2 + w3) % n)
|
||||||
if (x % n != w1.toLong()) { throw DecodingError.Generic }
|
if (x % n != w1.toLong()) { throw DecodingError.Generic
|
||||||
|
}
|
||||||
val string = "0000000" + x.toString(16)
|
val string = "0000000" + x.toString(16)
|
||||||
result += swap(string.substring(string.length - 8 until string.length))
|
result += swap(string.substring(string.length - 8 until string.length))
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
@ -116,7 +118,8 @@ class MnemonicCodec(private val loadFileContents: (String) -> String) {
|
|||||||
// Verify checksum
|
// Verify checksum
|
||||||
val checksumIndex = determineChecksumIndex(words, prefixLength)
|
val checksumIndex = determineChecksumIndex(words, prefixLength)
|
||||||
val expectedChecksumWord = words[checksumIndex]
|
val expectedChecksumWord = words[checksumIndex]
|
||||||
if (expectedChecksumWord.substring(0 until prefixLength) != checksumWord.substring(0 until prefixLength)) { throw DecodingError.VerificationFailed }
|
if (expectedChecksumWord.substring(0 until prefixLength) != checksumWord.substring(0 until prefixLength)) { throw DecodingError.VerificationFailed
|
||||||
|
}
|
||||||
// Return
|
// Return
|
||||||
return result
|
return result
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package org.session.libsignal.service.loki.utilities
|
package org.session.libsignal.service.loki
|
||||||
|
|
||||||
import org.session.libsignal.service.api.crypto.DigestingOutputStream
|
import org.session.libsignal.service.api.crypto.DigestingOutputStream
|
||||||
import org.session.libsignal.service.internal.push.http.OutputStreamFactory
|
import org.session.libsignal.service.internal.push.http.OutputStreamFactory
|
@ -1,7 +1,7 @@
|
|||||||
package org.session.libsignal.service.loki.api.crypto
|
package org.session.libsignal.service.loki.api.crypto
|
||||||
|
|
||||||
import org.session.libsignal.libsignal.ecc.ECKeyPair
|
import org.session.libsignal.libsignal.ecc.ECKeyPair
|
||||||
import org.session.libsignal.service.loki.database.LokiAPIDatabaseProtocol
|
import org.session.libsignal.service.loki.LokiAPIDatabaseProtocol
|
||||||
|
|
||||||
interface SessionProtocol {
|
interface SessionProtocol {
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package org.session.libsignal.service.loki.api
|
package org.session.libsignal.service.loki
|
||||||
|
|
||||||
import org.session.libsignal.service.internal.push.SignalServiceProtos
|
import org.session.libsignal.service.internal.push.SignalServiceProtos
|
||||||
|
|
@ -1,49 +0,0 @@
|
|||||||
package org.session.libsignal.service.loki.api.utilities
|
|
||||||
|
|
||||||
import okhttp3.MultipartBody
|
|
||||||
import okhttp3.Request
|
|
||||||
import okio.Buffer
|
|
||||||
import org.session.libsignal.utilities.Base64
|
|
||||||
import java.io.IOException
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
internal fun Request.getHeadersForOnionRequest(): Map<String, Any> {
|
|
||||||
val result = mutableMapOf<String, Any>()
|
|
||||||
val contentType = body()?.contentType()
|
|
||||||
if (contentType != null) {
|
|
||||||
result["content-type"] = contentType.toString()
|
|
||||||
}
|
|
||||||
val headers = headers()
|
|
||||||
for (name in headers.names()) {
|
|
||||||
val value = headers.get(name)
|
|
||||||
if (value != null) {
|
|
||||||
if (value.toLowerCase(Locale.US) == "true" || value.toLowerCase(Locale.US) == "false") {
|
|
||||||
result[name] = value.toBoolean()
|
|
||||||
} else if (value.toIntOrNull() != null) {
|
|
||||||
result[name] = value.toInt()
|
|
||||||
} else {
|
|
||||||
result[name] = value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
internal fun Request.getBodyForOnionRequest(): Any? {
|
|
||||||
try {
|
|
||||||
val copyOfThis = newBuilder().build()
|
|
||||||
val buffer = Buffer()
|
|
||||||
val body = copyOfThis.body() ?: return null
|
|
||||||
body.writeTo(buffer)
|
|
||||||
val bodyAsData = buffer.readByteArray()
|
|
||||||
if (body is MultipartBody) {
|
|
||||||
val base64EncodedBody: String = Base64.encodeBytes(bodyAsData)
|
|
||||||
return mapOf( "fileUpload" to base64EncodedBody )
|
|
||||||
} else {
|
|
||||||
val charset = body.contentType()?.charset() ?: Charsets.UTF_8
|
|
||||||
return bodyAsData?.toString(charset)
|
|
||||||
}
|
|
||||||
} catch (e: IOException) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}
|
|
@ -58,7 +58,7 @@ public class JsonUtil {
|
|||||||
return objectMapper.writeValueAsString(object);
|
return objectMapper.writeValueAsString(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String toJson(Object object) {
|
public static String toJson(Object object) {
|
||||||
try {
|
try {
|
||||||
return objectMapper.writeValueAsString(object);
|
return objectMapper.writeValueAsString(object);
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
@ -67,32 +67,11 @@ public class JsonUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class IdentityKeySerializer extends JsonSerializer<IdentityKey> {
|
|
||||||
@Override
|
|
||||||
public void serialize(IdentityKey value, JsonGenerator gen, SerializerProvider serializers)
|
|
||||||
throws IOException
|
|
||||||
{
|
|
||||||
gen.writeString(Base64.encodeBytesWithoutPadding(value.serialize()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class IdentityKeyDeserializer extends JsonDeserializer<IdentityKey> {
|
|
||||||
@Override
|
|
||||||
public IdentityKey deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
|
|
||||||
try {
|
|
||||||
return new IdentityKey(Base64.decodeWithoutPadding(p.getValueAsString()), 0);
|
|
||||||
} catch (InvalidKeyException e) {
|
|
||||||
throw new IOException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ObjectMapper getMapper() {
|
public static ObjectMapper getMapper() {
|
||||||
return objectMapper;
|
return objectMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SaneJSONObject {
|
public static class SaneJSONObject {
|
||||||
|
|
||||||
private final JSONObject delegate;
|
private final JSONObject delegate;
|
||||||
|
|
||||||
public SaneJSONObject(JSONObject delegate) {
|
public SaneJSONObject(JSONObject delegate) {
|
||||||
|
@ -1,25 +1,11 @@
|
|||||||
@file:JvmName("PromiseUtilities")
|
@file:JvmName("PromiseUtilities")
|
||||||
package org.session.libsignal.utilities
|
package org.session.libsignal.utilities
|
||||||
|
|
||||||
import nl.komponents.kovenant.Context
|
|
||||||
import nl.komponents.kovenant.Kovenant
|
|
||||||
import nl.komponents.kovenant.Promise
|
import nl.komponents.kovenant.Promise
|
||||||
import nl.komponents.kovenant.deferred
|
import nl.komponents.kovenant.deferred
|
||||||
import nl.komponents.kovenant.jvm.asDispatcher
|
|
||||||
import org.session.libsignal.utilities.logging.Log
|
import org.session.libsignal.utilities.logging.Log
|
||||||
import java.util.concurrent.Executors
|
|
||||||
import java.util.concurrent.TimeoutException
|
import java.util.concurrent.TimeoutException
|
||||||
|
|
||||||
fun Kovenant.createContext(): Context {
|
|
||||||
return createContext {
|
|
||||||
callbackContext.dispatcher = Executors.newSingleThreadExecutor().asDispatcher()
|
|
||||||
workerContext.dispatcher = ThreadUtils.executorPool.asDispatcher()
|
|
||||||
multipleCompletion = { v1, v2 ->
|
|
||||||
Log.d("Loki", "Promise resolved more than once (first with $v1, then with $v2); ignoring $v2.")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun <V, E : Throwable> Promise<V, E>.get(defaultValue: V): V {
|
fun <V, E : Throwable> Promise<V, E>.get(defaultValue: V): V {
|
||||||
return try {
|
return try {
|
||||||
get()
|
get()
|
||||||
|
@ -3,7 +3,6 @@ package org.session.libsignal.utilities
|
|||||||
import java.util.concurrent.*
|
import java.util.concurrent.*
|
||||||
|
|
||||||
object ThreadUtils {
|
object ThreadUtils {
|
||||||
|
|
||||||
val executorPool = Executors.newCachedThreadPool()
|
val executorPool = Executors.newCachedThreadPool()
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@ -17,10 +16,8 @@ object ThreadUtils {
|
|||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun newDynamicSingleThreadedExecutor(): ExecutorService {
|
fun newDynamicSingleThreadedExecutor(): ExecutorService {
|
||||||
val executor = ThreadPoolExecutor(1, 1, 60, TimeUnit.SECONDS,
|
val executor = ThreadPoolExecutor(1, 1, 60, TimeUnit.SECONDS, LinkedBlockingQueue())
|
||||||
LinkedBlockingQueue())
|
|
||||||
executor.allowCoreThreadTimeOut(true)
|
executor.allowCoreThreadTimeOut(true)
|
||||||
return executor
|
return executor
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user