Allow pinning in note to self.

This commit is contained in:
Michelle Tang
2025-12-19 18:06:53 -05:00
committed by jeffrey-signal
parent 08915befa5
commit ed5c51d954
2 changed files with 40 additions and 30 deletions

View File

@@ -339,8 +339,9 @@ class ConversationRepository(
listOf(threadRecipient)
}
val includeSelf = threadRecipient.isSelf
val eligibleTargets = RecipientUtil.getEligibleForSending(possibleTargets)
val results = PinSendUtil.sendPinMessage(applicationContext, threadRecipient, message, eligibleTargets, messageRecord.id)
val results = PinSendUtil.sendPinMessage(applicationContext, threadRecipient, message, eligibleTargets, includeSelf, messageRecord.id)
val sendResults = GroupSendJobHelper.getCompletedSends(eligibleTargets, results)
@@ -396,8 +397,9 @@ class ConversationRepository(
listOf(threadRecipient)
}
val includeSelf = threadRecipient.isSelf
val eligibleTargets: List<Recipient> = RecipientUtil.getEligibleForSending(possibleTargets)
val results = PinSendUtil.sendUnpinMessage(applicationContext, threadRecipient, message.fromRecipient.requireServiceId(), message.dateSent, eligibleTargets, messageId)
val results = PinSendUtil.sendUnpinMessage(applicationContext, threadRecipient, message.fromRecipient.requireServiceId(), message.dateSent, eligibleTargets, includeSelf, messageId)
val sendResults = GroupSendJobHelper.getCompletedSends(eligibleTargets, results)
if (sendResults.completed.isNotEmpty() || possibleTargets.isEmpty()) {

View File

@@ -31,7 +31,7 @@ object PinSendUtil {
private val PIN_TERMINATE_TIMEOUT = 7000.milliseconds
@Throws(IOException::class, GroupNotAMemberException::class, UndeliverableMessageException::class)
fun sendPinMessage(applicationContext: Context, threadRecipient: Recipient, message: OutgoingMessage, destinations: List<Recipient>, relatedMessageId: Long): List<SendMessageResult?> {
fun sendPinMessage(applicationContext: Context, threadRecipient: Recipient, message: OutgoingMessage, destinations: List<Recipient>, includeSelf: Boolean, relatedMessageId: Long): List<SendMessageResult?> {
val builder = newBuilder()
val groupId = if (threadRecipient.isPushV2Group) threadRecipient.requireGroupId().requireV2() else null
@@ -58,23 +58,27 @@ object PinSendUtil {
)
.build()
return GroupSendUtil.sendResendableDataMessage(
applicationContext,
groupId,
null,
destinations,
false,
ContentHint.RESENDABLE,
MessageId(relatedMessageId),
message,
false,
false,
null
) { System.currentTimeMillis() - sentTime > PIN_TERMINATE_TIMEOUT.inWholeMilliseconds }
return if (includeSelf) {
listOf(AppDependencies.signalServiceMessageSender.sendSyncMessage(message))
} else {
GroupSendUtil.sendResendableDataMessage(
applicationContext,
groupId,
null,
destinations,
false,
ContentHint.RESENDABLE,
MessageId(relatedMessageId),
message,
false,
false,
null
) { System.currentTimeMillis() - sentTime > PIN_TERMINATE_TIMEOUT.inWholeMilliseconds }
}
}
@Throws(IOException::class, GroupNotAMemberException::class, UndeliverableMessageException::class)
fun sendUnpinMessage(applicationContext: Context, threadRecipient: Recipient, targetAuthor: ServiceId, targetSentTimestamp: Long, destinations: List<Recipient>, relatedMessageId: Long): List<SendMessageResult?> {
fun sendUnpinMessage(applicationContext: Context, threadRecipient: Recipient, targetAuthor: ServiceId, targetSentTimestamp: Long, destinations: List<Recipient>, includeSelf: Boolean, relatedMessageId: Long): List<SendMessageResult?> {
val builder = newBuilder()
val groupId = if (threadRecipient.isPushV2Group) threadRecipient.requireGroupId().requireV2() else null
if (groupId != null) {
@@ -98,18 +102,22 @@ object PinSendUtil {
)
.build()
return GroupSendUtil.sendResendableDataMessage(
applicationContext,
groupId,
null,
destinations,
false,
ContentHint.RESENDABLE,
MessageId(relatedMessageId),
message,
false,
false,
null
) { System.currentTimeMillis() - sentTime > PIN_TERMINATE_TIMEOUT.inWholeMilliseconds }
return if (includeSelf) {
listOf(AppDependencies.signalServiceMessageSender.sendSyncMessage(message))
} else {
GroupSendUtil.sendResendableDataMessage(
applicationContext,
groupId,
null,
destinations,
false,
ContentHint.RESENDABLE,
MessageId(relatedMessageId),
message,
false,
false,
null
) { System.currentTimeMillis() - sentTime > PIN_TERMINATE_TIMEOUT.inWholeMilliseconds }
}
}
}