Add --no-urgent flag to send command (#1933)

* Add --no-push flag to send command

Expose the server's `urgent` parameter so callers can skip sending a
push notification (FCM/APNs) to the recipient. The message is still
delivered in real-time over WebSocket if the recipient's app is active.

The flag is added to the Message record (following the same pattern as
viewOnce) and threaded through ManagerImpl and SendHelper, keeping the
Manager interface unchanged.

* Rename --no-push flag to --no-urgent

Align with the protocol naming as suggested by the maintainer.
The flag controls the 'urgent' parameter on the server request.
This commit is contained in:
Kai Kozlov authored and GitHub committed 2026-02-25 21:42:51 +01:00
1 parent 4a35d47515
commit d4b3816c5d
6 files changed
+38 -24

No files matched your search

@@ -12,7 +12,8 @@ public record Message(
Optional<Sticker> sticker,
List<Preview> previews,
Optional<StoryReply> storyReply,
List<TextStyle> textStyles
List<TextStyle> textStyles,
boolean noUrgent
) {
public record Mention(RecipientIdentifier.Single recipient, int start, int length) {}
@@ -682,7 +682,7 @@ public class GroupHelper {
private void sendExpirationTimerUpdate(GroupIdV1 groupId) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException {
final var messageBuilder = SignalServiceDataMessage.newBuilder().asExpirationUpdate();
context.getSendHelper().sendAsGroupMessage(messageBuilder, groupId, false, Optional.empty());
context.getSendHelper().sendAsGroupMessage(messageBuilder, groupId, false, Optional.empty(), true);
}
private SendGroupMessageResults updateGroupV2(
@@ -84,7 +84,8 @@ public class SendHelper {
public SendMessageResult sendMessage(
final SignalServiceDataMessage.Builder messageBuilder,
final RecipientId recipientId,
Optional<Long> editTargetTimestamp
Optional<Long> editTargetTimestamp,
boolean urgent
) {
var contact = account.getContactStore().getContact(recipientId);
if (contact == null || !contact.isProfileSharingEnabled() || contact.isHidden()) {
@@ -102,7 +103,7 @@ public class SendHelper {
}
final var message = messageBuilder.build();
return sendMessage(message, recipientId, editTargetTimestamp);
return sendMessage(message, recipientId, editTargetTimestamp, urgent);
}
/**
@@ -113,10 +114,11 @@ public class SendHelper {
final SignalServiceDataMessage.Builder messageBuilder,
final GroupId groupId,
final boolean includeSelf,
final Optional<Long> editTargetTimestamp
final Optional<Long> editTargetTimestamp,
boolean urgent
) throws IOException, GroupNotFoundException, NotAGroupMemberException, GroupSendingNotAllowedException {
final var g = getGroupForSending(groupId);
return sendAsGroupMessage(messageBuilder, g, includeSelf, editTargetTimestamp);
return sendAsGroupMessage(messageBuilder, g, includeSelf, editTargetTimestamp, urgent);
}
/**
@@ -128,7 +130,7 @@ public class SendHelper {
final Set<RecipientId> recipientIds,
final GroupInfo groupInfo
) throws IOException {
return sendGroupMessage(message, recipientIds, groupInfo, ContentHint.IMPLICIT, Optional.empty());
return sendGroupMessage(message, recipientIds, groupInfo, ContentHint.IMPLICIT, Optional.empty(), true);
}
public SendMessageResult sendReceiptMessage(
@@ -311,7 +313,8 @@ public class SendHelper {
final SignalServiceDataMessage.Builder messageBuilder,
final GroupInfo g,
final boolean includeSelf,
final Optional<Long> editTargetTimestamp
final Optional<Long> editTargetTimestamp,
boolean urgent
) throws IOException, GroupSendingNotAllowedException {
GroupUtils.setGroupContext(messageBuilder, g);
messageBuilder.withExpiration(g.getMessageExpirationTimer());
@@ -330,7 +333,7 @@ public class SendHelper {
}
}
return sendGroupMessage(message, recipients, g, ContentHint.RESENDABLE, editTargetTimestamp);
return sendGroupMessage(message, recipients, g, ContentHint.RESENDABLE, editTargetTimestamp, urgent);
}
private List<SendMessageResult> sendGroupMessage(
@@ -338,13 +341,13 @@ public class SendHelper {
final Set<RecipientId> recipientIds,
final GroupInfo groupInfo,
final ContentHint contentHint,
final Optional<Long> editTargetTimestamp
final Optional<Long> editTargetTimestamp,
boolean urgent
) throws IOException {
final var messageSender = dependencies.getMessageSender();
final var messageSendLogStore = account.getMessageSendLogStore();
final AtomicLong entryId = new AtomicLong(-1);
final var urgent = true;
final PartialSendCompleteListener partialSendCompleteListener = sendResult -> {
logger.trace("Partial message send result: {}", sendResult.isSuccess());
synchronized (entryId) {
@@ -712,10 +715,10 @@ public class SendHelper {
private SendMessageResult sendMessage(
SignalServiceDataMessage message,
RecipientId recipientId,
Optional<Long> editTargetTimestamp
Optional<Long> editTargetTimestamp,
boolean urgent
) {
final var messageSendLogStore = account.getMessageSendLogStore();
final var urgent = true;
final var result = handleSendMessage(recipientId,
editTargetTimestamp.isEmpty()
? (messageSender, address, unidentifiedAccess, includePniSignature) -> messageSender.sendDataMessage(
@@ -666,14 +666,15 @@ public class ManagerImpl implements Manager {
Set<RecipientIdentifier> recipients,
boolean notifySelf
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException {
return sendMessage(messageBuilder, recipients, notifySelf, Optional.empty());
return sendMessage(messageBuilder, recipients, notifySelf, Optional.empty(), true);
}
private SendMessageResults sendMessage(
SignalServiceDataMessage.Builder messageBuilder,
Set<RecipientIdentifier> recipients,
boolean notifySelf,
Optional<Long> editTargetTimestamp
Optional<Long> editTargetTimestamp,
boolean urgent
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException {
var results = new HashMap<RecipientIdentifier, List<SendMessageResult>>();
long timestamp = getNextMessageTimestamp();
@@ -685,14 +686,14 @@ public class ManagerImpl implements Manager {
)) {
final var result = notifySelf
? context.getSendHelper()
.sendMessage(messageBuilder, account.getSelfRecipientId(), editTargetTimestamp)
.sendMessage(messageBuilder, account.getSelfRecipientId(), editTargetTimestamp, urgent)
: context.getSendHelper().sendSelfMessage(messageBuilder, editTargetTimestamp);
results.put(recipient, List.of(toSendMessageResult(result)));
} else if (recipient instanceof RecipientIdentifier.Single single) {
try {
final var recipientId = context.getRecipientHelper().resolveRecipient(single);
final var result = context.getSendHelper()
.sendMessage(messageBuilder, recipientId, editTargetTimestamp);
.sendMessage(messageBuilder, recipientId, editTargetTimestamp, urgent);
results.put(recipient, List.of(toSendMessageResult(result)));
} catch (UnregisteredRecipientException e) {
results.put(recipient,
@@ -700,7 +701,7 @@ public class ManagerImpl implements Manager {
}
} else if (recipient instanceof RecipientIdentifier.Group group) {
final var result = context.getSendHelper()
.sendAsGroupMessage(messageBuilder, group.groupId(), notifySelf, editTargetTimestamp);
.sendAsGroupMessage(messageBuilder, group.groupId(), notifySelf, editTargetTimestamp, urgent);
results.put(recipient, result.stream().map(this::toSendMessageResult).toList());
}
}
@@ -799,7 +800,7 @@ public class ManagerImpl implements Manager {
}
final var messageBuilder = SignalServiceDataMessage.newBuilder();
applyMessage(messageBuilder, message);
return sendMessage(messageBuilder, recipients, notifySelf);
return sendMessage(messageBuilder, recipients, notifySelf, Optional.empty(), !message.noUrgent());
}
@Override
@@ -810,7 +811,7 @@ public class ManagerImpl implements Manager {
) throws IOException, AttachmentInvalidException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException, UnregisteredRecipientException, InvalidStickerException {
final var messageBuilder = SignalServiceDataMessage.newBuilder();
applyMessage(messageBuilder, message);
return sendMessage(messageBuilder, recipients, false, Optional.of(editTargetTimestamp));
return sendMessage(messageBuilder, recipients, false, Optional.of(editTargetTimestamp), !message.noUrgent());
}
private void applyMessage(