mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-23 00:17:34 +00:00
Disable disappearing closed group messages
This commit is contained in:
parent
3cd5ca4a6d
commit
affdf1ca07
@ -952,36 +952,23 @@ open class Storage(
|
|||||||
|
|
||||||
override fun insertIncomingInfoMessage(context: Context, senderPublicKey: String, groupID: String, type: SignalServiceGroup.Type, name: String, members: Collection<String>, admins: Collection<String>, sentTimestamp: Long) {
|
override fun insertIncomingInfoMessage(context: Context, senderPublicKey: String, groupID: String, type: SignalServiceGroup.Type, name: String, members: Collection<String>, admins: Collection<String>, sentTimestamp: Long) {
|
||||||
val group = SignalServiceGroup(type, GroupUtil.getDecodedGroupIDAsData(groupID), SignalServiceGroup.GroupType.SIGNAL, name, members.toList(), null, admins.toList())
|
val group = SignalServiceGroup(type, GroupUtil.getDecodedGroupIDAsData(groupID), SignalServiceGroup.GroupType.SIGNAL, name, members.toList(), null, admins.toList())
|
||||||
val recipient = Recipient.from(context, fromSerialized(groupID), false)
|
val m = IncomingTextMessage(fromSerialized(senderPublicKey), 1, sentTimestamp, "", Optional.of(group), 0, 0, true, false)
|
||||||
val threadId = DatabaseComponent.get(context).threadDatabase().getOrCreateThreadIdFor(recipient)
|
|
||||||
val expirationConfig = getExpirationConfiguration(threadId)
|
|
||||||
val expiryMode = expirationConfig?.expiryMode ?: ExpiryMode.NONE
|
|
||||||
val expiresInMillis = expiryMode.expiryMillis
|
|
||||||
val expireStartedAt = if (expiryMode is ExpiryMode.AfterSend) sentTimestamp else 0
|
|
||||||
val m = IncomingTextMessage(fromSerialized(senderPublicKey), 1, sentTimestamp, "", Optional.of(group), expiresInMillis, expireStartedAt, true, false)
|
|
||||||
val updateData = UpdateMessageData.buildGroupUpdate(type, name, members)?.toJSON()
|
val updateData = UpdateMessageData.buildGroupUpdate(type, name, members)?.toJSON()
|
||||||
val infoMessage = IncomingGroupMessage(m, groupID, updateData, true)
|
val infoMessage = IncomingGroupMessage(m, groupID, updateData, true)
|
||||||
val smsDB = DatabaseComponent.get(context).smsDatabase()
|
val smsDB = DatabaseComponent.get(context).smsDatabase()
|
||||||
smsDB.insertMessageInbox(infoMessage, true)
|
smsDB.insertMessageInbox(infoMessage, true)
|
||||||
SSKEnvironment.shared.messageExpirationManager.maybeStartExpiration(sentTimestamp, senderPublicKey, expiryMode)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun insertOutgoingInfoMessage(context: Context, groupID: String, type: SignalServiceGroup.Type, name: String, members: Collection<String>, admins: Collection<String>, threadID: Long, sentTimestamp: Long) {
|
override fun insertOutgoingInfoMessage(context: Context, groupID: String, type: SignalServiceGroup.Type, name: String, members: Collection<String>, admins: Collection<String>, threadID: Long, sentTimestamp: Long) {
|
||||||
val userPublicKey = getUserPublicKey()!!
|
val userPublicKey = getUserPublicKey()!!
|
||||||
val recipient = Recipient.from(context, fromSerialized(groupID), false)
|
val recipient = Recipient.from(context, fromSerialized(groupID), false)
|
||||||
val threadId = DatabaseComponent.get(context).threadDatabase().getOrCreateThreadIdFor(recipient)
|
|
||||||
val expirationConfig = getExpirationConfiguration(threadId)
|
|
||||||
val expiryMode = expirationConfig?.expiryMode ?: ExpiryMode.NONE
|
|
||||||
val expiresInMillis = expiryMode.expiryMillis
|
|
||||||
val expireStartedAt = if (expiryMode is ExpiryMode.AfterSend) sentTimestamp else 0
|
|
||||||
val updateData = UpdateMessageData.buildGroupUpdate(type, name, members)?.toJSON() ?: ""
|
val updateData = UpdateMessageData.buildGroupUpdate(type, name, members)?.toJSON() ?: ""
|
||||||
val infoMessage = OutgoingGroupMediaMessage(recipient, updateData, groupID, null, sentTimestamp, expiresInMillis, expireStartedAt, true, null, listOf(), listOf())
|
val infoMessage = OutgoingGroupMediaMessage(recipient, updateData, groupID, null, sentTimestamp, 0, 0, true, null, listOf(), listOf())
|
||||||
val mmsDB = DatabaseComponent.get(context).mmsDatabase()
|
val mmsDB = DatabaseComponent.get(context).mmsDatabase()
|
||||||
val mmsSmsDB = DatabaseComponent.get(context).mmsSmsDatabase()
|
val mmsSmsDB = DatabaseComponent.get(context).mmsSmsDatabase()
|
||||||
if (mmsSmsDB.getMessageFor(sentTimestamp, userPublicKey) != null) return
|
if (mmsSmsDB.getMessageFor(sentTimestamp, userPublicKey) != null) return
|
||||||
val infoMessageID = mmsDB.insertMessageOutbox(infoMessage, threadID, false, null, runThreadUpdate = true)
|
val infoMessageID = mmsDB.insertMessageOutbox(infoMessage, threadID, false, null, runThreadUpdate = true)
|
||||||
mmsDB.markAsSent(infoMessageID, true)
|
mmsDB.markAsSent(infoMessageID, true)
|
||||||
SSKEnvironment.shared.messageExpirationManager.maybeStartExpiration(sentTimestamp, userPublicKey, expiryMode)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isClosedGroup(publicKey: String): Boolean {
|
override fun isClosedGroup(publicKey: String): Boolean {
|
||||||
|
@ -6,6 +6,7 @@ import network.loki.messenger.libsession_util.util.ExpiryMode
|
|||||||
import org.session.libsession.messaging.MessagingModuleConfiguration
|
import org.session.libsession.messaging.MessagingModuleConfiguration
|
||||||
import org.session.libsession.messaging.contacts.Contact
|
import org.session.libsession.messaging.contacts.Contact
|
||||||
import org.session.libsession.messaging.messages.Message
|
import org.session.libsession.messaging.messages.Message
|
||||||
|
import org.session.libsession.messaging.messages.control.ClosedGroupControlMessage
|
||||||
import org.session.libsession.messaging.messages.control.ExpirationTimerUpdate
|
import org.session.libsession.messaging.messages.control.ExpirationTimerUpdate
|
||||||
import org.session.libsession.messaging.sending_receiving.notifications.MessageNotifier
|
import org.session.libsession.messaging.sending_receiving.notifications.MessageNotifier
|
||||||
import org.session.libsession.snode.SnodeAPI.nowWithOffset
|
import org.session.libsession.snode.SnodeAPI.nowWithOffset
|
||||||
@ -46,7 +47,7 @@ class SSKEnvironment(
|
|||||||
fun startAnyExpiration(timestamp: Long, author: String, expireStartedAt: Long)
|
fun startAnyExpiration(timestamp: Long, author: String, expireStartedAt: Long)
|
||||||
|
|
||||||
fun maybeStartExpiration(message: Message, startDisappearAfterRead: Boolean = false) {
|
fun maybeStartExpiration(message: Message, startDisappearAfterRead: Boolean = false) {
|
||||||
if (message is ExpirationTimerUpdate && message.isGroup) return
|
if (message is ExpirationTimerUpdate && message.isGroup || message is ClosedGroupControlMessage) return
|
||||||
|
|
||||||
maybeStartExpiration(
|
maybeStartExpiration(
|
||||||
message.sentTimestamp ?: return,
|
message.sentTimestamp ?: return,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user