mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-20 02:58:45 +00:00
Send sync message when unpinning.
This commit is contained in:
@@ -230,6 +230,7 @@ public class ApplicationContext extends Application implements AppForegroundObse
|
|||||||
.addPostRender(() -> ActiveCallManager.clearNotifications(this))
|
.addPostRender(() -> ActiveCallManager.clearNotifications(this))
|
||||||
.addPostRender(RestoreOptimizedMediaJob::enqueueIfNecessary)
|
.addPostRender(RestoreOptimizedMediaJob::enqueueIfNecessary)
|
||||||
.addPostRender(RetryPendingSendsJob::enqueueForAll)
|
.addPostRender(RetryPendingSendsJob::enqueueForAll)
|
||||||
|
.addPostRender(() -> AppDependencies.getPinnedMessageManager().scheduleIfNecessary())
|
||||||
.execute();
|
.execute();
|
||||||
|
|
||||||
Log.d(TAG, "onCreate() took " + (System.currentTimeMillis() - startTime) + " ms");
|
Log.d(TAG, "onCreate() took " + (System.currentTimeMillis() - startTime) + " ms");
|
||||||
|
|||||||
@@ -406,7 +406,7 @@ class Recipient(
|
|||||||
private val resolved: Recipient
|
private val resolved: Recipient
|
||||||
get() = if (isResolving) live().resolve() else this
|
get() = if (isResolving) live().resolve() else this
|
||||||
|
|
||||||
/** Convenience method to get a non-null [serviceId] hen you know it is there. */
|
/** Convenience method to get a non-null [serviceId] when you know it is there. */
|
||||||
fun requireServiceId(): ServiceId {
|
fun requireServiceId(): ServiceId {
|
||||||
return resolved.aciValue ?: resolved.pniValue ?: throw MissingServiceIdError(id)
|
return resolved.aciValue ?: resolved.pniValue ?: throw MissingServiceIdError(id)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ import org.thoughtcrime.securesms.database.SignalDatabase
|
|||||||
import org.thoughtcrime.securesms.database.model.MmsMessageRecord
|
import org.thoughtcrime.securesms.database.model.MmsMessageRecord
|
||||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||||
|
import org.thoughtcrime.securesms.util.GroupUtil
|
||||||
|
import org.whispersystems.signalservice.api.messages.SignalServiceDataMessage
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages waking up and unpinning pinned messages at the correct time
|
* Manages waking up and unpinning pinned messages at the correct time
|
||||||
@@ -51,7 +53,20 @@ class PinnedMessageManager(
|
|||||||
val pinnedMessagesToUnpin = messagesTable.getPinnedMessagesBefore(System.currentTimeMillis())
|
val pinnedMessagesToUnpin = messagesTable.getPinnedMessagesBefore(System.currentTimeMillis())
|
||||||
for (record in pinnedMessagesToUnpin) {
|
for (record in pinnedMessagesToUnpin) {
|
||||||
messagesTable.unpinMessage(messageId = record.id, threadId = record.threadId)
|
messagesTable.unpinMessage(messageId = record.id, threadId = record.threadId)
|
||||||
// TODO(michelle): Send sync message to linked device to unpin message (done to ensure consistency)
|
val dataMessageBuilder = SignalServiceDataMessage.newBuilder()
|
||||||
|
.withTimestamp(System.currentTimeMillis())
|
||||||
|
.withUnpinnedMessage(
|
||||||
|
SignalServiceDataMessage.UnpinnedMessage(
|
||||||
|
targetAuthor = record.fromRecipient.requireServiceId(),
|
||||||
|
targetSentTimestamp = record.dateSent
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
val conversationRecipient = SignalDatabase.threads.getRecipientForThreadId(record.threadId) ?: continue
|
||||||
|
if (conversationRecipient.isGroup) {
|
||||||
|
GroupUtil.setDataMessageGroupContext(application, dataMessageBuilder, conversationRecipient.requireGroupId().requirePush())
|
||||||
|
}
|
||||||
|
AppDependencies.signalServiceMessageSender.sendSyncMessage(dataMessageBuilder.build())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user