mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-25 11:05:25 +00:00
fix: adding in more checks for open group inbox recipients before being saved to the shared configs. Prevent sending typing indicator for blocked users
This commit is contained in:
parent
1f8fa4a904
commit
1cf4ef9e10
@ -212,6 +212,10 @@ open class Storage(context: Context, helper: SQLCipherOpenHelper, private val co
|
||||
val threadDb = DatabaseComponent.get(context).threadDatabase()
|
||||
getRecipientForThread(threadId)?.let { recipient ->
|
||||
threadDb.markAllAsRead(threadId, recipient.isGroupRecipient, lastSeenTime)
|
||||
|
||||
// don't process configs for inbox recipients
|
||||
if (recipient.isOpenGroupInboxRecipient) return
|
||||
|
||||
configFactory.convoVolatile?.let { config ->
|
||||
val convo = when {
|
||||
// recipient closed group
|
||||
|
@ -204,6 +204,7 @@ object ConfigurationMessageUtilities {
|
||||
recipient.isContactRecipient -> {
|
||||
val sessionId = SessionId(recipient.address.serialize())
|
||||
if (recipient.isLocalNumber) null // this is handled by the user profile NTS data
|
||||
if (recipient.isOpenGroupInboxRecipient) null // specifically exclude
|
||||
else convoConfig.getOrConstructOneToOne(recipient.address.serialize())
|
||||
}
|
||||
else -> null
|
||||
|
@ -54,6 +54,6 @@ object SessionMetaProtocol {
|
||||
|
||||
@JvmStatic
|
||||
fun shouldSendTypingIndicator(recipient: Recipient): Boolean {
|
||||
return !recipient.isGroupRecipient && recipient.isApproved
|
||||
return !recipient.isGroupRecipient && recipient.isApproved && !recipient.isBlocked
|
||||
}
|
||||
}
|
@ -7,6 +7,8 @@ import network.loki.messenger.libsession_util.util.Conversation
|
||||
import network.loki.messenger.libsession_util.util.GroupInfo
|
||||
import network.loki.messenger.libsession_util.util.UserPic
|
||||
import org.session.libsignal.protos.SignalServiceProtos.SharedConfigMessage.Kind
|
||||
import org.session.libsignal.utilities.IdPrefix
|
||||
import org.session.libsignal.utilities.Log
|
||||
|
||||
|
||||
sealed class ConfigBase(protected val /* yucky */ pointer: Long) {
|
||||
@ -69,6 +71,13 @@ class Contacts(pointer: Long) : ConfigBase(pointer) {
|
||||
* Similar to [updateIfExists], but will create the underlying contact if it doesn't exist before passing to [updateFunction]
|
||||
*/
|
||||
fun upsertContact(sessionId: String, updateFunction: Contact.()->Unit = {}) {
|
||||
if (sessionId.startsWith(IdPrefix.BLINDED.value)) {
|
||||
Log.w("Loki", "Trying to create a contact with a blinded ID prefix")
|
||||
return
|
||||
} else if (sessionId.startsWith(IdPrefix.UN_BLINDED.value)) {
|
||||
Log.w("Loki", "Trying to create a contact with an un-blinded ID prefix")
|
||||
return
|
||||
}
|
||||
val contact = getOrConstruct(sessionId)
|
||||
updateFunction(contact)
|
||||
set(contact)
|
||||
@ -79,6 +88,13 @@ class Contacts(pointer: Long) : ConfigBase(pointer) {
|
||||
* the [updateFunction] doesn't run if there is no contact
|
||||
*/
|
||||
fun updateIfExists(sessionId: String, updateFunction: Contact.()->Unit) {
|
||||
if (sessionId.startsWith(IdPrefix.BLINDED.value)) {
|
||||
Log.w("Loki", "Trying to create a contact with a blinded ID prefix")
|
||||
return
|
||||
} else if (sessionId.startsWith(IdPrefix.UN_BLINDED.value)) {
|
||||
Log.w("Loki", "Trying to create a contact with an un-blinded ID prefix")
|
||||
return
|
||||
}
|
||||
val contact = get(sessionId) ?: return
|
||||
updateFunction(contact)
|
||||
set(contact)
|
||||
|
Loading…
Reference in New Issue
Block a user