mirror of
https://github.com/oxen-io/session-android.git
synced 2025-01-11 22:03:54 +00:00
fix: emoji author parsing and adding message senders to storage (#957)
This commit is contained in:
parent
2520287aff
commit
ebcae1f284
@ -1064,8 +1064,11 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
|||||||
dateReceived = emojiTimestamp
|
dateReceived = emojiTimestamp
|
||||||
)
|
)
|
||||||
reactionDb.addReaction(MessageId(originalMessage.id, originalMessage.isMms), reaction)
|
reactionDb.addReaction(MessageId(originalMessage.id, originalMessage.isMms), reaction)
|
||||||
|
val originalAuthor = if (originalMessage.isOutgoing) {
|
||||||
|
fromSerialized(viewModel.blindedPublicKey ?: textSecurePreferences.getLocalNumber()!!)
|
||||||
|
} else originalMessage.individualRecipient.address
|
||||||
// Send it
|
// Send it
|
||||||
reactionMessage.reaction = Reaction.from(originalMessage.timestamp, originalMessage.recipient.address.serialize(), emoji, true)
|
reactionMessage.reaction = Reaction.from(originalMessage.timestamp, originalAuthor.serialize(), emoji, true)
|
||||||
if (recipient.isOpenGroupRecipient) {
|
if (recipient.isOpenGroupRecipient) {
|
||||||
val messageServerId = lokiMessageDb.getServerID(originalMessage.id, !originalMessage.isMms) ?: return
|
val messageServerId = lokiMessageDb.getServerID(originalMessage.id, !originalMessage.isMms) ?: return
|
||||||
viewModel.openGroup?.let {
|
viewModel.openGroup?.let {
|
||||||
@ -1084,7 +1087,12 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
|||||||
message.sentTimestamp = emojiTimestamp
|
message.sentTimestamp = emojiTimestamp
|
||||||
val author = textSecurePreferences.getLocalNumber()!!
|
val author = textSecurePreferences.getLocalNumber()!!
|
||||||
reactionDb.deleteReaction(emoji, MessageId(originalMessage.id, originalMessage.isMms), author)
|
reactionDb.deleteReaction(emoji, MessageId(originalMessage.id, originalMessage.isMms), author)
|
||||||
message.reaction = Reaction.from(originalMessage.timestamp, author, emoji, false)
|
|
||||||
|
val originalAuthor = if (originalMessage.isOutgoing) {
|
||||||
|
fromSerialized(viewModel.blindedPublicKey ?: textSecurePreferences.getLocalNumber()!!)
|
||||||
|
} else originalMessage.individualRecipient.address
|
||||||
|
|
||||||
|
message.reaction = Reaction.from(originalMessage.timestamp, originalAuthor.serialize(), emoji, false)
|
||||||
if (recipient.isOpenGroupRecipient) {
|
if (recipient.isOpenGroupRecipient) {
|
||||||
val messageServerId = lokiMessageDb.getServerID(originalMessage.id, !originalMessage.isMms) ?: return
|
val messageServerId = lokiMessageDb.getServerID(originalMessage.id, !originalMessage.isMms) ?: return
|
||||||
viewModel.openGroup?.let {
|
viewModel.openGroup?.let {
|
||||||
@ -1330,7 +1338,9 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe
|
|||||||
message.text = body
|
message.text = body
|
||||||
val quote = quotedMessage?.let {
|
val quote = quotedMessage?.let {
|
||||||
val quotedAttachments = (it as? MmsMessageRecord)?.slideDeck?.asAttachments() ?: listOf()
|
val quotedAttachments = (it as? MmsMessageRecord)?.slideDeck?.asAttachments() ?: listOf()
|
||||||
val sender = if (it.isOutgoing) fromSerialized(textSecurePreferences.getLocalNumber()!!) else it.individualRecipient.address
|
val sender = if (it.isOutgoing) {
|
||||||
|
fromSerialized(viewModel.blindedPublicKey ?: textSecurePreferences.getLocalNumber()!!)
|
||||||
|
} else it.individualRecipient.address
|
||||||
QuoteModel(it.dateSent, sender, it.body, false, quotedAttachments)
|
QuoteModel(it.dateSent, sender, it.body, false, quotedAttachments)
|
||||||
}
|
}
|
||||||
val outgoingTextMessage = OutgoingMediaMessage.from(message, recipient, attachments, quote, linkPreview)
|
val outgoingTextMessage = OutgoingMediaMessage.from(message, recipient, attachments, quote, linkPreview)
|
||||||
|
@ -892,7 +892,7 @@ class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context,
|
|||||||
return mapping
|
return mapping
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun addReaction(reaction: Reaction) {
|
override fun addReaction(reaction: Reaction, messageSender: String) {
|
||||||
val timestamp = reaction.timestamp
|
val timestamp = reaction.timestamp
|
||||||
val localId = reaction.localId
|
val localId = reaction.localId
|
||||||
val isMms = reaction.isMms
|
val isMms = reaction.isMms
|
||||||
@ -907,7 +907,7 @@ class Storage(context: Context, helper: SQLCipherOpenHelper) : Database(context,
|
|||||||
ReactionRecord(
|
ReactionRecord(
|
||||||
messageId = messageId.id,
|
messageId = messageId.id,
|
||||||
isMms = messageId.mms,
|
isMms = messageId.mms,
|
||||||
author = reaction.publicKey!!,
|
author = messageSender,
|
||||||
emoji = reaction.emoji!!,
|
emoji = reaction.emoji!!,
|
||||||
serverId = reaction.serverId!!,
|
serverId = reaction.serverId!!,
|
||||||
count = reaction.count!!,
|
count = reaction.count!!,
|
||||||
|
@ -2,6 +2,7 @@ package org.session.libsession.database
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
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
|
||||||
@ -13,14 +14,13 @@ import org.session.libsession.messaging.messages.control.MessageRequestResponse
|
|||||||
import org.session.libsession.messaging.messages.visible.Attachment
|
import org.session.libsession.messaging.messages.visible.Attachment
|
||||||
import org.session.libsession.messaging.messages.visible.Reaction
|
import org.session.libsession.messaging.messages.visible.Reaction
|
||||||
import org.session.libsession.messaging.messages.visible.VisibleMessage
|
import org.session.libsession.messaging.messages.visible.VisibleMessage
|
||||||
|
import org.session.libsession.messaging.open_groups.GroupMember
|
||||||
import org.session.libsession.messaging.open_groups.OpenGroup
|
import org.session.libsession.messaging.open_groups.OpenGroup
|
||||||
import org.session.libsession.messaging.sending_receiving.attachments.AttachmentId
|
import org.session.libsession.messaging.sending_receiving.attachments.AttachmentId
|
||||||
import org.session.libsession.messaging.sending_receiving.attachments.DatabaseAttachment
|
import org.session.libsession.messaging.sending_receiving.attachments.DatabaseAttachment
|
||||||
import org.session.libsession.messaging.sending_receiving.data_extraction.DataExtractionNotificationInfoMessage
|
import org.session.libsession.messaging.sending_receiving.data_extraction.DataExtractionNotificationInfoMessage
|
||||||
import org.session.libsession.messaging.sending_receiving.link_preview.LinkPreview
|
import org.session.libsession.messaging.sending_receiving.link_preview.LinkPreview
|
||||||
import org.session.libsession.messaging.sending_receiving.quotes.QuoteModel
|
import org.session.libsession.messaging.sending_receiving.quotes.QuoteModel
|
||||||
import org.session.libsession.messaging.BlindedIdMapping
|
|
||||||
import org.session.libsession.messaging.open_groups.GroupMember
|
|
||||||
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.Recipient
|
import org.session.libsession.utilities.recipients.Recipient
|
||||||
@ -190,7 +190,7 @@ interface StorageProtocol {
|
|||||||
fun removeLastOutboxMessageId(server: String)
|
fun removeLastOutboxMessageId(server: String)
|
||||||
fun getOrCreateBlindedIdMapping(blindedId: String, server: String, serverPublicKey: String, fromOutbox: Boolean = false): BlindedIdMapping
|
fun getOrCreateBlindedIdMapping(blindedId: String, server: String, serverPublicKey: String, fromOutbox: Boolean = false): BlindedIdMapping
|
||||||
|
|
||||||
fun addReaction(reaction: Reaction)
|
fun addReaction(reaction: Reaction, messageSender: String)
|
||||||
fun removeReaction(emoji: String, messageTimestamp: Long, author: String)
|
fun removeReaction(emoji: String, messageTimestamp: Long, author: String)
|
||||||
fun updateReactionIfNeeded(message: Message, sender: String, openGroupSentTimestamp: Long)
|
fun updateReactionIfNeeded(message: Message, sender: String, openGroupSentTimestamp: Long)
|
||||||
fun deleteReactions(messageId: Long, mms: Boolean)
|
fun deleteReactions(messageId: Long, mms: Boolean)
|
||||||
|
@ -300,7 +300,7 @@ fun MessageReceiver.handleVisibleMessage(message: VisibleMessage,
|
|||||||
reaction.serverId = message.openGroupServerMessageID?.toString() ?: message.serverHash.orEmpty()
|
reaction.serverId = message.openGroupServerMessageID?.toString() ?: message.serverHash.orEmpty()
|
||||||
reaction.dateSent = message.sentTimestamp ?: 0
|
reaction.dateSent = message.sentTimestamp ?: 0
|
||||||
reaction.dateReceived = message.receivedTimestamp ?: 0
|
reaction.dateReceived = message.receivedTimestamp ?: 0
|
||||||
storage.addReaction(reaction)
|
storage.addReaction(reaction, messageSender)
|
||||||
} else {
|
} else {
|
||||||
storage.removeReaction(reaction.emoji!!, reaction.timestamp!!, reaction.publicKey!!)
|
storage.removeReaction(reaction.emoji!!, reaction.timestamp!!, reaction.publicKey!!)
|
||||||
}
|
}
|
||||||
@ -347,17 +347,17 @@ fun MessageReceiver.handleOpenGroupReactions(
|
|||||||
val reactorIds = reaction.reactors.filter { it != blindedPublicKey && it != userPublicKey }
|
val reactorIds = reaction.reactors.filter { it != blindedPublicKey && it != userPublicKey }
|
||||||
val count = if (reaction.you) reaction.count - 1 else reaction.count
|
val count = if (reaction.you) reaction.count - 1 else reaction.count
|
||||||
// Add the first reaction (with the count)
|
// Add the first reaction (with the count)
|
||||||
reactorIds.firstOrNull()?.let {
|
reactorIds.firstOrNull()?.let { reactor ->
|
||||||
storage.addReaction(Reaction(
|
storage.addReaction(Reaction(
|
||||||
localId = messageId,
|
localId = messageId,
|
||||||
isMms = !isSms,
|
isMms = !isSms,
|
||||||
publicKey = it,
|
publicKey = reactor,
|
||||||
emoji = emoji,
|
emoji = emoji,
|
||||||
react = true,
|
react = true,
|
||||||
serverId = "$openGroupMessageServerID",
|
serverId = "$openGroupMessageServerID",
|
||||||
count = count,
|
count = count,
|
||||||
index = reaction.index
|
index = reaction.index
|
||||||
))
|
), reactor)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add all other reactions
|
// Add all other reactions
|
||||||
@ -373,7 +373,7 @@ fun MessageReceiver.handleOpenGroupReactions(
|
|||||||
serverId = "$openGroupMessageServerID",
|
serverId = "$openGroupMessageServerID",
|
||||||
count = 0, // Only want this on the first reaction
|
count = 0, // Only want this on the first reaction
|
||||||
index = reaction.index
|
index = reaction.index
|
||||||
))
|
), reactor)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the current user reaction (if applicable and not already included)
|
// Add the current user reaction (if applicable and not already included)
|
||||||
@ -387,7 +387,7 @@ fun MessageReceiver.handleOpenGroupReactions(
|
|||||||
serverId = "$openGroupMessageServerID",
|
serverId = "$openGroupMessageServerID",
|
||||||
count = 1,
|
count = 1,
|
||||||
index = reaction.index
|
index = reaction.index
|
||||||
))
|
), userPublicKey)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user