mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-25 11:05:25 +00:00
Compilation errors
This commit is contained in:
parent
6814f0abe2
commit
1b9b5dd42c
@ -912,7 +912,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
|||||||
}
|
}
|
||||||
|
|
||||||
// show or hide loading indicator
|
// show or hide loading indicator
|
||||||
binding.loader.isVisible = uiState.showLoader
|
binding.loader.isVisible = state.showLoader
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -303,9 +303,8 @@ open class Storage @Inject constructor(
|
|||||||
|
|
||||||
override fun deleteMessagesByHash(threadId: Long, hashes: List<String>) {
|
override fun deleteMessagesByHash(threadId: Long, hashes: List<String>) {
|
||||||
val info = lokiMessageDatabase.getSendersForHashes(threadId, hashes.toSet())
|
val info = lokiMessageDatabase.getSendersForHashes(threadId, hashes.toSet())
|
||||||
// TODO: no idea if we need to server delete this
|
|
||||||
for ((serverHash, sender, messageIdToDelete, isSms) in info) {
|
for ((serverHash, sender, messageIdToDelete, isSms) in info) {
|
||||||
messageDataProvider.updateMessageAsDeleted(messageIdToDelete, isSms)
|
messageDataProvider.deleteMessage(messageIdToDelete, isSms)
|
||||||
if (!messageDataProvider.isOutgoingMessage(messageIdToDelete)) {
|
if (!messageDataProvider.isOutgoingMessage(messageIdToDelete)) {
|
||||||
notificationManager.updateNotification(context)
|
notificationManager.updateNotification(context)
|
||||||
}
|
}
|
||||||
@ -662,9 +661,8 @@ open class Storage @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getMessageType(timestamp: Long, author: String): MessageType? {
|
override fun getMessageType(timestamp: Long, author: String): MessageType? {
|
||||||
val database = DatabaseComponent.get(context).mmsSmsDatabase()
|
|
||||||
val address = fromSerialized(author)
|
val address = fromSerialized(author)
|
||||||
return database.getMessageFor(timestamp, address)?.individualRecipient?.getType()
|
return mmsSmsDatabase.getMessageFor(timestamp, address)?.individualRecipient?.getType()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun updateSentTimestamp(
|
override fun updateSentTimestamp(
|
||||||
@ -1817,7 +1815,7 @@ open class Storage @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun deleteReactions(messageIds: List<Long>, mms: Boolean) {
|
override fun deleteReactions(messageIds: List<Long>, mms: Boolean) {
|
||||||
DatabaseComponent.get(context).reactionDatabase().deleteMessageReactions(
|
reactionDatabase.deleteMessageReactions(
|
||||||
messageIds.map { MessageId(it, mms) }
|
messageIds.map { MessageId(it, mms) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,6 @@ class EditGroupViewModel @AssistedInject constructor(
|
|||||||
val editingName: StateFlow<String?> get() = mutableEditingName
|
val editingName: StateFlow<String?> get() = mutableEditingName
|
||||||
|
|
||||||
// Output: the source-of-truth group information. Other states are derived from this.
|
// Output: the source-of-truth group information. Other states are derived from this.
|
||||||
@OptIn(ExperimentalCoroutinesApi::class)
|
|
||||||
private val groupInfo: StateFlow<Pair<GroupDisplayInfo, List<GroupMemberState>>?> =
|
private val groupInfo: StateFlow<Pair<GroupDisplayInfo, List<GroupMemberState>>?> =
|
||||||
combine(
|
combine(
|
||||||
configFactory.configUpdateNotifications
|
configFactory.configUpdateNotifications
|
||||||
@ -77,9 +76,10 @@ class EditGroupViewModel @AssistedInject constructor(
|
|||||||
?: return@withContext null
|
?: return@withContext null
|
||||||
|
|
||||||
val members = storage.getMembers(groupId.hexString)
|
val members = storage.getMembers(groupId.hexString)
|
||||||
.asSequence()
|
.filterTo(mutableListOf()) { !it.removed }
|
||||||
.filter { !it.removed }
|
sortMembers(members, currentUserId)
|
||||||
.mapTo(arrayListOf()) { member ->
|
|
||||||
|
displayInfo to members.map { member ->
|
||||||
createGroupMember(
|
createGroupMember(
|
||||||
member = member,
|
member = member,
|
||||||
myAccountId = currentUserId,
|
myAccountId = currentUserId,
|
||||||
@ -87,10 +87,6 @@ class EditGroupViewModel @AssistedInject constructor(
|
|||||||
pendingState = pending[AccountId(member.sessionId)]
|
pendingState = pending[AccountId(member.sessionId)]
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
sortMembers(members, currentUserId)
|
|
||||||
|
|
||||||
displayInfo to members
|
|
||||||
}
|
}
|
||||||
}.stateIn(viewModelScope, SharingStarted.Eagerly, null)
|
}.stateIn(viewModelScope, SharingStarted.Eagerly, null)
|
||||||
|
|
||||||
@ -181,16 +177,16 @@ class EditGroupViewModel @AssistedInject constructor(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun sortMembers(members: MutableList<GroupMemberState>, currentUserId: String) {
|
private fun sortMembers(members: MutableList<GroupMember>, currentUserId: String) {
|
||||||
// Order or members:
|
|
||||||
// 1. Current user always comes first
|
|
||||||
// 2. Then sort by name
|
|
||||||
// 3. Then sort by account ID
|
|
||||||
members.sortWith(
|
members.sortWith(
|
||||||
compareBy(
|
compareBy(
|
||||||
{ it.accountId != currentUserId },
|
{ !it.inviteFailed }, // Failed invite comes first (as false value is less than true)
|
||||||
{ it.name },
|
{ memberPendingState.value[AccountId(it.sessionId)] != MemberPendingState.Inviting }, // "Sending invite" comes first
|
||||||
{ it.accountId }
|
{ !it.invitePending }, // "Invite sent" comes first
|
||||||
|
{ !it.isAdminOrBeingPromoted }, // Admins come first
|
||||||
|
{ it.sessionId != currentUserId }, // Being myself comes first
|
||||||
|
{ it.name }, // Sort by name
|
||||||
|
{ it.sessionId } // Last resort: sort by account ID
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -326,7 +326,7 @@ class GroupManagerV2Impl @Inject constructor(
|
|||||||
OwnedSwarmAuth.ofClosedGroup(groupAccountId, it)
|
OwnedSwarmAuth.ofClosedGroup(groupAccountId, it)
|
||||||
} ?: return@withContext
|
} ?: return@withContext
|
||||||
|
|
||||||
SnodeAPI.deleteMessage(groupAccountId.hexString, groupAdminAuth, messagesToDelete).await()
|
SnodeAPI.deleteMessage(groupAccountId.hexString, groupAdminAuth, messagesToDelete)
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun handleMemberLeft(message: GroupUpdated, group: AccountId) {
|
override suspend fun handleMemberLeft(message: GroupUpdated, group: AccountId) {
|
||||||
@ -831,7 +831,7 @@ class GroupManagerV2Impl @Inject constructor(
|
|||||||
publicKey = groupId.hexString,
|
publicKey = groupId.hexString,
|
||||||
swarmAuth = OwnedSwarmAuth.ofClosedGroup(groupId, adminKey),
|
swarmAuth = OwnedSwarmAuth.ofClosedGroup(groupId, adminKey),
|
||||||
serverHashes = messageHashes
|
serverHashes = messageHashes
|
||||||
).await()
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct a message to ask members to delete the messages, sign if we are admin, then send
|
// Construct a message to ask members to delete the messages, sign if we are admin, then send
|
||||||
@ -918,7 +918,7 @@ class GroupManagerV2Impl @Inject constructor(
|
|||||||
groupId.hexString,
|
groupId.hexString,
|
||||||
OwnedSwarmAuth.ofClosedGroup(groupId, adminKey),
|
OwnedSwarmAuth.ofClosedGroup(groupId, adminKey),
|
||||||
hashes
|
hashes
|
||||||
).await()
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// The non-admin user shouldn't be able to delete other user's messages so we will
|
// The non-admin user shouldn't be able to delete other user's messages so we will
|
||||||
|
@ -90,7 +90,7 @@ class PushReceiver @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
Log.w(TAG, "Received a push notification with an unknown namespace: ${metadata.namespace}")
|
Log.w(TAG, "Received a push notification with an unknown namespace: ${pushData.metadata.namespace}")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,8 +30,6 @@ import org.session.libsession.utilities.GroupUtil
|
|||||||
import org.session.libsession.utilities.TextSecurePreferences
|
import org.session.libsession.utilities.TextSecurePreferences
|
||||||
import org.session.libsession.utilities.recipients.Recipient
|
import org.session.libsession.utilities.recipients.Recipient
|
||||||
import org.session.libsignal.utilities.AccountId
|
import org.session.libsignal.utilities.AccountId
|
||||||
import org.session.libsignal.utilities.Log
|
|
||||||
import org.session.libsignal.utilities.toHexString
|
|
||||||
import org.thoughtcrime.securesms.database.DatabaseContentProviders
|
import org.thoughtcrime.securesms.database.DatabaseContentProviders
|
||||||
import org.thoughtcrime.securesms.database.DraftDatabase
|
import org.thoughtcrime.securesms.database.DraftDatabase
|
||||||
import org.thoughtcrime.securesms.database.LokiMessageDatabase
|
import org.thoughtcrime.securesms.database.LokiMessageDatabase
|
||||||
@ -46,8 +44,6 @@ import org.thoughtcrime.securesms.database.model.MessageRecord
|
|||||||
import org.thoughtcrime.securesms.database.model.ThreadRecord
|
import org.thoughtcrime.securesms.database.model.ThreadRecord
|
||||||
import org.thoughtcrime.securesms.dependencies.ConfigFactory
|
import org.thoughtcrime.securesms.dependencies.ConfigFactory
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import kotlin.coroutines.resume
|
|
||||||
import kotlin.coroutines.suspendCoroutine
|
|
||||||
|
|
||||||
interface ConversationRepository {
|
interface ConversationRepository {
|
||||||
fun maybeGetRecipientForThreadId(threadId: Long): Recipient?
|
fun maybeGetRecipientForThreadId(threadId: Long): Recipient?
|
||||||
@ -81,7 +77,6 @@ interface ConversationRepository {
|
|||||||
messages: Set<MessageRecord>
|
messages: Set<MessageRecord>
|
||||||
)
|
)
|
||||||
|
|
||||||
fun buildUnsendRequest(recipient: Recipient, message: MessageRecord): UnsendRequest?
|
|
||||||
suspend fun banUser(threadId: Long, recipient: Recipient): Result<Unit>
|
suspend fun banUser(threadId: Long, recipient: Recipient): Result<Unit>
|
||||||
suspend fun banAndDeleteAll(threadId: Long, recipient: Recipient): Result<Unit>
|
suspend fun banAndDeleteAll(threadId: Long, recipient: Recipient): Result<Unit>
|
||||||
suspend fun deleteThread(threadId: Long): Result<Unit>
|
suspend fun deleteThread(threadId: Long): Result<Unit>
|
||||||
@ -280,21 +275,24 @@ class DefaultConversationRepository @Inject constructor(
|
|||||||
// delete the messages remotely
|
// delete the messages remotely
|
||||||
val publicKey = recipient.address.serialize()
|
val publicKey = recipient.address.serialize()
|
||||||
val userAddress: Address? = textSecurePreferences.getLocalNumber()?.let { Address.fromSerialized(it) }
|
val userAddress: Address? = textSecurePreferences.getLocalNumber()?.let { Address.fromSerialized(it) }
|
||||||
|
val userAuth = requireNotNull(storage.userAuth) {
|
||||||
|
"User auth is required to delete messages remotely"
|
||||||
|
}
|
||||||
|
|
||||||
messages.forEach { message ->
|
messages.forEach { message ->
|
||||||
// delete from swarm
|
// delete from swarm
|
||||||
messageDataProvider.getServerHashForMessage(message.id, message.isMms)
|
messageDataProvider.getServerHashForMessage(message.id, message.isMms)
|
||||||
?.let { serverHash ->
|
?.let { serverHash ->
|
||||||
SnodeAPI.deleteMessage(publicKey, listOf(serverHash))
|
SnodeAPI.deleteMessage(publicKey, userAuth, listOf(serverHash))
|
||||||
}
|
}
|
||||||
|
|
||||||
// send an UnsendRequest to user's swarm
|
// send an UnsendRequest to user's swarm
|
||||||
buildUnsendRequest(recipient, message)?.let { unsendRequest ->
|
buildUnsendRequest(message).let { unsendRequest ->
|
||||||
userAddress?.let { MessageSender.send(unsendRequest, it) }
|
userAddress?.let { MessageSender.send(unsendRequest, it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
// send an UnsendRequest to recipient's swarm
|
// send an UnsendRequest to recipient's swarm
|
||||||
buildUnsendRequest(recipient, message)?.let { unsendRequest ->
|
buildUnsendRequest(message).let { unsendRequest ->
|
||||||
MessageSender.send(unsendRequest, recipient.address)
|
MessageSender.send(unsendRequest, recipient.address)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -304,12 +302,12 @@ class DefaultConversationRepository @Inject constructor(
|
|||||||
recipient: Recipient,
|
recipient: Recipient,
|
||||||
messages: Set<MessageRecord>
|
messages: Set<MessageRecord>
|
||||||
) {
|
) {
|
||||||
if (recipient.isClosedGroupRecipient) {
|
if (recipient.isLegacyClosedGroupRecipient) {
|
||||||
val publicKey = recipient.address
|
val publicKey = recipient.address
|
||||||
|
|
||||||
messages.forEach { message ->
|
messages.forEach { message ->
|
||||||
// send an UnsendRequest to group's swarm
|
// send an UnsendRequest to group's swarm
|
||||||
buildUnsendRequest(recipient, message)?.let { unsendRequest ->
|
buildUnsendRequest(message).let { unsendRequest ->
|
||||||
MessageSender.send(unsendRequest, publicKey)
|
MessageSender.send(unsendRequest, publicKey)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -324,16 +322,19 @@ class DefaultConversationRepository @Inject constructor(
|
|||||||
// delete the messages remotely
|
// delete the messages remotely
|
||||||
val publicKey = recipient.address.serialize()
|
val publicKey = recipient.address.serialize()
|
||||||
val userAddress: Address? = textSecurePreferences.getLocalNumber()?.let { Address.fromSerialized(it) }
|
val userAddress: Address? = textSecurePreferences.getLocalNumber()?.let { Address.fromSerialized(it) }
|
||||||
|
val userAuth = requireNotNull(storage.userAuth) {
|
||||||
|
"User auth is required to delete messages remotely"
|
||||||
|
}
|
||||||
|
|
||||||
messages.forEach { message ->
|
messages.forEach { message ->
|
||||||
// delete from swarm
|
// delete from swarm
|
||||||
messageDataProvider.getServerHashForMessage(message.id, message.isMms)
|
messageDataProvider.getServerHashForMessage(message.id, message.isMms)
|
||||||
?.let { serverHash ->
|
?.let { serverHash ->
|
||||||
SnodeAPI.deleteMessage(publicKey, listOf(serverHash))
|
SnodeAPI.deleteMessage(publicKey, userAuth, listOf(serverHash))
|
||||||
}
|
}
|
||||||
|
|
||||||
// send an UnsendRequest to user's swarm
|
// send an UnsendRequest to user's swarm
|
||||||
buildUnsendRequest(recipient, message)?.let { unsendRequest ->
|
buildUnsendRequest(message).let { unsendRequest ->
|
||||||
userAddress?.let { MessageSender.send(unsendRequest, it) }
|
userAddress?.let { MessageSender.send(unsendRequest, it) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ interface ThemeColors {
|
|||||||
// properties to override for each theme
|
// properties to override for each theme
|
||||||
val isLight: Boolean
|
val isLight: Boolean
|
||||||
val primary: Color
|
val primary: Color
|
||||||
val warning: Color
|
|
||||||
val textAlert: Color
|
val textAlert: Color
|
||||||
val danger: Color
|
val danger: Color
|
||||||
val warning: Color
|
val warning: Color
|
||||||
|
@ -3,17 +3,13 @@ package org.session.libsession.database
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import com.goterl.lazysodium.utils.KeyPair
|
import com.goterl.lazysodium.utils.KeyPair
|
||||||
import network.loki.messenger.libsession_util.Config
|
|
||||||
import network.loki.messenger.libsession_util.util.GroupDisplayInfo
|
import network.loki.messenger.libsession_util.util.GroupDisplayInfo
|
||||||
import network.loki.messenger.libsession_util.util.GroupInfo
|
|
||||||
import nl.komponents.kovenant.Promise
|
|
||||||
import org.session.libsession.messaging.BlindedIdMapping
|
import org.session.libsession.messaging.BlindedIdMapping
|
||||||
import org.session.libsession.messaging.calls.CallMessageType
|
import org.session.libsession.messaging.calls.CallMessageType
|
||||||
import org.session.libsession.messaging.contacts.Contact
|
import org.session.libsession.messaging.contacts.Contact
|
||||||
import org.session.libsession.messaging.jobs.AttachmentUploadJob
|
import org.session.libsession.messaging.jobs.AttachmentUploadJob
|
||||||
import org.session.libsession.messaging.jobs.Job
|
import org.session.libsession.messaging.jobs.Job
|
||||||
import org.session.libsession.messaging.jobs.MessageSendJob
|
import org.session.libsession.messaging.jobs.MessageSendJob
|
||||||
import org.session.libsession.messaging.messages.Destination
|
|
||||||
import org.session.libsession.messaging.messages.ExpirationConfiguration
|
import org.session.libsession.messaging.messages.ExpirationConfiguration
|
||||||
import org.session.libsession.messaging.messages.Message
|
import org.session.libsession.messaging.messages.Message
|
||||||
import org.session.libsession.messaging.messages.control.ConfigurationMessage
|
import org.session.libsession.messaging.messages.control.ConfigurationMessage
|
||||||
@ -34,14 +30,13 @@ import org.session.libsession.messaging.sending_receiving.quotes.QuoteModel
|
|||||||
import org.session.libsession.messaging.utilities.UpdateMessageData
|
import org.session.libsession.messaging.utilities.UpdateMessageData
|
||||||
import org.session.libsession.utilities.Address
|
import org.session.libsession.utilities.Address
|
||||||
import org.session.libsession.utilities.GroupRecord
|
import org.session.libsession.utilities.GroupRecord
|
||||||
|
import org.session.libsession.utilities.recipients.MessageType
|
||||||
import org.session.libsession.utilities.recipients.Recipient
|
import org.session.libsession.utilities.recipients.Recipient
|
||||||
import org.session.libsession.utilities.recipients.Recipient.RecipientSettings
|
import org.session.libsession.utilities.recipients.Recipient.RecipientSettings
|
||||||
import org.session.libsession.utilities.recipients.MessageType
|
|
||||||
import org.session.libsignal.crypto.ecc.ECKeyPair
|
import org.session.libsignal.crypto.ecc.ECKeyPair
|
||||||
import org.session.libsignal.messages.SignalServiceAttachmentPointer
|
import org.session.libsignal.messages.SignalServiceAttachmentPointer
|
||||||
import org.session.libsignal.messages.SignalServiceGroup
|
import org.session.libsignal.messages.SignalServiceGroup
|
||||||
import org.session.libsignal.utilities.AccountId
|
import org.session.libsignal.utilities.AccountId
|
||||||
import org.session.libsignal.utilities.guava.Optional
|
|
||||||
import network.loki.messenger.libsession_util.util.Contact as LibSessionContact
|
import network.loki.messenger.libsession_util.util.Contact as LibSessionContact
|
||||||
import network.loki.messenger.libsession_util.util.GroupMember as LibSessionGroupMember
|
import network.loki.messenger.libsession_util.util.GroupMember as LibSessionGroupMember
|
||||||
|
|
||||||
|
@ -292,8 +292,9 @@ fun MessageReceiver.handleUnsendRequest(message: UnsendRequest): Long? {
|
|||||||
messageDataProvider.getServerHashForMessage(messageIdToDelete, mms)?.let { serverHash ->
|
messageDataProvider.getServerHashForMessage(messageIdToDelete, mms)?.let { serverHash ->
|
||||||
GlobalScope.launch(Dispatchers.IO) { // using GlobalScope as we are slowly migrating to coroutines but we can't migrate everything at once
|
GlobalScope.launch(Dispatchers.IO) { // using GlobalScope as we are slowly migrating to coroutines but we can't migrate everything at once
|
||||||
try {
|
try {
|
||||||
SnodeAPI.deleteMessage(author, listOf(serverHash))
|
SnodeAPI.deleteMessage(author, userAuth, listOf(serverHash))
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
Log.e("Loki", "Failed to delete message", e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ fun Recipient.getType(): MessageType =
|
|||||||
when{
|
when{
|
||||||
isCommunityRecipient -> MessageType.COMMUNITY
|
isCommunityRecipient -> MessageType.COMMUNITY
|
||||||
isLocalNumber -> MessageType.NOTE_TO_SELF
|
isLocalNumber -> MessageType.NOTE_TO_SELF
|
||||||
isClosedGroupRecipient -> MessageType.LEGACY_GROUP //todo GROUPS V2 this property will change for groups v2. Check for legacyGroup here
|
isLegacyClosedGroupRecipient -> MessageType.LEGACY_GROUP
|
||||||
//isXXXXX -> RecipientType.GROUPS_V2 //todo GROUPS V2 this property will change for groups v2. Check for legacyGroup here
|
isClosedGroupV2Recipient -> MessageType.GROUPS_V2
|
||||||
else -> MessageType.ONE_ON_ONE
|
else -> MessageType.ONE_ON_ONE
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user