void deleteUsername() throws IOException;
void startChangeNumber(
- String newNumber, boolean voiceVerification, String captcha
+ String newNumber,
+ boolean voiceVerification,
+ String captcha
) throws RateLimitException, IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, NotPrimaryDeviceException, VerificationMethodNotAvailableException;
void finishChangeNumber(
- String newNumber, String verificationCode, String pin
+ String newNumber,
+ String verificationCode,
+ String pin
) throws IncorrectPinException, PinLockedException, IOException, NotPrimaryDeviceException;
void unregister() throws IOException;
void deleteAccount() throws IOException;
void submitRateLimitRecaptchaChallenge(
- String challenge, String captcha
+ String challenge,
+ String captcha
) throws IOException, CaptchaRejectedException;
List<Device> getLinkedDevices() throws IOException;
List<Group> getGroups();
SendGroupMessageResults quitGroup(
- GroupId groupId, Set<RecipientIdentifier.Single> groupAdmins
+ GroupId groupId,
+ Set<RecipientIdentifier.Single> groupAdmins
) throws GroupNotFoundException, IOException, NotAGroupMemberException, LastGroupAdminException, UnregisteredRecipientException;
void deleteGroup(GroupId groupId) throws IOException;
Pair<GroupId, SendGroupMessageResults> createGroup(
- String name, Set<RecipientIdentifier.Single> members, String avatarFile
+ String name,
+ Set<RecipientIdentifier.Single> members,
+ String avatarFile
) throws IOException, AttachmentInvalidException, UnregisteredRecipientException;
SendGroupMessageResults updateGroup(
- final GroupId groupId, final UpdateGroup updateGroup
+ final GroupId groupId,
+ final UpdateGroup updateGroup
) throws IOException, GroupNotFoundException, AttachmentInvalidException, NotAGroupMemberException, GroupSendingNotAllowedException, UnregisteredRecipientException;
Pair<GroupId, SendGroupMessageResults> joinGroup(
) throws IOException, InactiveGroupLinkException, PendingAdminApprovalException;
SendMessageResults sendTypingMessage(
- TypingAction action, Set<RecipientIdentifier> recipients
+ TypingAction action,
+ Set<RecipientIdentifier> recipients
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException;
- SendMessageResults sendReadReceipt(
- RecipientIdentifier.Single sender, List<Long> messageIds
- );
+ SendMessageResults sendReadReceipt(RecipientIdentifier.Single sender, List<Long> messageIds);
- SendMessageResults sendViewedReceipt(
- RecipientIdentifier.Single sender, List<Long> messageIds
- );
+ SendMessageResults sendViewedReceipt(RecipientIdentifier.Single sender, List<Long> messageIds);
SendMessageResults sendMessage(
- Message message, Set<RecipientIdentifier> recipients, boolean notifySelf
+ Message message,
+ Set<RecipientIdentifier> recipients,
+ boolean notifySelf
) throws IOException, AttachmentInvalidException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException, UnregisteredRecipientException, InvalidStickerException;
SendMessageResults sendEditMessage(
- Message message, Set<RecipientIdentifier> recipients, long editTargetTimestamp
+ Message message,
+ Set<RecipientIdentifier> recipients,
+ long editTargetTimestamp
) throws IOException, AttachmentInvalidException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException, UnregisteredRecipientException, InvalidStickerException;
SendMessageResults sendRemoteDeleteMessage(
- long targetSentTimestamp, Set<RecipientIdentifier> recipients
+ long targetSentTimestamp,
+ Set<RecipientIdentifier> recipients
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException;
SendMessageResults sendMessageReaction(
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException, UnregisteredRecipientException;
SendMessageResults sendPaymentNotificationMessage(
- byte[] receipt, String note, RecipientIdentifier.Single recipient
+ byte[] receipt,
+ String note,
+ RecipientIdentifier.Single recipient
) throws IOException;
SendMessageResults sendEndSessionMessage(Set<RecipientIdentifier.Single> recipients) throws IOException;
SendMessageResults sendMessageRequestResponse(
- MessageEnvelope.Sync.MessageRequestResponse.Type type, Set<RecipientIdentifier> recipientIdentifiers
+ MessageEnvelope.Sync.MessageRequestResponse.Type type,
+ Set<RecipientIdentifier> recipientIdentifiers
);
void hideRecipient(RecipientIdentifier.Single recipient);
void deleteContact(RecipientIdentifier.Single recipient);
void setContactName(
- RecipientIdentifier.Single recipient, String givenName, final String familyName
+ RecipientIdentifier.Single recipient,
+ String givenName,
+ final String familyName
) throws NotPrimaryDeviceException, UnregisteredRecipientException;
void setContactsBlocked(
- Collection<RecipientIdentifier.Single> recipient, boolean blocked
+ Collection<RecipientIdentifier.Single> recipient,
+ boolean blocked
) throws NotPrimaryDeviceException, IOException, UnregisteredRecipientException;
void setGroupsBlocked(
- Collection<GroupId> groupId, boolean blocked
+ Collection<GroupId> groupId,
+ boolean blocked
) throws GroupNotFoundException, IOException, NotPrimaryDeviceException;
/**
* Change the expiration timer for a contact
*/
void setExpirationTimer(
- RecipientIdentifier.Single recipient, int messageExpirationTimer
+ RecipientIdentifier.Single recipient,
+ int messageExpirationTimer
) throws IOException, UnregisteredRecipientException;
/**
* Receive new messages from server, returns if no new message arrive in a timespan of timeout.
*/
void receiveMessages(
- Optional<Duration> timeout, Optional<Integer> maxMessages, ReceiveMessageHandler handler
+ Optional<Duration> timeout,
+ Optional<Integer> maxMessages,
+ ReceiveMessageHandler handler
) throws IOException, AlreadyReceivingException;
void stopReceiveMessages();
* @param recipient account of the identity
*/
boolean trustIdentityVerified(
- RecipientIdentifier.Single recipient, IdentityVerificationCode verificationCode
+ RecipientIdentifier.Single recipient,
+ IdentityVerificationCode verificationCode
) throws UnregisteredRecipientException;
/**
public interface RegistrationManager extends Closeable {
void register(
- boolean voiceVerification, String captcha, final boolean forceRegister
+ boolean voiceVerification,
+ String captcha,
+ final boolean forceRegister
) throws IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, RateLimitException, VerificationMethodNotAvailableException;
void verifyAccount(
- String verificationCode, String pin
+ String verificationCode,
+ String pin
) throws IOException, PinLockedException, IncorrectPinException;
void deleteLocalAccountData() throws IOException;
}
private Manager initManager(
- String number, String accountPath
+ String number,
+ String accountPath
) throws IOException, NotRegisteredException, AccountCheckException {
if (accountPath == null) {
throw new NotRegisteredException();
}
public RegistrationManager initRegistrationManager(
- String number, Consumer<Manager> newManagerListener
+ String number,
+ Consumer<Manager> newManagerListener
) throws IOException {
final var accountPath = accountsStore.getPathByNumber(number);
if (accountPath == null || !SignalAccount.accountFileExists(pathConfig.dataPath(), accountPath)) {
private final MessageSendLogEntry messageSendLogEntry;
public ResendMessageAction(
- final RecipientId recipientId, final long timestamp, final MessageSendLogEntry messageSendLogEntry
+ final RecipientId recipientId,
+ final long timestamp,
+ final MessageSendLogEntry messageSendLogEntry
) {
this.recipientId = recipientId;
this.timestamp = timestamp;
private final List<Long> timestamps = new ArrayList<>();
public SendReceiptAction(
- final RecipientId recipientId, final SignalServiceReceiptMessage.Type type, final long timestamp
+ final RecipientId recipientId,
+ final SignalServiceReceiptMessage.Type type,
+ final long timestamp
) {
this.recipientId = recipientId;
this.type = type;
) {
public static Group from(
- final GroupInfo groupInfo, final RecipientAddressResolver recipientStore, final RecipientId selfRecipientId
+ final GroupInfo groupInfo,
+ final RecipientAddressResolver recipientStore,
+ final RecipientId selfRecipientId
) {
return new Group(groupInfo.getGroupId(),
groupInfo.getTitle(),
}
static Attachment from(
- SignalServiceDataMessage.Quote.QuotedAttachment a, final AttachmentFileProvider fileProvider
+ SignalServiceDataMessage.Quote.QuotedAttachment a,
+ final AttachmentFileProvider fileProvider
) {
return new Attachment(Optional.empty(),
Optional.empty(),
public record Preview(String title, String description, long date, String url, Optional<Attachment> image) {
- static Preview from(
- SignalServicePreview preview, final AttachmentFileProvider fileProvider
- ) {
+ static Preview from(SignalServicePreview preview, final AttachmentFileProvider fileProvider) {
return new Preview(preview.getTitle(),
preview.getDescription(),
preview.getDate(),
Optional<TextAttachment> textAttachment
) {
- public static Story from(
- SignalServiceStoryMessage storyMessage, final AttachmentFileProvider fileProvider
- ) {
+ public static Story from(SignalServiceStoryMessage storyMessage, final AttachmentFileProvider fileProvider) {
return new Story(storyMessage.getAllowsReplies().orElse(false),
storyMessage.getGroupContext().map(c -> GroupUtils.getGroupIdV2(c.getMasterKey())),
storyMessage.getFileAttachment().map(f -> Data.Attachment.from(f, fileProvider)),
) {
static TextAttachment from(
- SignalServiceTextAttachment textAttachment, final AttachmentFileProvider fileProvider
+ SignalServiceTextAttachment textAttachment,
+ final AttachmentFileProvider fileProvider
) {
return new TextAttachment(textAttachment.getText(),
textAttachment.getStyle().map(Style::from),
}
public static ServiceEnvironmentConfig getServiceEnvironmentConfig(
- ServiceEnvironment serviceEnvironment, String userAgent
+ ServiceEnvironment serviceEnvironment,
+ String userAgent
) {
final Interceptor userAgentInterceptor = chain -> chain.proceed(chain.request()
.newBuilder()
public class GroupUtils {
public static void setGroupContext(
- final SignalServiceDataMessage.Builder messageBuilder, final GroupInfo groupInfo
+ final SignalServiceDataMessage.Builder messageBuilder,
+ final GroupInfo groupInfo
) {
if (groupInfo instanceof GroupInfoV1) {
var group = SignalServiceGroup.newBuilder(SignalServiceGroup.Type.DELIVER)
}
public void startChangeNumber(
- String newNumber, boolean voiceVerification, String captcha
+ String newNumber,
+ boolean voiceVerification,
+ String captcha
) throws IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, RateLimitException, VerificationMethodNotAvailableException {
final var accountManager = dependencies.createUnauthenticatedAccountManager(newNumber, account.getPassword());
final var registrationApi = accountManager.getRegistrationApi();
}
public void finishChangeNumber(
- String newNumber, String verificationCode, String pin
+ String newNumber,
+ String verificationCode,
+ String pin
) throws IncorrectPinException, PinLockedException, IOException {
for (var attempts = 0; attempts < 5; attempts++) {
try {
}
private void finishChangeNumberInternal(
- String newNumber, String verificationCode, String pin
+ String newNumber,
+ String verificationCode,
+ String pin
) throws IncorrectPinException, PinLockedException, IOException {
final var pniIdentity = KeyUtils.generateIdentityKeyPair();
final var encryptedDeviceMessages = new ArrayList<OutgoingPushMessage>();
handlePniChangeNumberMessage(selfChangeNumber, updatePni);
}
- public void handlePniChangeNumberMessage(
- final SyncMessage.PniChangeNumber pniChangeNumber, final PNI updatedPni
- ) {
+ public void handlePniChangeNumberMessage(final SyncMessage.PniChangeNumber pniChangeNumber, final PNI updatedPni) {
if (pniChangeNumber.identityKeyPair != null
&& pniChangeNumber.registrationId != null
&& pniChangeNumber.signedPreKey != null) {
retrieveAttachment(attachment, input -> IOUtils.copyStream(input, outputStream));
}
- public void retrieveAttachment(
- SignalServiceAttachment attachment, AttachmentHandler consumer
- ) throws IOException {
+ public void retrieveAttachment(SignalServiceAttachment attachment, AttachmentHandler consumer) throws IOException {
if (attachment.isStream()) {
var input = attachment.asStream().getInputStream();
// don't close input stream here, it might be reused later (e.g. with contact sync messages ...)
}
private InputStream retrieveAttachmentAsStream(
- SignalServiceAttachmentPointer pointer, File tmpFile
+ SignalServiceAttachmentPointer pointer,
+ File tmpFile
) throws IOException {
try {
return dependencies.getMessageReceiver()
}
public void setExpirationTimer(
- RecipientId recipientId, int messageExpirationTimer, int messageExpirationTimerVersion
+ RecipientId recipientId,
+ int messageExpirationTimer,
+ int messageExpirationTimerVersion
) {
var contact = account.getContactStore().getContact(recipientId);
if (contact != null && (
}
public GroupInfoV2 getOrMigrateGroup(
- final GroupMasterKey groupMasterKey, final int revision, final byte[] signedGroupChange
+ final GroupMasterKey groupMasterKey,
+ final int revision,
+ final byte[] signedGroupChange
) {
final var groupSecretParams = GroupSecretParams.deriveFromMasterKey(groupMasterKey);
}
private DecryptedGroup handleDecryptedGroupResponse(
- GroupInfoV2 groupInfoV2, final DecryptedGroupResponse decryptedGroupResponse
+ GroupInfoV2 groupInfoV2,
+ final DecryptedGroupResponse decryptedGroupResponse
) {
final var groupSecretParams = GroupSecretParams.deriveFromMasterKey(groupInfoV2.getMasterKey());
ReceivedGroupSendEndorsements groupSendEndorsements = dependencies.getGroupsV2Operations()
}
private GroupChange handleGroupChangeResponse(
- final GroupInfoV2 groupInfoV2, final GroupChangeResponse groupChangeResponse
+ final GroupInfoV2 groupInfoV2,
+ final GroupChangeResponse groupChangeResponse
) {
ReceivedGroupSendEndorsements groupSendEndorsements = dependencies.getGroupsV2Operations()
.forGroup(GroupSecretParams.deriveFromMasterKey(groupInfoV2.getMasterKey()))
}
public Pair<GroupId, SendGroupMessageResults> createGroup(
- String name, Set<RecipientId> members, String avatarFile
+ String name,
+ Set<RecipientId> members,
+ String avatarFile
) throws IOException, AttachmentInvalidException {
final var selfRecipientId = account.getSelfRecipientId();
if (members != null && members.contains(selfRecipientId)) {
}
public SendGroupMessageResults quitGroup(
- final GroupId groupId, final Set<RecipientId> newAdmins
+ final GroupId groupId,
+ final Set<RecipientId> newAdmins
) throws IOException, LastGroupAdminException, NotAGroupMemberException, GroupNotFoundException {
var group = getGroupForUpdating(groupId);
if (group instanceof GroupInfoV1) {
context.getJobExecutor().enqueueJob(new SyncStorageJob());
}
- public SendGroupMessageResults sendGroupInfoRequest(
- GroupIdV1 groupId, RecipientId recipientId
- ) throws IOException {
+ public SendGroupMessageResults sendGroupInfoRequest(GroupIdV1 groupId, RecipientId recipientId) throws IOException {
var group = SignalServiceGroup.newBuilder(SignalServiceGroup.Type.REQUEST_INFO).withId(groupId.serialize());
var messageBuilder = SignalServiceDataMessage.newBuilder().asGroupMessage(group.build());
}
public SendGroupMessageResults sendGroupInfoMessage(
- GroupIdV1 groupId, RecipientId recipientId
+ GroupIdV1 groupId,
+ RecipientId recipientId
) throws IOException, NotAGroupMemberException, GroupNotFoundException, AttachmentInvalidException {
GroupInfoV1 g;
var group = getGroupForUpdating(groupId);
}
private void retrieveGroupV2Avatar(
- GroupSecretParams groupSecretParams, String cdnKey, OutputStream outputStream
+ GroupSecretParams groupSecretParams,
+ String cdnKey,
+ OutputStream outputStream
) throws IOException {
var groupOperations = dependencies.getGroupsV2Operations().forGroup(groupSecretParams);
}
private SendGroupMessageResults updateGroupV1(
- final GroupInfoV1 gv1, final String name, final Set<RecipientId> members, final byte[] avatarFile
+ final GroupInfoV1 gv1,
+ final String name,
+ final Set<RecipientId> members,
+ final byte[] avatarFile
) throws IOException, AttachmentInvalidException {
updateGroupV1Details(gv1, name, members, avatarFile);
}
private void updateGroupV1Details(
- final GroupInfoV1 g, final String name, final Collection<RecipientId> members, final byte[] avatarFile
+ final GroupInfoV1 g,
+ final String name,
+ final Collection<RecipientId> members,
+ final byte[] avatarFile
) throws IOException {
if (name != null) {
g.name = name;
* Change the expiration timer for a group
*/
private void setExpirationTimer(
- GroupInfoV1 groupInfoV1, int messageExpirationTimer
+ GroupInfoV1 groupInfoV1,
+ int messageExpirationTimer
) throws NotAGroupMemberException, GroupNotFoundException, IOException, GroupSendingNotAllowedException {
groupInfoV1.messageExpirationTime = messageExpirationTimer;
account.getGroupStore().updateGroup(groupInfoV1);
}
private SendGroupMessageResults quitGroupV2(
- final GroupInfoV2 groupInfoV2, final Set<RecipientId> newAdmins
+ final GroupInfoV2 groupInfoV2,
+ final Set<RecipientId> newAdmins
) throws LastGroupAdminException, IOException {
final var currentAdmins = groupInfoV2.getAdminMembers();
newAdmins.removeAll(currentAdmins);
}
private SendGroupMessageResults sendUpdateGroupV2Message(
- GroupInfoV2 group, DecryptedGroup newDecryptedGroup, GroupChange groupChange
+ GroupInfoV2 group,
+ DecryptedGroup newDecryptedGroup,
+ GroupChange groupChange
) throws IOException {
final var selfRecipientId = account.getSelfRecipientId();
final var members = group.getMembersIncludingPendingWithout(selfRecipientId);
}
DecryptedGroupJoinInfo getDecryptedGroupJoinInfo(
- GroupMasterKey groupMasterKey, GroupLinkPassword password
+ GroupMasterKey groupMasterKey,
+ GroupLinkPassword password
) throws IOException, GroupLinkNotActiveException {
var groupSecretParams = GroupSecretParams.deriveFromMasterKey(groupMasterKey);
}
GroupHistoryPage getDecryptedGroupHistoryPage(
- final GroupSecretParams groupSecretParams, int fromRevision, long sendEndorsementsExpirationMs
+ final GroupSecretParams groupSecretParams,
+ int fromRevision,
+ long sendEndorsementsExpirationMs
) throws NotAGroupMemberException {
try {
final var groupsV2AuthorizationString = getGroupAuthForToday(groupSecretParams);
return partialDecryptedGroup.revision;
}
- Pair<GroupInfoV2, DecryptedGroupResponse> createGroup(
- String name, Set<RecipientId> members, byte[] avatarFile
- ) {
+ Pair<GroupInfoV2, DecryptedGroupResponse> createGroup(String name, Set<RecipientId> members, byte[] avatarFile) {
final var newGroup = buildNewGroup(name, members, avatarFile);
if (newGroup == null) {
return null;
return new Pair<>(g, response);
}
- private GroupsV2Operations.NewGroup buildNewGroup(
- String name, Set<RecipientId> members, byte[] avatar
- ) {
+ private GroupsV2Operations.NewGroup buildNewGroup(String name, Set<RecipientId> members, byte[] avatar) {
final var profileKeyCredential = context.getProfileHelper()
.getExpiringProfileKeyCredential(context.getAccount().getSelfRecipientId());
if (profileKeyCredential == null) {
}
Pair<DecryptedGroup, GroupChangeResponse> updateGroup(
- GroupInfoV2 groupInfoV2, String name, String description, byte[] avatarFile
+ GroupInfoV2 groupInfoV2,
+ String name,
+ String description,
+ byte[] avatarFile
) throws IOException {
final var groupSecretParams = GroupSecretParams.deriveFromMasterKey(groupInfoV2.getMasterKey());
var groupOperations = dependencies.getGroupsV2Operations().forGroup(groupSecretParams);
}
Pair<DecryptedGroup, GroupChangeResponse> addMembers(
- GroupInfoV2 groupInfoV2, Set<RecipientId> newMembers
+ GroupInfoV2 groupInfoV2,
+ Set<RecipientId> newMembers
) throws IOException {
GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
}
Pair<DecryptedGroup, GroupChangeResponse> leaveGroup(
- GroupInfoV2 groupInfoV2, Set<RecipientId> membersToMakeAdmin
+ GroupInfoV2 groupInfoV2,
+ Set<RecipientId> membersToMakeAdmin
) throws IOException {
var pendingMembersList = groupInfoV2.getGroup().pendingMembers;
final var selfAci = getSelfAci();
}
Pair<DecryptedGroup, GroupChangeResponse> removeMembers(
- GroupInfoV2 groupInfoV2, Set<RecipientId> members
+ GroupInfoV2 groupInfoV2,
+ Set<RecipientId> members
) throws IOException {
final var memberUuids = members.stream()
.map(context.getRecipientHelper()::resolveSignalServiceAddress)
}
Pair<DecryptedGroup, GroupChangeResponse> approveJoinRequestMembers(
- GroupInfoV2 groupInfoV2, Set<RecipientId> members
+ GroupInfoV2 groupInfoV2,
+ Set<RecipientId> members
) throws IOException {
final var memberUuids = members.stream()
.map(context.getRecipientHelper()::resolveSignalServiceAddress)
}
Pair<DecryptedGroup, GroupChangeResponse> refuseJoinRequestMembers(
- GroupInfoV2 groupInfoV2, Set<RecipientId> members
+ GroupInfoV2 groupInfoV2,
+ Set<RecipientId> members
) throws IOException {
final var memberUuids = members.stream()
.map(context.getRecipientHelper()::resolveSignalServiceAddress)
}
Pair<DecryptedGroup, GroupChangeResponse> revokeInvitedMembers(
- GroupInfoV2 groupInfoV2, Set<RecipientId> members
+ GroupInfoV2 groupInfoV2,
+ Set<RecipientId> members
) throws IOException {
var pendingMembersList = groupInfoV2.getGroup().pendingMembers;
final var memberUuids = members.stream()
}
Pair<DecryptedGroup, GroupChangeResponse> banMembers(
- GroupInfoV2 groupInfoV2, Set<RecipientId> block
+ GroupInfoV2 groupInfoV2,
+ Set<RecipientId> block
) throws IOException {
GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
}
Pair<DecryptedGroup, GroupChangeResponse> unbanMembers(
- GroupInfoV2 groupInfoV2, Set<RecipientId> block
+ GroupInfoV2 groupInfoV2,
+ Set<RecipientId> block
) throws IOException {
GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
}
Pair<DecryptedGroup, GroupChangeResponse> setGroupLinkState(
- GroupInfoV2 groupInfoV2, GroupLinkState state
+ GroupInfoV2 groupInfoV2,
+ GroupLinkState state
) throws IOException {
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
}
Pair<DecryptedGroup, GroupChangeResponse> setEditDetailsPermission(
- GroupInfoV2 groupInfoV2, GroupPermission permission
+ GroupInfoV2 groupInfoV2,
+ GroupPermission permission
) throws IOException {
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
}
Pair<DecryptedGroup, GroupChangeResponse> setAddMemberPermission(
- GroupInfoV2 groupInfoV2, GroupPermission permission
+ GroupInfoV2 groupInfoV2,
+ GroupPermission permission
) throws IOException {
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
}
Pair<DecryptedGroup, GroupChangeResponse> setMemberAdmin(
- GroupInfoV2 groupInfoV2, RecipientId recipientId, boolean admin
+ GroupInfoV2 groupInfoV2,
+ RecipientId recipientId,
+ boolean admin
) throws IOException {
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
final var address = context.getRecipientHelper().resolveSignalServiceAddress(recipientId);
}
Pair<DecryptedGroup, GroupChangeResponse> setMessageExpirationTimer(
- GroupInfoV2 groupInfoV2, int messageExpirationTimer
+ GroupInfoV2 groupInfoV2,
+ int messageExpirationTimer
) throws IOException {
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
final var change = groupOperations.createModifyGroupTimerChange(messageExpirationTimer);
}
Pair<DecryptedGroup, GroupChangeResponse> setIsAnnouncementGroup(
- GroupInfoV2 groupInfoV2, boolean isAnnouncementGroup
+ GroupInfoV2 groupInfoV2,
+ boolean isAnnouncementGroup
) throws IOException {
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
final var change = groupOperations.createAnnouncementGroupChange(isAnnouncementGroup);
}
private Pair<DecryptedGroup, GroupChangeResponse> revokeInvites(
- GroupInfoV2 groupInfoV2, Set<DecryptedPendingMember> pendingMembers
+ GroupInfoV2 groupInfoV2,
+ Set<DecryptedPendingMember> pendingMembers
) throws IOException {
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
final var uuidCipherTexts = pendingMembers.stream().map(member -> {
}
private Pair<DecryptedGroup, GroupChangeResponse> approveJoinRequest(
- GroupInfoV2 groupInfoV2, Set<UUID> uuids
+ GroupInfoV2 groupInfoV2,
+ Set<UUID> uuids
) throws IOException {
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
return commitChange(groupInfoV2, groupOperations.createApproveGroupJoinRequest(uuids));
}
private Pair<DecryptedGroup, GroupChangeResponse> refuseJoinRequest(
- GroupInfoV2 groupInfoV2, Set<ServiceId> serviceIds
+ GroupInfoV2 groupInfoV2,
+ Set<ServiceId> serviceIds
) throws IOException {
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
return commitChange(groupInfoV2, groupOperations.createRefuseGroupJoinRequest(serviceIds, false, List.of()));
}
private Pair<DecryptedGroup, GroupChangeResponse> ejectMembers(
- GroupInfoV2 groupInfoV2, Set<ACI> members
+ GroupInfoV2 groupInfoV2,
+ Set<ACI> members
) throws IOException {
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
return commitChange(groupInfoV2, groupOperations.createRemoveMembersChange(members, false, List.of()));
}
private Pair<DecryptedGroup, GroupChangeResponse> commitChange(
- GroupInfoV2 groupInfoV2, GroupChange.Actions.Builder change
+ GroupInfoV2 groupInfoV2,
+ GroupChange.Actions.Builder change
) throws IOException {
final var groupSecretParams = GroupSecretParams.deriveFromMasterKey(groupInfoV2.getMasterKey());
final var groupOperations = dependencies.getGroupsV2Operations().forGroup(groupSecretParams);
}
private GroupsV2AuthorizationString getAuthorizationString(
- final GroupSecretParams groupSecretParams, final long todaySeconds
+ final GroupSecretParams groupSecretParams,
+ final long todaySeconds
) throws VerificationFailedException {
var authCredentialResponse = groupApiCredentials.get(todaySeconds);
final var aci = getSelfAci();
return fingerprint == null ? null : fingerprint.getScannableFingerprint();
}
- private Fingerprint computeSafetyNumberFingerprint(
- final ServiceId serviceId, final IdentityKey theirIdentityKey
- ) {
+ private Fingerprint computeSafetyNumberFingerprint(final ServiceId serviceId, final IdentityKey theirIdentityKey) {
if (!serviceId.isUnknown()) {
return Utils.computeSafetyNumberForUuid(account.getAci(),
account.getAciIdentityKeyPair().getPublicKey(),
}
private boolean trustIdentity(
- RecipientId recipientId, BiFunction<ServiceId, IdentityKey, Boolean> verifier, TrustLevel trustLevel
+ RecipientId recipientId,
+ BiFunction<ServiceId, IdentityKey, Boolean> verifier,
+ TrustLevel trustLevel
) {
final var address = account.getRecipientAddressResolver().resolveRecipientAddress(recipientId);
final var serviceId = address.serviceId().orElse(null);
}
private SignalServiceContent validate(
- Envelope envelope, SignalServiceCipherResult cipherResult, long serverDeliveredTimestamp
+ Envelope envelope,
+ SignalServiceCipherResult cipherResult,
+ long serverDeliveredTimestamp
) throws ProtocolInvalidKeyException, ProtocolInvalidMessageException, UnsupportedDataMessageException, InvalidMessageStructureException {
final var content = cipherResult.getContent();
final var envelopeMetadata = cipherResult.getMetadata();
}
public List<HandleAction> handleMessage(
- SignalServiceEnvelope envelope, SignalServiceContent content, ReceiveConfig receiveConfig
+ SignalServiceEnvelope envelope,
+ SignalServiceContent content,
+ ReceiveConfig receiveConfig
) {
var actions = new ArrayList<HandleAction>();
final var senderDeviceAddress = getSender(envelope, content);
}
private boolean handlePniSignatureMessage(
- final SignalServicePniSignatureMessage message, final SignalServiceAddress senderAddress
+ final SignalServicePniSignatureMessage message,
+ final SignalServiceAddress senderAddress
) {
final var aci = senderAddress.getServiceId();
final var aciIdentity = account.getIdentityKeyStore().getIdentityInfo(aci);
}
private List<HandleAction> handleSignalServiceStoryMessage(
- SignalServiceStoryMessage message, RecipientId source, boolean ignoreAttachments
+ SignalServiceStoryMessage message,
+ RecipientId source,
+ boolean ignoreAttachments
) {
var actions = new ArrayList<HandleAction>();
if (message.getGroupContext().isPresent()) {
this.secureValueRecoveries = secureValueRecoveries;
}
- public void setRegistrationLockPin(
- String pin, MasterKey masterKey
- ) throws IOException {
+ public void setRegistrationLockPin(String pin, MasterKey masterKey) throws IOException {
IOException exception = null;
for (final var secureValueRecovery : secureValueRecoveries) {
try {
}
public SecureValueRecovery.RestoreResponse.Success getRegistrationLockData(
- String pin, LockedException lockedException
+ String pin,
+ LockedException lockedException
) throws IOException, IncorrectPinException {
var svr2Credentials = lockedException.getSvr2Credentials();
if (svr2Credentials != null) {
}
public SecureValueRecovery.RestoreResponse.Success getRegistrationLockData(
- SecureValueRecovery secureValueRecovery, AuthCredentials authCredentials, String pin
+ SecureValueRecovery secureValueRecovery,
+ AuthCredentials authCredentials,
+ String pin
) throws IOException, IncorrectPinException {
final var restoreResponse = secureValueRecovery.restoreDataPreRegistration(authCredentials, null, pin);
private final SignalAccount account;
private final SignalDependencies dependencies;
- public PreKeyHelper(
- final SignalAccount account, final SignalDependencies dependencies
- ) {
+ public PreKeyHelper(final SignalAccount account, final SignalDependencies dependencies) {
this.account = account;
this.dependencies = dependencies;
}
}
private boolean refreshPreKeysIfNecessary(
- final ServiceIdType serviceIdType, final IdentityKeyPair identityKeyPair
+ final ServiceIdType serviceIdType,
+ final IdentityKeyPair identityKeyPair
) throws IOException {
OneTimePreKeyCounts preKeyCounts;
try {
}
private List<KyberPreKeyRecord> generateKyberPreKeys(
- ServiceIdType serviceIdType, final IdentityKeyPair identityKeyPair
+ ServiceIdType serviceIdType,
+ final IdentityKeyPair identityKeyPair
) {
final var accountData = account.getAccountData(serviceIdType);
final var offset = accountData.getPreKeyMetadata().getNextKyberPreKeyId();
}
private KyberPreKeyRecord generateLastResortKyberPreKey(
- ServiceIdType serviceIdType, IdentityKeyPair identityKeyPair, final int offset
+ ServiceIdType serviceIdType,
+ IdentityKeyPair identityKeyPair,
+ final int offset
) {
final var accountData = account.getAccountData(serviceIdType);
final var signedPreKeyId = accountData.getPreKeyMetadata().getNextKyberPreKeyId() + offset;
}
private Profile decryptProfileAndDownloadAvatar(
- final RecipientId recipientId, final ProfileKey profileKey, final SignalServiceProfile encryptedProfile
+ final RecipientId recipientId,
+ final ProfileKey profileKey,
+ final SignalServiceProfile encryptedProfile
) {
final var avatarPath = encryptedProfile.getAvatar();
downloadProfileAvatar(recipientId, avatarPath, profileKey);
}
public void downloadProfileAvatar(
- final RecipientId recipientId, final String avatarPath, final ProfileKey profileKey
+ final RecipientId recipientId,
+ final String avatarPath,
+ final ProfileKey profileKey
) {
var profile = account.getProfileStore().getProfile(recipientId);
if (profile == null || !Objects.equals(avatarPath, profile.getAvatarUrlPath())) {
}
private Single<ProfileAndCredential> retrieveProfile(
- RecipientId recipientId, SignalServiceProfile.RequestType requestType
+ RecipientId recipientId,
+ SignalServiceProfile.RequestType requestType
) {
var unidentifiedAccess = getUnidentifiedAccess(recipientId);
var profileKey = Optional.ofNullable(account.getProfileStore().getProfileKey(recipientId));
});
}
- private void downloadProfileAvatar(
- RecipientAddress address, String avatarPath, ProfileKey profileKey
- ) {
+ private void downloadProfileAvatar(RecipientAddress address, String avatarPath, ProfileKey profileKey) {
if (avatarPath == null) {
try {
context.getAvatarStore().deleteProfileAvatar(address);
}
private void retrieveProfileAvatar(
- String avatarPath, ProfileKey profileKey, OutputStream outputStream
+ String avatarPath,
+ ProfileKey profileKey,
+ OutputStream outputStream
) throws IOException {
var tmpFile = IOUtils.createTempFile();
try (var input = dependencies.getMessageReceiver()
}
public void receiveMessages(
- Duration timeout, boolean returnOnTimeout, Integer maxMessages, Manager.ReceiveMessageHandler handler
+ Duration timeout,
+ boolean returnOnTimeout,
+ Integer maxMessages,
+ Manager.ReceiveMessageHandler handler
) throws IOException {
account.setNeedsToRetryFailedMessages(true);
hasCaughtUpWithOldMessages = false;
}
private List<HandleAction> retryFailedReceivedMessage(
- final Manager.ReceiveMessageHandler handler, final CachedMessage cachedMessage
+ final Manager.ReceiveMessageHandler handler,
+ final CachedMessage cachedMessage
) {
var envelope = cachedMessage.loadEnvelope();
if (envelope == null) {
}
public RecipientId resolveRecipientByUsernameOrLink(
- String username, boolean forceRefresh
+ String username,
+ boolean forceRefresh
) throws UnregisteredRecipientException {
final Username finalUsername;
try {
}
private Map<String, RegisteredUser> getRegisteredUsers(
- final Set<String> numbers, final boolean isPartialRefresh
+ final Set<String> numbers,
+ final boolean isPartialRefresh
) throws IOException {
Map<String, RegisteredUser> registeredUsers = getRegisteredUsersV2(numbers, isPartialRefresh);
}
private Map<String, RegisteredUser> getRegisteredUsersV2(
- final Set<String> numbers, boolean isPartialRefresh
+ final Set<String> numbers,
+ boolean isPartialRefresh
) throws IOException {
final var previousNumbers = isPartialRefresh ? Set.<String>of() : account.getCdsiStore().getAllNumbers();
final var newNumbers = new HashSet<>(numbers) {{
}
public SendMessageResult sendReceiptMessage(
- final SignalServiceReceiptMessage receiptMessage, final RecipientId recipientId
+ final SignalServiceReceiptMessage receiptMessage,
+ final RecipientId recipientId
) {
final var messageSendLogStore = account.getMessageSendLogStore();
final var result = handleSendMessage(recipientId,
}
public SendMessageResult sendRetryReceipt(
- DecryptionErrorMessage errorMessage, RecipientId recipientId, Optional<GroupId> groupId
+ DecryptionErrorMessage errorMessage,
+ RecipientId recipientId,
+ Optional<GroupId> groupId
) {
logger.debug("Sending retry receipt for {} to {}, device: {}",
errorMessage.getTimestamp(),
}
public SendMessageResult sendSelfMessage(
- SignalServiceDataMessage.Builder messageBuilder, Optional<Long> editTargetTimestamp
+ SignalServiceDataMessage.Builder messageBuilder,
+ Optional<Long> editTargetTimestamp
) {
final var recipientId = account.getSelfRecipientId();
final var contact = account.getContactStore().getContact(recipientId);
}
}
- public SendMessageResult sendTypingMessage(
- SignalServiceTypingMessage message, RecipientId recipientId
- ) {
+ public SendMessageResult sendTypingMessage(SignalServiceTypingMessage message, RecipientId recipientId) {
final var result = handleSendMessage(recipientId,
(messageSender, address, unidentifiedAccess, includePniSignature) -> messageSender.sendTyping(List.of(
address), List.of(unidentifiedAccess), message, null).getFirst());
}
public List<SendMessageResult> sendGroupTypingMessage(
- SignalServiceTypingMessage message, GroupId groupId
+ SignalServiceTypingMessage message,
+ GroupId groupId
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException {
final var g = getGroupForSending(groupId);
if (g.isAnnouncementGroup() && !g.isAdmin(account.getSelfRecipientId())) {
}
public SendMessageResult resendMessage(
- final RecipientId recipientId, final long timestamp, final MessageSendLogEntry messageSendLogEntry
+ final RecipientId recipientId,
+ final long timestamp,
+ final MessageSendLogEntry messageSendLogEntry
) {
logger.trace("Resending message {} to {}", timestamp, recipientId);
if (messageSendLogEntry.groupId().isEmpty()) {
}
private List<SendMessageResult> sendGroupMessageInternalWithLegacy(
- final LegacySenderHandler sender, final Set<RecipientId> recipientIds, final boolean isRecipientUpdate
+ final LegacySenderHandler sender,
+ final Set<RecipientId> recipientIds,
+ final boolean isRecipientUpdate
) throws IOException {
final var recipientIdList = new ArrayList<>(recipientIds);
final var addresses = recipientIdList.stream()
}
private SendMessageResult sendMessage(
- SignalServiceDataMessage message, RecipientId recipientId, Optional<Long> editTargetTimestamp
+ SignalServiceDataMessage message,
+ RecipientId recipientId,
+ Optional<Long> editTargetTimestamp
) {
final var messageSendLogStore = account.getMessageSendLogStore();
final var urgent = true;
}
public StickerPack addOrUpdateStickerPack(
- final StickerPackId stickerPackId, final byte[] stickerPackKey, final boolean installed
+ final StickerPackId stickerPackId,
+ final byte[] stickerPackKey,
+ final boolean installed
) {
final var sticker = account.getStickerStore().getStickerPack(stickerPackId);
if (sticker != null) {
}
public JsonStickerPack getOrRetrieveStickerPack(
- StickerPackId packId, byte[] packKey
+ StickerPackId packId,
+ byte[] packKey
) throws InvalidStickerException {
try {
retrieveStickerPack(packId, packKey);
}
private boolean writeToStorage(
- final StorageKey storageKey, final SignalStorageManifest remoteManifest, final boolean needsForcePush
+ final StorageKey storageKey,
+ final SignalStorageManifest remoteManifest,
+ final boolean needsForcePush
) throws IOException, RetryLaterException {
final WriteOperationResult remoteWriteOperation;
try (final var connection = account.getAccountDatabase().getConnection()) {
}
private List<SignalStorageRecord> getSignalStorageRecords(
- final StorageKey storageKey, final List<StorageId> storageIds
+ final StorageKey storageKey,
+ final List<StorageId> storageIds
) throws IOException {
List<SignalStorageRecord> records;
try {
}
private List<SignalStorageRecord> buildLocalStorageRecords(
- final Connection connection, final List<StorageId> storageIds
+ final Connection connection,
+ final List<StorageId> storageIds
) throws SQLException {
final var records = new ArrayList<SignalStorageRecord>();
for (final var storageId : storageIds) {
}
private SignalStorageRecord buildLocalStorageRecord(
- Connection connection, StorageId storageId
+ Connection connection,
+ StorageId storageId
) throws SQLException {
return switch (ManifestRecord.Identifier.Type.fromValue(storageId.getType())) {
case ManifestRecord.Identifier.Type.CONTACT -> {
* exclusive to the local data set.
*/
private static IdDifferenceResult findIdDifference(
- Collection<StorageId> remoteIds, Collection<StorageId> localIds
+ Collection<StorageId> remoteIds,
+ Collection<StorageId> localIds
) {
final var base64Encoder = Base64.getEncoder();
final var remoteByRawId = remoteIds.stream()
}
private List<StorageId> processKnownRecords(
- final Connection connection, List<SignalStorageRecord> records
+ final Connection connection,
+ List<SignalStorageRecord> records
) throws SQLException {
final var unknownRecords = new ArrayList<StorageId>();
@NotNull
private DeviceContact getDeviceContact(
- final RecipientAddress address, final RecipientId recipientId, final Contact contact
+ final RecipientAddress address,
+ final RecipientId recipientId,
+ final Contact contact
) throws IOException {
var currentIdentity = address.serviceId().isEmpty()
? null
}
public SendMessageResult sendVerifiedMessage(
- SignalServiceAddress destination, IdentityKey identityKey, TrustLevel trustLevel
+ SignalServiceAddress destination,
+ IdentityKey identityKey,
+ TrustLevel trustLevel
) {
var verifiedMessage = new VerifiedMessage(destination,
identityKey,
}
public SendMessageResult sendStickerOperationsMessage(
- List<StickerPack> installStickers, List<StickerPack> removeStickers
+ List<StickerPack> installStickers,
+ List<StickerPack> removeStickers
) {
var installStickerMessages = installStickers.stream().map(s -> getStickerPackOperationMessage(s, true));
var removeStickerMessages = removeStickers.stream().map(s -> getStickerPackOperationMessage(s, false));
}
private static StickerPackOperationMessage getStickerPackOperationMessage(
- final StickerPack s, final boolean installed
+ final StickerPack s,
+ final boolean installed
) {
return new StickerPackOperationMessage(s.packId().serialize(),
s.packKey(),
}
}
- public SendMessageResult sendMessageRequestResponse(
- final MessageRequestResponse.Type type, final GroupId groupId
- ) {
+ public SendMessageResult sendMessageRequestResponse(final MessageRequestResponse.Type type, final GroupId groupId) {
final var response = MessageRequestResponseMessage.forGroup(groupId.serialize(), localToRemoteType(type));
return context.getSendHelper().sendSyncMessage(SignalServiceSyncMessage.forMessageRequestResponse(response));
}
public SendMessageResult sendMessageRequestResponse(
- final MessageRequestResponse.Type type, final RecipientId recipientId
+ final MessageRequestResponse.Type type,
+ final RecipientId recipientId
) {
final var address = account.getRecipientAddressResolver().resolveRecipientAddress(recipientId);
if (address.serviceId().isEmpty()) {
}
private static byte[] getTargetUnidentifiedAccessKey(
- final Profile targetProfile, final ProfileKey theirProfileKey
+ final Profile targetProfile,
+ final ProfileKey theirProfileKey
) {
return switch (targetProfile.getUnidentifiedAccessMode()) {
case ENABLED -> theirProfileKey == null ? null : UnidentifiedAccess.deriveAccessKeyFrom(theirProfileKey);
@Override
public void startChangeNumber(
- String newNumber, boolean voiceVerification, String captcha
+ String newNumber,
+ boolean voiceVerification,
+ String captcha
) throws RateLimitException, IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, NotPrimaryDeviceException, VerificationMethodNotAvailableException {
if (!account.isPrimaryDevice()) {
throw new NotPrimaryDeviceException();
@Override
public void finishChangeNumber(
- String newNumber, String verificationCode, String pin
+ String newNumber,
+ String verificationCode,
+ String pin
) throws IncorrectPinException, PinLockedException, IOException, NotPrimaryDeviceException {
if (!account.isPrimaryDevice()) {
throw new NotPrimaryDeviceException();
@Override
public void submitRateLimitRecaptchaChallenge(
- String challenge, String captcha
+ String challenge,
+ String captcha
) throws IOException, CaptchaRejectedException {
captcha = captcha == null ? null : captcha.replace("signalcaptcha://", "");
@Override
public SendGroupMessageResults quitGroup(
- GroupId groupId, Set<RecipientIdentifier.Single> groupAdmins
+ GroupId groupId,
+ Set<RecipientIdentifier.Single> groupAdmins
) throws GroupNotFoundException, IOException, NotAGroupMemberException, LastGroupAdminException, UnregisteredRecipientException {
final var newAdmins = context.getRecipientHelper().resolveRecipients(groupAdmins);
return context.getGroupHelper().quitGroup(groupId, newAdmins);
@Override
public Pair<GroupId, SendGroupMessageResults> createGroup(
- String name, Set<RecipientIdentifier.Single> members, String avatarFile
+ String name,
+ Set<RecipientIdentifier.Single> members,
+ String avatarFile
) throws IOException, AttachmentInvalidException, UnregisteredRecipientException {
return context.getGroupHelper()
.createGroup(name,
@Override
public SendGroupMessageResults updateGroup(
- final GroupId groupId, final UpdateGroup updateGroup
+ final GroupId groupId,
+ final UpdateGroup updateGroup
) throws IOException, GroupNotFoundException, AttachmentInvalidException, NotAGroupMemberException, GroupSendingNotAllowedException, UnregisteredRecipientException {
return context.getGroupHelper()
.updateGroup(groupId,
}
private SendMessageResults sendMessage(
- SignalServiceDataMessage.Builder messageBuilder, Set<RecipientIdentifier> recipients, boolean notifySelf
+ SignalServiceDataMessage.Builder messageBuilder,
+ Set<RecipientIdentifier> recipients,
+ boolean notifySelf
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException {
return sendMessage(messageBuilder, recipients, notifySelf, Optional.empty());
}
}
private SendMessageResults sendTypingMessage(
- SignalServiceTypingMessage.Action action, Set<RecipientIdentifier> recipients
+ SignalServiceTypingMessage.Action action,
+ Set<RecipientIdentifier> recipients
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException {
var results = new HashMap<RecipientIdentifier, List<SendMessageResult>>();
final var timestamp = System.currentTimeMillis();
@Override
public SendMessageResults sendTypingMessage(
- TypingAction action, Set<RecipientIdentifier> recipients
+ TypingAction action,
+ Set<RecipientIdentifier> recipients
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException {
return sendTypingMessage(action.toSignalService(), recipients);
}
@Override
- public SendMessageResults sendReadReceipt(
- RecipientIdentifier.Single sender, List<Long> messageIds
- ) {
+ public SendMessageResults sendReadReceipt(RecipientIdentifier.Single sender, List<Long> messageIds) {
final var timestamp = System.currentTimeMillis();
var receiptMessage = new SignalServiceReceiptMessage(SignalServiceReceiptMessage.Type.READ,
messageIds,
}
@Override
- public SendMessageResults sendViewedReceipt(
- RecipientIdentifier.Single sender, List<Long> messageIds
- ) {
+ public SendMessageResults sendViewedReceipt(RecipientIdentifier.Single sender, List<Long> messageIds) {
final var timestamp = System.currentTimeMillis();
var receiptMessage = new SignalServiceReceiptMessage(SignalServiceReceiptMessage.Type.VIEWED,
messageIds,
@Override
public SendMessageResults sendMessage(
- Message message, Set<RecipientIdentifier> recipients, boolean notifySelf
+ Message message,
+ Set<RecipientIdentifier> recipients,
+ boolean notifySelf
) throws IOException, AttachmentInvalidException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException, UnregisteredRecipientException, InvalidStickerException {
final var selfProfile = context.getProfileHelper().getSelfProfile();
if (selfProfile == null || selfProfile.getDisplayName().isEmpty()) {
@Override
public SendMessageResults sendEditMessage(
- Message message, Set<RecipientIdentifier> recipients, long editTargetTimestamp
+ Message message,
+ Set<RecipientIdentifier> recipients,
+ long editTargetTimestamp
) throws IOException, AttachmentInvalidException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException, UnregisteredRecipientException, InvalidStickerException {
final var messageBuilder = SignalServiceDataMessage.newBuilder();
applyMessage(messageBuilder, message);
}
private void applyMessage(
- final SignalServiceDataMessage.Builder messageBuilder, final Message message
+ final SignalServiceDataMessage.Builder messageBuilder,
+ final Message message
) throws AttachmentInvalidException, IOException, UnregisteredRecipientException, InvalidStickerException {
final var additionalAttachments = new ArrayList<SignalServiceAttachment>();
if (message.messageText().length() > ServiceConfig.MAX_MESSAGE_BODY_SIZE) {
@Override
public SendMessageResults sendRemoteDeleteMessage(
- long targetSentTimestamp, Set<RecipientIdentifier> recipients
+ long targetSentTimestamp,
+ Set<RecipientIdentifier> recipients
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException {
var delete = new SignalServiceDataMessage.RemoteDelete(targetSentTimestamp);
final var messageBuilder = SignalServiceDataMessage.newBuilder().withRemoteDelete(delete);
@Override
public SendMessageResults sendPaymentNotificationMessage(
- byte[] receipt, String note, RecipientIdentifier.Single recipient
+ byte[] receipt,
+ String note,
+ RecipientIdentifier.Single recipient
) throws IOException {
final var paymentNotification = new SignalServiceDataMessage.PaymentNotification(receipt, note);
final var payment = new SignalServiceDataMessage.Payment(paymentNotification, null);
@Override
public SendMessageResults sendMessageRequestResponse(
- final MessageRequestResponse.Type type, final Set<RecipientIdentifier> recipients
+ final MessageRequestResponse.Type type,
+ final Set<RecipientIdentifier> recipients
) {
var results = new HashMap<RecipientIdentifier, List<SendMessageResult>>();
for (final var recipient : recipients) {
@Override
public void setContactName(
- RecipientIdentifier.Single recipient, String givenName, final String familyName
+ RecipientIdentifier.Single recipient,
+ String givenName,
+ final String familyName
) throws NotPrimaryDeviceException, UnregisteredRecipientException {
if (!account.isPrimaryDevice()) {
throw new NotPrimaryDeviceException();
@Override
public void setContactsBlocked(
- Collection<RecipientIdentifier.Single> recipients, boolean blocked
+ Collection<RecipientIdentifier.Single> recipients,
+ boolean blocked
) throws IOException, UnregisteredRecipientException {
if (recipients.isEmpty()) {
return;
@Override
public void setGroupsBlocked(
- final Collection<GroupId> groupIds, final boolean blocked
+ final Collection<GroupId> groupIds,
+ final boolean blocked
) throws GroupNotFoundException, IOException {
if (groupIds.isEmpty()) {
return;
@Override
public void setExpirationTimer(
- RecipientIdentifier.Single recipient, int messageExpirationTimer
+ RecipientIdentifier.Single recipient,
+ int messageExpirationTimer
) throws IOException, UnregisteredRecipientException {
var recipientId = context.getRecipientHelper().resolveRecipient(recipient);
context.getContactHelper().setExpirationTimer(recipientId, messageExpirationTimer);
@Override
public void receiveMessages(
- Optional<Duration> timeout, Optional<Integer> maxMessages, ReceiveMessageHandler handler
+ Optional<Duration> timeout,
+ Optional<Integer> maxMessages,
+ ReceiveMessageHandler handler
) throws IOException, AlreadyReceivingException {
receiveMessages(timeout.orElse(Duration.ofMinutes(1)), timeout.isPresent(), maxMessages.orElse(null), handler);
}
}
private void receiveMessages(
- Duration timeout, boolean returnOnTimeout, Integer maxMessages, ReceiveMessageHandler handler
+ Duration timeout,
+ boolean returnOnTimeout,
+ Integer maxMessages,
+ ReceiveMessageHandler handler
) throws IOException, AlreadyReceivingException {
synchronized (messageHandlers) {
if (isReceiving()) {
@Override
public boolean trustIdentityVerified(
- RecipientIdentifier.Single recipient, IdentityVerificationCode verificationCode
+ RecipientIdentifier.Single recipient,
+ IdentityVerificationCode verificationCode
) throws UnregisteredRecipientException {
return switch (verificationCode) {
case IdentityVerificationCode.Fingerprint fingerprint -> trustIdentity(recipient,
}
private boolean trustIdentity(
- RecipientIdentifier.Single recipient, Function<RecipientId, Boolean> trustMethod
+ RecipientIdentifier.Single recipient,
+ Function<RecipientId, Boolean> trustMethod
) throws UnregisteredRecipientException {
final var recipientId = context.getRecipientHelper().resolveRecipient(recipient);
final var updated = trustMethod.apply(recipientId);
@Override
public void register(
- boolean voiceVerification, String captcha, final boolean forceRegister
+ boolean voiceVerification,
+ String captcha,
+ final boolean forceRegister
) throws IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, RateLimitException, VerificationMethodNotAvailableException {
if (account.isRegistered()
&& account.getServiceEnvironment() != null
@Override
public void verifyAccount(
- String verificationCode, String pin
+ String verificationCode,
+ String pin
) throws IOException, PinLockedException, IncorrectPinException {
if (account.isRegistered()) {
throw new IOException("Account is already registered");
}
private static void createUuidMappingTable(
- final Connection connection, final Statement statement
+ final Connection connection,
+ final Statement statement
) throws SQLException {
statement.executeUpdate("""
CREATE TABLE tmp_mapping_table (
}
public void storeAttachmentPreview(
- final SignalServiceAttachmentPointer pointer, final AttachmentStorer storer
+ final SignalServiceAttachmentPointer pointer,
+ final AttachmentStorer storer
) throws IOException {
storeAttachment(getAttachmentPreviewFile(pointer.getRemoteId(),
pointer.getFileName(),
}
public void storeAttachment(
- final SignalServiceAttachmentPointer pointer, final AttachmentStorer storer
+ final SignalServiceAttachmentPointer pointer,
+ final AttachmentStorer storer
) throws IOException {
storeAttachment(getAttachmentFile(pointer), storer);
}
}
private File getAttachmentPreviewFile(
- SignalServiceAttachmentRemoteId attachmentId, Optional<String> filename, Optional<String> contentType
+ SignalServiceAttachmentRemoteId attachmentId,
+ Optional<String> filename,
+ Optional<String> contentType
) {
final var extension = getAttachmentExtension(filename, contentType);
return new File(attachmentsPath, attachmentId.toString() + extension + ".preview");
}
private File getAttachmentFile(
- SignalServiceAttachmentRemoteId attachmentId, Optional<String> filename, Optional<String> contentType
+ SignalServiceAttachmentRemoteId attachmentId,
+ Optional<String> filename,
+ Optional<String> contentType
) {
final var extension = getAttachmentExtension(filename, contentType);
return new File(attachmentsPath, attachmentId.toString() + extension);
}
- private static String getAttachmentExtension(
- final Optional<String> filename, final Optional<String> contentType
- ) {
+ private static String getAttachmentExtension(final Optional<String> filename, final Optional<String> contentType) {
return filename.filter(f -> f.contains("."))
.map(f -> f.substring(f.lastIndexOf(".") + 1))
.or(() -> contentType.flatMap(MimeUtils::guessExtensionFromMimeType))
}
public static <T extends Database> T initDatabase(
- File databaseFile, Function<HikariDataSource, T> newDatabase
+ File databaseFile,
+ Function<HikariDataSource, T> newDatabase
) throws SQLException {
HikariDataSource dataSource = null;
}
public static SignalAccount load(
- File dataPath, String accountPath, boolean waitForLock, final Settings settings
+ File dataPath,
+ String accountPath,
+ boolean waitForLock,
+ final Settings settings
) throws IOException {
logger.trace("Opening account file");
final var fileName = getFileName(dataPath, accountPath);
}
public void finishLinking(
- final int deviceId, final PreKeyCollection aciPreKeys, final PreKeyCollection pniPreKeys
+ final int deviceId,
+ final PreKeyCollection aciPreKeys,
+ final PreKeyCollection pniPreKeys
) {
this.registered = true;
this.deviceId = deviceId;
}
private void mergeRecipients(
- final Connection connection, RecipientId recipientId, RecipientId toBeMergedRecipientId
+ final Connection connection,
+ RecipientId recipientId,
+ RecipientId toBeMergedRecipientId
) throws SQLException {
getMessageCache().mergeRecipients(recipientId, toBeMergedRecipientId);
getGroupStore().mergeRecipients(connection, recipientId, toBeMergedRecipientId);
return f.exists() && !f.isDirectory() && f.length() > 0L;
}
- private void load(
- File dataPath, String accountPath, final Settings settings
- ) throws IOException {
+ private void load(File dataPath, String accountPath, final Settings settings) throws IOException {
logger.trace("Loading account file {}", accountPath);
this.dataPath = dataPath;
this.accountPath = accountPath;
}
private void loadLegacyStores(
- final JsonNode rootNode, final LegacyJsonSignalProtocolStore legacySignalProtocolStore
+ final JsonNode rootNode,
+ final LegacyJsonSignalProtocolStore legacySignalProtocolStore
) {
var legacyRecipientStoreNode = rootNode.get("recipientStore");
if (legacyRecipientStoreNode != null) {
}
}
- public List<StorageId> getUnknownStorageIds(
- Connection connection, Collection<Integer> types
- ) throws SQLException {
+ public List<StorageId> getUnknownStorageIds(Connection connection, Collection<Integer> types) throws SQLException {
final var typesCommaSeparated = types.stream().map(String::valueOf).collect(Collectors.joining(","));
final var sql = (
"""
}
public static <T> T executeQuerySingleRow(
- PreparedStatement statement, ResultSetMapper<T> mapper
+ PreparedStatement statement,
+ ResultSetMapper<T> mapper
) throws SQLException {
final var resultSet = statement.executeQuery();
if (!resultSet.next()) {
}
public static <T> Optional<T> executeQueryForOptional(
- PreparedStatement statement, ResultSetMapper<T> mapper
+ PreparedStatement statement,
+ ResultSetMapper<T> mapper
) throws SQLException {
final var resultSet = statement.executeQuery();
if (!resultSet.next()) {
}
public static <T> Stream<T> executeQueryForStream(
- PreparedStatement statement, ResultSetMapper<T> mapper
+ PreparedStatement statement,
+ ResultSetMapper<T> mapper
) throws SQLException {
final var resultSet = statement.executeQuery();
private final AccountLoader accountLoader;
public AccountsStore(
- final File dataPath, final ServiceEnvironment serviceEnvironment, final AccountLoader accountLoader
+ final File dataPath,
+ final ServiceEnvironment serviceEnvironment,
+ final AccountLoader accountLoader
) throws IOException {
this.dataPath = dataPath;
this.serviceEnvironment = getServiceEnvironmentString(serviceEnvironment);
}
private AccountsStorage upgradeAccountsFile(
- final FileChannel fileChannel, final AccountsStorage storage, final int accountsVersion
+ final FileChannel fileChannel,
+ final AccountsStorage storage,
+ final int accountsVersion
) {
try {
List<AccountsStorage.Account> newAccounts = storage.accounts();
}
public void setUnidentifiedDeliveryIndicators(
- final Connection connection, final boolean value
+ final Connection connection,
+ final boolean value
) throws SQLException {
if (keyValueStore.storeEntry(connection, unidentifiedDeliveryIndicators, value)) {
recipientStore.rotateSelfStorageId(connection);
}
public void setPhoneNumberSharingMode(
- final Connection connection, final PhoneNumberSharingMode value
+ final Connection connection,
+ final PhoneNumberSharingMode value
) throws SQLException {
if (keyValueStore.storeEntry(connection, phoneNumberSharingMode, value)) {
recipientStore.rotateSelfStorageId(connection);
private final RecipientResolver recipientResolver;
public GroupInfoV2(
- final GroupIdV2 groupId, final GroupMasterKey masterKey, final RecipientResolver recipientResolver
+ final GroupIdV2 groupId,
+ final GroupMasterKey masterKey,
+ final RecipientResolver recipientResolver
) {
this.groupId = groupId;
this.masterKey = masterKey;
}
public void storeStorageRecord(
- final Connection connection, final GroupId groupId, final StorageId storageId, final byte[] storageRecord
+ final Connection connection,
+ final GroupId groupId,
+ final StorageId storageId,
+ final byte[] storageRecord
) throws SQLException {
final var groupTable = groupId instanceof GroupIdV1 ? TABLE_GROUP_V1 : TABLE_GROUP_V2;
final var deleteSql = (
}
public GroupInfoV2 getGroupOrPartialMigrate(
- Connection connection, final GroupMasterKey groupMasterKey
+ Connection connection,
+ final GroupMasterKey groupMasterKey
) throws SQLException {
final var groupSecretParams = GroupSecretParams.deriveFromMasterKey(groupMasterKey);
final var groupId = GroupUtils.getGroupIdV2(groupSecretParams);
return getGroupOrPartialMigrate(connection, groupMasterKey, groupId);
}
- public GroupInfoV2 getGroupOrPartialMigrate(
- final GroupMasterKey groupMasterKey, final GroupIdV2 groupId
- ) {
+ public GroupInfoV2 getGroupOrPartialMigrate(final GroupMasterKey groupMasterKey, final GroupIdV2 groupId) {
try (final var connection = database.getConnection()) {
return getGroupOrPartialMigrate(connection, groupMasterKey, groupId);
} catch (SQLException e) {
}
private GroupInfoV2 getGroupOrPartialMigrate(
- Connection connection, final GroupMasterKey groupMasterKey, final GroupIdV2 groupId
+ Connection connection,
+ final GroupMasterKey groupMasterKey,
+ final GroupIdV2 groupId
) throws SQLException {
switch (getGroup(connection, (GroupId) groupId)) {
case GroupInfoV1 groupInfoV1 -> {
}
public void mergeRecipients(
- final Connection connection, final RecipientId recipientId, final RecipientId toBeMergedRecipientId
+ final Connection connection,
+ final RecipientId recipientId,
+ final RecipientId toBeMergedRecipientId
) throws SQLException {
final var sql = (
"""
}
public void updateStorageIds(
- Connection connection, Map<GroupIdV1, StorageId> storageIdV1Map, Map<GroupIdV2, StorageId> storageIdV2Map
+ Connection connection,
+ Map<GroupIdV1, StorageId> storageIdV1Map,
+ Map<GroupIdV2, StorageId> storageIdV2Map
) throws SQLException {
final var sql = (
"""
}
}
- public void updateStorageId(
- Connection connection, GroupId groupId, StorageId storageId
- ) throws SQLException {
+ public void updateStorageId(Connection connection, GroupId groupId, StorageId storageId) throws SQLException {
final var sqlV1 = (
"""
UPDATE %s
}
private void insertOrReplaceGroup(
- final Connection connection, Long internalId, final GroupInfo group
+ final Connection connection,
+ Long internalId,
+ final GroupInfo group
) throws SQLException {
if (group instanceof GroupInfoV1 groupV1) {
if (internalId != null) {
@Override
public List<Member> deserialize(
- JsonParser jsonParser, DeserializationContext deserializationContext
+ JsonParser jsonParser,
+ DeserializationContext deserializationContext
) throws IOException {
var addresses = new ArrayList<Member>();
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
@Override
public List<Object> deserialize(
- JsonParser jsonParser, DeserializationContext deserializationContext
+ JsonParser jsonParser,
+ DeserializationContext deserializationContext
) throws IOException {
var groups = new ArrayList<>();
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
private final TrustLevel trustLevel;
private final long addedTimestamp;
- IdentityInfo(
- final String address, IdentityKey identityKey, TrustLevel trustLevel, long addedTimestamp
- ) {
+ IdentityInfo(final String address, IdentityKey identityKey, TrustLevel trustLevel, long addedTimestamp) {
this.address = address;
this.identityKey = identityKey;
this.trustLevel = trustLevel;
}
public IdentityKeyStore(
- final Database database, final TrustNewIdentity trustNewIdentity, RecipientStore recipientStore
+ final Database database,
+ final TrustNewIdentity trustNewIdentity,
+ RecipientStore recipientStore
) {
this.database = database;
this.trustNewIdentity = trustNewIdentity;
}
public boolean saveIdentity(
- final Connection connection, final ServiceId serviceId, final IdentityKey identityKey
+ final Connection connection,
+ final ServiceId serviceId,
+ final IdentityKey identityKey
) throws SQLException {
return saveIdentity(connection, serviceId.toString(), identityKey);
}
}
private boolean saveIdentity(
- final Connection connection, final String address, final IdentityKey identityKey
+ final Connection connection,
+ final String address,
+ final IdentityKey identityKey
) throws SQLException {
final var identityInfo = loadIdentity(connection, address);
if (identityInfo != null && identityInfo.getIdentityKey().equals(identityKey)) {
logger.debug("Complete identities migration took {}ms", (System.nanoTime() - start) / 1000000);
}
- private IdentityInfo loadIdentity(
- final Connection connection, final String address
- ) throws SQLException {
+ private IdentityInfo loadIdentity(final Connection connection, final String address) throws SQLException {
final var sql = (
"""
SELECT i.address, i.identity_key, i.added_timestamp, i.trust_level
static final Pattern identityFileNamePattern = Pattern.compile("(\\d+)");
private static List<IdentityInfo> getIdentities(
- final File identitiesPath, final RecipientResolver resolver, final RecipientAddressResolver addressResolver
+ final File identitiesPath,
+ final RecipientResolver resolver,
+ final RecipientAddressResolver addressResolver
) {
final var files = identitiesPath.listFiles();
if (files == null) {
}
private static IdentityInfo loadIdentityLocked(
- final RecipientId recipientId, RecipientAddressResolver addressResolver, final File identitiesPath
+ final RecipientId recipientId,
+ RecipientAddressResolver addressResolver,
+ final File identitiesPath
) {
final var file = getIdentityFile(recipientId, identitiesPath);
if (!file.exists()) {
}
public <T> boolean storeEntry(
- final Connection connection, final KeyValueEntry<T> key, final T value
+ final Connection connection,
+ final KeyValueEntry<T> key,
+ final T value
) throws SQLException {
final var entry = getEntry(key);
if (Objects.equals(entry, value)) {
@SuppressWarnings("unchecked")
private static <T> T readValueFromResultSet(
- final KeyValueEntry<T> key, final ResultSet resultSet
+ final KeyValueEntry<T> key,
+ final ResultSet resultSet
) throws SQLException {
Object value;
final var clazz = key.clazz();
}
private static <T> void setParameterValue(
- final PreparedStatement statement, final int parameterIndex, final Class<T> clazz, final T value
+ final PreparedStatement statement,
+ final int parameterIndex,
+ final Class<T> clazz,
+ final T value
) throws SQLException {
if (clazz == int.class || clazz == Integer.class) {
if (value == null) {
@Override
public List<LegacySignalProfileEntry> deserialize(
- JsonParser jsonParser, DeserializationContext deserializationContext
+ JsonParser jsonParser,
+ DeserializationContext deserializationContext
) throws IOException {
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
void storeProfileKey(RecipientId recipientId, ProfileKey profileKey);
void storeExpiringProfileKeyCredential(
- RecipientId recipientId, ExpiringProfileKeyCredential expiringProfileKeyCredential
+ RecipientId recipientId,
+ ExpiringProfileKeyCredential expiringProfileKeyCredential
);
}
private final int localRegistrationId;
private LegacyJsonIdentityKeyStore(
- final List<LegacyIdentityInfo> identities, IdentityKeyPair identityKeyPair, int localRegistrationId
+ final List<LegacyIdentityInfo> identities,
+ IdentityKeyPair identityKeyPair,
+ int localRegistrationId
) {
this.identities = identities;
this.identityKeyPair = identityKeyPair;
@Override
public LegacyJsonIdentityKeyStore deserialize(
- JsonParser jsonParser, DeserializationContext deserializationContext
+ JsonParser jsonParser,
+ DeserializationContext deserializationContext
) throws IOException {
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
@Override
public LegacyJsonPreKeyStore deserialize(
- JsonParser jsonParser, DeserializationContext deserializationContext
+ JsonParser jsonParser,
+ DeserializationContext deserializationContext
) throws IOException {
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
@Override
public LegacyJsonSessionStore deserialize(
- JsonParser jsonParser, DeserializationContext deserializationContext
+ JsonParser jsonParser,
+ DeserializationContext deserializationContext
) throws IOException {
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
@Override
public LegacyJsonSignedPreKeyStore deserialize(
- JsonParser jsonParser, DeserializationContext deserializationContext
+ JsonParser jsonParser,
+ DeserializationContext deserializationContext
) throws IOException {
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
@Override
public void storeSenderKey(
- final SignalProtocolAddress sender, final UUID distributionId, final SenderKeyRecord record
+ final SignalProtocolAddress sender,
+ final UUID distributionId,
+ final SenderKeyRecord record
) {
senderKeyStore.storeSenderKey(sender, distributionId, record);
}
@Override
public void markSenderKeySharedWith(
- final DistributionId distributionId, final Collection<SignalProtocolAddress> addresses
+ final DistributionId distributionId,
+ final Collection<SignalProtocolAddress> addresses
) {
senderKeyStore.markSenderKeySharedWith(distributionId, addresses);
}
}
}
- private static void removeNumbers(
- final Connection connection, final Set<String> numbers
- ) throws SQLException {
+ private static void removeNumbers(final Connection connection, final Set<String> numbers) throws SQLException {
final var sql = (
"""
DELETE FROM %s
}
private static void addNumbers(
- final Connection connection, final Set<String> numbers, final long lastSeen
+ final Connection connection,
+ final Set<String> numbers,
+ final long lastSeen
) throws SQLException {
final var sql = (
"""
}
private static void updateLastSeen(
- final Connection connection, final Set<String> numbers, final long lastSeen
+ final Connection connection,
+ final Set<String> numbers,
+ final long lastSeen
) throws SQLException {
final var sql = (
"""
@Override
public List<RecipientAddress> deserialize(
- JsonParser jsonParser, DeserializationContext deserializationContext
+ JsonParser jsonParser,
+ DeserializationContext deserializationContext
) throws IOException {
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
private static final Logger logger = LoggerFactory.getLogger(MergeRecipientHelper.class);
static Pair<RecipientId, List<RecipientId>> resolveRecipientTrustedLocked(
- Store store, RecipientAddress address
+ Store store,
+ RecipientAddress address
) throws SQLException {
// address has at least one of serviceId/pni and optionally number/username
}
public RecipientId resolveRecipientByNumber(
- final String number, Supplier<ServiceId> serviceIdSupplier
+ final String number,
+ Supplier<ServiceId> serviceIdSupplier
) throws UnregisteredRecipientException {
final Optional<RecipientWithAddress> byNumber;
try (final var connection = database.getConnection()) {
}
public RecipientId resolveRecipientByUsername(
- final String username, Supplier<ACI> aciSupplier
+ final String username,
+ Supplier<ACI> aciSupplier
) throws UnregisteredRecipientException {
final Optional<RecipientWithAddress> byUsername;
try (final var connection = database.getConnection()) {
@Override
public RecipientId resolveRecipientTrusted(
- final Optional<ACI> aci, final Optional<PNI> pni, final Optional<String> number
+ final Optional<ACI> aci,
+ final Optional<PNI> pni,
+ final Optional<String> number
) {
return resolveRecipientTrusted(new RecipientAddress(aci, pni, number, Optional.empty()));
}
}
public List<Recipient> getRecipients(
- boolean onlyContacts, Optional<Boolean> blocked, Set<RecipientId> recipientIds, Optional<String> name
+ boolean onlyContacts,
+ Optional<Boolean> blocked,
+ Set<RecipientId> recipientIds,
+ Optional<String> name
) {
final var sqlWhere = new ArrayList<String>();
if (onlyContacts) {
}
public void storeProfileKey(
- Connection connection, RecipientId recipientId, final ProfileKey profileKey
+ Connection connection,
+ RecipientId recipientId,
+ final ProfileKey profileKey
) throws SQLException {
storeProfileKey(connection, recipientId, profileKey, true);
}
@Override
public void storeExpiringProfileKeyCredential(
- RecipientId recipientId, final ExpiringProfileKeyCredential profileKeyCredential
+ RecipientId recipientId,
+ final ExpiringProfileKeyCredential profileKeyCredential
) {
try (final var connection = database.getConnection()) {
storeExpiringProfileKeyCredential(connection, recipientId, profileKeyCredential);
}
public void updateStorageId(
- Connection connection, RecipientId recipientId, StorageId storageId
+ Connection connection,
+ RecipientId recipientId,
+ StorageId storageId
) throws SQLException {
final var sql = (
"""
}
public void storeContact(
- final Connection connection, final RecipientId recipientId, final Contact contact
+ final Connection connection,
+ final RecipientId recipientId,
+ final Contact contact
) throws SQLException {
final var sql = (
"""
}
public int removeStorageIdsFromLocalOnlyUnregisteredRecipients(
- final Connection connection, final List<StorageId> storageIds
+ final Connection connection,
+ final List<StorageId> storageIds
) throws SQLException {
final var sql = (
"""
}
private void markUnregisteredAndSplitIfNecessary(
- final Connection connection, final RecipientId recipientId
+ final Connection connection,
+ final RecipientId recipientId
) throws SQLException {
markUnregistered(connection, recipientId);
final var address = resolveRecipientAddress(connection, recipientId);
}
private void markDiscoverable(
- final Connection connection, final RecipientId recipientId, final boolean discoverable
+ final Connection connection,
+ final RecipientId recipientId,
+ final boolean discoverable
) throws SQLException {
final var sql = (
"""
}
}
- private void markRegistered(
- final Connection connection, final RecipientId recipientId
- ) throws SQLException {
+ private void markRegistered(final Connection connection, final RecipientId recipientId) throws SQLException {
final var sql = (
"""
UPDATE %s
}
}
- private void markUnregistered(
- final Connection connection, final RecipientId recipientId
- ) throws SQLException {
+ private void markUnregistered(final Connection connection, final RecipientId recipientId) throws SQLException {
final var sql = (
"""
UPDATE %s
}
public void storeProfile(
- final Connection connection, final RecipientId recipientId, final Profile profile
+ final Connection connection,
+ final RecipientId recipientId,
+ final Profile profile
) throws SQLException {
final var sql = (
"""
}
private void storeProfileKey(
- Connection connection, RecipientId recipientId, final ProfileKey profileKey, boolean resetProfile
+ Connection connection,
+ RecipientId recipientId,
+ final ProfileKey profileKey,
+ boolean resetProfile
) throws SQLException {
if (profileKey != null) {
final var recipientProfileKey = getProfileKey(connection, recipientId);
}
private RecipientAddress resolveRecipientAddress(
- final Connection connection, final RecipientId recipientId
+ final Connection connection,
+ final RecipientId recipientId
) throws SQLException {
final var sql = (
"""
}
private Pair<RecipientId, List<RecipientId>> resolveRecipientTrustedLocked(
- final Connection connection, final RecipientAddress address, final boolean isSelf
+ final Connection connection,
+ final RecipientAddress address,
+ final boolean isSelf
) throws SQLException {
if (address.hasSingleIdentifier() || (
!isSelf && selfAddressProvider.getSelfAddress().matches(address)
}
private void mergeRecipients(
- final Connection connection, final RecipientId recipientId, final List<RecipientId> toBeMergedRecipientIds
+ final Connection connection,
+ final RecipientId recipientId,
+ final List<RecipientId> toBeMergedRecipientIds
) throws SQLException {
for (final var toBeMergedRecipientId : toBeMergedRecipientIds) {
recipientMergeHandler.mergeRecipients(connection, recipientId, toBeMergedRecipientId);
}
}
- private RecipientId resolveRecipientLocked(
- Connection connection, RecipientAddress address
- ) throws SQLException {
+ private RecipientId resolveRecipientLocked(Connection connection, RecipientAddress address) throws SQLException {
final var byAci = address.aci().isEmpty()
? Optional.<RecipientWithAddress>empty()
: findByServiceId(connection, address.aci().get());
}
private RecipientId addNewRecipient(
- final Connection connection, final RecipientAddress address
+ final Connection connection,
+ final RecipientAddress address
) throws SQLException {
final var sql = (
"""
}
private void updateRecipientAddress(
- Connection connection, RecipientId recipientId, final RecipientAddress address
+ Connection connection,
+ RecipientId recipientId,
+ final RecipientAddress address
) throws SQLException {
recipientAddressCache.entrySet().removeIf(e -> e.getValue().id().equals(recipientId));
final var sql = (
}
private void mergeRecipientsLocked(
- Connection connection, RecipientId recipientId, RecipientId toBeMergedRecipientId
+ Connection connection,
+ RecipientId recipientId,
+ RecipientId toBeMergedRecipientId
) throws SQLException {
final var contact = getContact(connection, recipientId);
if (contact == null) {
}
private Optional<RecipientWithAddress> findByNumber(
- final Connection connection, final String number
+ final Connection connection,
+ final String number
) throws SQLException {
final var sql = """
SELECT r._id, r.number, r.aci, r.pni, r.username
}
private Optional<RecipientWithAddress> findByUsername(
- final Connection connection, final String username
+ final Connection connection,
+ final String username
) throws SQLException {
final var sql = """
SELECT r._id, r.number, r.aci, r.pni, r.username
}
private Optional<RecipientWithAddress> findByServiceId(
- final Connection connection, final ServiceId serviceId
+ final Connection connection,
+ final ServiceId serviceId
) throws SQLException {
var recipientWithAddress = Optional.ofNullable(recipientAddressCache.get(serviceId));
if (recipientWithAddress.isPresent()) {
}
private Set<RecipientWithAddress> findAllByAddress(
- final Connection connection, final RecipientAddress address
+ final Connection connection,
+ final RecipientAddress address
) throws SQLException {
final var sql = """
SELECT r._id, r.number, r.aci, r.pni, r.username
}
private ExpiringProfileKeyCredential getExpiringProfileKeyCredential(
- final Connection connection, final RecipientId recipientId
+ final Connection connection,
+ final RecipientId recipientId
) throws SQLException {
final var sql = (
"""
public interface RecipientMergeHandler {
void mergeRecipients(
- final Connection connection, RecipientId recipientId, RecipientId toBeMergedRecipientId
+ final Connection connection,
+ RecipientId recipientId,
+ RecipientId toBeMergedRecipientId
) throws SQLException;
}
@Override
public void updateRecipientAddress(
- final RecipientId recipientId, final RecipientAddress address
+ final RecipientId recipientId,
+ final RecipientAddress address
) throws SQLException {
RecipientStore.this.updateRecipientAddress(connection, recipientId, address);
}
@Override
public RecipientId resolveRecipientTrusted(
- final Optional<ACI> aci, final Optional<PNI> pni, final Optional<String> number
+ final Optional<ACI> aci,
+ final Optional<PNI> pni,
+ final Optional<String> number
) {
return recipientTrustedResolverSupplier.get().resolveRecipientTrusted(aci, pni, number);
}
}
public List<MessageSendLogEntry> findMessages(
- final ServiceId serviceId, final int deviceId, final long timestamp, final boolean isSenderKey
+ final ServiceId serviceId,
+ final int deviceId,
+ final long timestamp,
+ final boolean isSenderKey
) {
final var sql = """
SELECT group_id, content, content_hint, urgent
}
public long insertIfPossible(
- long sentTimestamp, SendMessageResult sendMessageResult, ContentHint contentHint, boolean urgent
+ long sentTimestamp,
+ SendMessageResult sendMessageResult,
+ ContentHint contentHint,
+ boolean urgent
) {
if (sendLogDisabled) {
return -1;
}
public long insertIfPossible(
- long sentTimestamp, List<SendMessageResult> sendMessageResults, ContentHint contentHint, boolean urgent
+ long sentTimestamp,
+ List<SendMessageResult> sendMessageResults,
+ ContentHint contentHint,
+ boolean urgent
) {
if (sendLogDisabled) {
return -1;
}
public void addRecipientToExistingEntryIfPossible(
- final long contentId, final List<SendMessageResult> sendMessageResults
+ final long contentId,
+ final List<SendMessageResult> sendMessageResults
) {
if (sendLogDisabled) {
return;
}
private void insertRecipientsForExistingContent(
- final long contentId, final List<RecipientDevices> recipientDevices
+ final long contentId,
+ final List<RecipientDevices> recipientDevices
) {
try (final var connection = database.getConnection()) {
connection.setAutoCommit(false);
}
private void insertRecipientsForExistingContent(
- final long contentId, final List<RecipientDevices> recipientDevices, final Connection connection
+ final long contentId,
+ final List<RecipientDevices> recipientDevices,
+ final Connection connection
) throws SQLException {
final var sql = """
INSERT INTO %s (address, device_id, content_id)
@Override
public void storeSenderKey(
- final SignalProtocolAddress address, final UUID distributionId, final SenderKeyRecord record
+ final SignalProtocolAddress address,
+ final UUID distributionId,
+ final SenderKeyRecord record
) {
final var key = getKey(address, distributionId);
}
private void storeSenderKey(
- final Connection connection, final Key key, final SenderKeyRecord senderKeyRecord
+ final Connection connection,
+ final Key key,
+ final SenderKeyRecord senderKeyRecord
) throws SQLException {
final var sqlUpdate = """
UPDATE %s
}
public void markSenderKeySharedWith(
- final DistributionId distributionId, final Collection<SignalProtocolAddress> addresses
+ final DistributionId distributionId,
+ final Collection<SignalProtocolAddress> addresses
) {
final var newEntries = addresses.stream()
.map(a -> new SenderKeySharedEntry(a.getName(), a.getDeviceId()))
}
}
- public void deleteSharedWith(
- final ServiceId serviceId, final int deviceId, final DistributionId distributionId
- ) {
+ public void deleteSharedWith(final ServiceId serviceId, final int deviceId, final DistributionId distributionId) {
try (final var connection = database.getConnection()) {
final var sql = (
"""
}
private void markSenderKeysSharedWith(
- final Connection connection, final DistributionId distributionId, final Set<SenderKeySharedEntry> newEntries
+ final Connection connection,
+ final DistributionId distributionId,
+ final Set<SenderKeySharedEntry> newEntries
) throws SQLException {
final var sql = (
"""
@Override
public void storeSenderKey(
- final SignalProtocolAddress sender, final UUID distributionId, final SenderKeyRecord record
+ final SignalProtocolAddress sender,
+ final UUID distributionId,
+ final SenderKeyRecord record
) {
senderKeyRecordStore.storeSenderKey(sender, distributionId, record);
}
@Override
public void markSenderKeySharedWith(
- final DistributionId distributionId, final Collection<SignalProtocolAddress> addresses
+ final DistributionId distributionId,
+ final Collection<SignalProtocolAddress> addresses
) {
senderKeySharedStore.markSenderKeySharedWith(distributionId, addresses);
}
}
private void storeSession(
- final Connection connection, final Key key, final SessionRecord session
+ final Connection connection,
+ final Key key,
+ final SessionRecord session
) throws SQLException {
synchronized (cachedSessions) {
cachedSessions.put(key, session);
@Override
public void serialize(
- final Map<?, ?> value, final JsonGenerator jgen, final SerializerProvider provider
+ final Map<?, ?> value,
+ final JsonGenerator jgen,
+ final SerializerProvider provider
) throws IOException {
jgen.writeObject(value.values());
}
@Override
public Map<String, LegacyThreadInfo> deserialize(
- JsonParser jsonParser, DeserializationContext deserializationContext
+ JsonParser jsonParser,
+ DeserializationContext deserializationContext
) throws IOException {
var threads = new HashMap<String, LegacyThreadInfo>();
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
private final JobExecutor jobExecutor;
public AccountRecordProcessor(
- SignalAccount account, Connection connection, final JobExecutor jobExecutor
+ SignalAccount account,
+ Connection connection,
+ final JobExecutor jobExecutor
) throws SQLException {
this.account = account;
this.connection = connection;
}
@Override
- protected SignalContactRecord merge(
- SignalContactRecord remote, SignalContactRecord local
- ) {
+ protected SignalContactRecord merge(SignalContactRecord remote, SignalContactRecord local) {
String profileGivenName;
String profileFamilyName;
if (remote.getProfileGivenName().isPresent() || remote.getProfileFamilyName().isPresent()) {
}
public static SignalStorageRecord localToRemoteRecord(
- Recipient recipient, IdentityInfo identity, byte[] rawStorageId
+ Recipient recipient,
+ IdentityInfo identity,
+ byte[] rawStorageId
) {
final var address = recipient.getAddress();
final var builder = new SignalContactRecord.Builder(rawStorageId,
return SignalStorageRecord.forContact(builder.build());
}
- public static SignalStorageRecord localToRemoteRecord(
- GroupInfoV1 group, byte[] rawStorageId
- ) {
+ public static SignalStorageRecord localToRemoteRecord(GroupInfoV1 group, byte[] rawStorageId) {
final var builder = new SignalGroupV1Record.Builder(rawStorageId,
group.getGroupId().serialize(),
group.getStorageRecord());
return SignalStorageRecord.forGroupV1(builder.build());
}
- public static SignalStorageRecord localToRemoteRecord(
- GroupInfoV2 group, byte[] rawStorageId
- ) {
+ public static SignalStorageRecord localToRemoteRecord(GroupInfoV2 group, byte[] rawStorageId) {
final var builder = new SignalGroupV2Record.Builder(rawStorageId,
group.getMasterKey(),
group.getStorageRecord());
}
public static void validateForcePush(
- SignalStorageManifest manifest, List<SignalStorageRecord> inserts, RecipientAddress self
+ SignalStorageManifest manifest,
+ List<SignalStorageRecord> inserts,
+ RecipientAddress self
) {
validateManifestAndInserts(manifest, inserts, self);
}
private static void validateManifestAndInserts(
- SignalStorageManifest manifest, List<SignalStorageRecord> inserts, RecipientAddress self
+ SignalStorageManifest manifest,
+ List<SignalStorageRecord> inserts,
+ RecipientAddress self
) {
int accountCount = 0;
for (StorageId id : manifest.getStorageIds()) {
public class AttachmentUtils {
public static SignalServiceAttachmentStream createAttachmentStream(
- String attachment, ResumableUploadSpec resumableUploadSpec
+ String attachment,
+ ResumableUploadSpec resumableUploadSpec
) throws AttachmentInvalidException {
try {
final var streamDetails = Utils.createStreamDetails(attachment);
}
public static SignalServiceAttachmentStream createAttachmentStream(
- StreamDetails streamDetails, Optional<String> name, ResumableUploadSpec resumableUploadSpec
+ StreamDetails streamDetails,
+ Optional<String> name,
+ ResumableUploadSpec resumableUploadSpec
) throws ResumeLocationInvalidException {
// TODO maybe add a parameter to set the voiceNote, borderless, preview, width, height and caption option
final var uploadTimestamp = System.currentTimeMillis();
}
public static SignedPreKeyRecord generateSignedPreKeyRecord(
- final int signedPreKeyId, final ECPrivateKey privateKey
+ final int signedPreKeyId,
+ final ECPrivateKey privateKey
) {
var keyPair = Curve.generateKeyPair();
byte[] signature;
return new SignedPreKeyRecord(signedPreKeyId, System.currentTimeMillis(), keyPair, signature);
}
- public static List<KyberPreKeyRecord> generateKyberPreKeyRecords(
- final int offset, final ECPrivateKey privateKey
- ) {
+ public static List<KyberPreKeyRecord> generateKyberPreKeyRecords(final int offset, final ECPrivateKey privateKey) {
var records = new ArrayList<KyberPreKeyRecord>(PREKEY_BATCH_SIZE);
for (var i = 0; i < PREKEY_BATCH_SIZE; i++) {
var preKeyId = (offset + i) % PREKEY_MAXIMUM_ID;
}
public static void requestVerificationCode(
- RegistrationApi registrationApi, String sessionId, boolean voiceVerification
+ RegistrationApi registrationApi,
+ String sessionId,
+ boolean voiceVerification
) throws IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException {
final var locale = Utils.getDefaultLocale(Locale.US);
final var response = registrationApi.requestSmsVerificationCode(sessionId,
}
public static Pair<VerifyAccountResponse, MasterKey> verifyNumber(
- String sessionId, String verificationCode, String pin, PinHelper pinHelper, Verifier verifier
+ String sessionId,
+ String verificationCode,
+ String pin,
+ PinHelper pinHelper,
+ Verifier verifier
) throws IOException, PinLockedException, IncorrectPinException {
verificationCode = verificationCode.replace("-", "");
try {
}
private static RegistrationSessionMetadataResponse validateSession(
- final RegistrationApi registrationApi, final String sessionId
+ final RegistrationApi registrationApi,
+ final String sessionId
) throws IOException {
if (sessionId == null || sessionId.isEmpty()) {
throw new NoSuchSessionException();
}
private static RegistrationSessionMetadataResponse getValidSession(
- final RegistrationApi registrationApi, final String sessionId
+ final RegistrationApi registrationApi,
+ final String sessionId
) throws IOException {
try {
return validateSession(registrationApi, sessionId);
}
private static RegistrationSessionMetadataResponse submitCaptcha(
- RegistrationApi registrationApi, String sessionId, String captcha
+ RegistrationApi registrationApi,
+ String sessionId,
+ String captcha
) throws IOException, CaptchaRequiredException {
captcha = captcha == null ? null : captcha.replace("signalcaptcha://", "");
try {
public interface Verifier {
VerifyAccountResponse verify(
- String sessionId, String verificationCode, String registrationLock
+ String sessionId,
+ String verificationCode,
+ String registrationLock
) throws IOException;
}
}
/**
* Signs the supplied address bytes with the {@link IdentityKeyPair}'s private key and returns a proto that includes it, and it's signature.
*/
- public static PaymentAddress signPaymentsAddress(
- byte[] publicAddressBytes, ECPrivateKey privateKey
- ) {
+ public static PaymentAddress signPaymentsAddress(byte[] publicAddressBytes, ECPrivateKey privateKey) {
byte[] signature = privateKey.calculateSignature(publicAddressBytes);
return new PaymentAddress.Builder().mobileCoinAddress(new PaymentAddress.MobileCoinAddress.Builder().address(
* <p>
* Returns the validated bytes if so, otherwise returns null.
*/
- public static byte[] verifyPaymentsAddress(
- PaymentAddress paymentAddress, ECPublicKey publicKey
- ) {
+ public static byte[] verifyPaymentsAddress(PaymentAddress paymentAddress, ECPublicKey publicKey) {
final var mobileCoinAddress = paymentAddress.mobileCoinAddress;
if (mobileCoinAddress == null || mobileCoinAddress.address == null || mobileCoinAddress.signature == null) {
logger.debug("Got payment address without mobile coin address, ignoring.");
private static final Logger logger = LoggerFactory.getLogger(ProfileUtils.class);
- public static Profile decryptProfile(
- final ProfileKey profileKey, final SignalServiceProfile encryptedProfile
- ) {
+ public static Profile decryptProfile(final ProfileKey profileKey, final SignalServiceProfile encryptedProfile) {
var profileCipher = new ProfileCipher(profileKey);
IdentityKey identityKey = null;
try {
}
public static Profile.UnidentifiedAccessMode getUnidentifiedAccessMode(
- final SignalServiceProfile encryptedProfile, final ProfileCipher profileCipher
+ final SignalServiceProfile encryptedProfile,
+ final ProfileCipher profileCipher
) {
if (encryptedProfile.isUnrestrictedUnidentifiedAccess()) {
return Profile.UnidentifiedAccessMode.UNRESTRICTED;
}
private static String decryptString(
- final String encrypted, final ProfileCipher profileCipher
+ final String encrypted,
+ final ProfileCipher profileCipher
) throws InvalidCiphertextException {
try {
return encrypted == null ? null : profileCipher.decryptString(Base64.getDecoder().decode(encrypted));
}
private static Optional<Boolean> decryptBoolean(
- final String encrypted, final ProfileCipher profileCipher
+ final String encrypted,
+ final ProfileCipher profileCipher
) throws InvalidCiphertextException {
try {
return encrypted == null
}
private static byte[] decryptAndVerifyMobileCoinAddress(
- final byte[] encryptedPaymentAddress, final ProfileCipher profileCipher, final ECPublicKey publicKey
+ final byte[] encryptedPaymentAddress,
+ final ProfileCipher profileCipher,
+ final ECPublicKey publicKey
) throws InvalidCiphertextException {
byte[] decrypted;
try {
}
private static Pair<InputStream, Long> getInputStreamAndLength(
- final String rootPath, final ZipFile zip, final String subfile
+ final String rootPath,
+ final ZipFile zip,
+ final String subfile
) throws IOException {
if (zip != null) {
final var entry = zip.getEntry(subfile);
}
private static String getContentType(
- final String rootPath, final ZipFile zip, final String subfile
+ final String rootPath,
+ final ZipFile zip,
+ final String subfile
) throws IOException {
if (zip != null) {
final var entry = zip.getEntry(subfile);
}
public static Fingerprint computeSafetyNumberForNumber(
- String ownNumber, IdentityKey ownIdentityKey, String theirNumber, IdentityKey theirIdentityKey
+ String ownNumber,
+ IdentityKey ownIdentityKey,
+ String theirNumber,
+ IdentityKey theirIdentityKey
) {
// Version 1: E164 user
final var version = 1;
}
public static Fingerprint computeSafetyNumberForUuid(
- ServiceId ownServiceId, IdentityKey ownIdentityKey, ServiceId theirServiceId, IdentityKey theirIdentityKey
+ ServiceId ownServiceId,
+ IdentityKey ownIdentityKey,
+ ServiceId theirServiceId,
+ IdentityKey theirIdentityKey
) {
// Version 2: UUID user
final var version = 2;
}
@Override
- public void updateRecipientAddress(
- final RecipientId recipientId, final RecipientAddress address
- ) {
+ public void updateRecipientAddress(final RecipientId recipientId, final RecipientAddress address) {
recipients.removeIf(r -> r.id().equals(recipientId));
recipients.add(new RecipientWithAddress(recipientId, address));
}
void unsubscribeReceive();
long sendMessage(
- String message, List<String> attachments, String recipient
+ String message,
+ List<String> attachments,
+ String recipient
) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber, Error.UntrustedIdentity;
long sendMessage(
- String message, List<String> attachments, List<String> recipients
+ String message,
+ List<String> attachments,
+ List<String> recipients
) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber, Error.UntrustedIdentity;
- void sendTyping(
- String recipient, boolean stop
- ) throws Error.Failure, Error.UntrustedIdentity;
+ void sendTyping(String recipient, boolean stop) throws Error.Failure, Error.UntrustedIdentity;
- void sendReadReceipt(
- String recipient, List<Long> messageIds
- ) throws Error.Failure, Error.UntrustedIdentity;
+ void sendReadReceipt(String recipient, List<Long> messageIds) throws Error.Failure, Error.UntrustedIdentity;
- void sendViewedReceipt(
- String recipient, List<Long> messageIds
- ) throws Error.Failure, Error.UntrustedIdentity;
+ void sendViewedReceipt(String recipient, List<Long> messageIds) throws Error.Failure, Error.UntrustedIdentity;
- long sendRemoteDeleteMessage(
- long targetSentTimestamp, String recipient
- ) throws Error.Failure, Error.InvalidNumber;
+ long sendRemoteDeleteMessage(long targetSentTimestamp, String recipient) throws Error.Failure, Error.InvalidNumber;
long sendRemoteDeleteMessage(
- long targetSentTimestamp, List<String> recipients
+ long targetSentTimestamp,
+ List<String> recipients
) throws Error.Failure, Error.InvalidNumber;
long sendMessageReaction(
- String emoji, boolean remove, String targetAuthor, long targetSentTimestamp, String recipient
+ String emoji,
+ boolean remove,
+ String targetAuthor,
+ long targetSentTimestamp,
+ String recipient
) throws Error.InvalidNumber, Error.Failure;
long sendMessageReaction(
- String emoji, boolean remove, String targetAuthor, long targetSentTimestamp, List<String> recipients
+ String emoji,
+ boolean remove,
+ String targetAuthor,
+ long targetSentTimestamp,
+ List<String> recipients
) throws Error.InvalidNumber, Error.Failure;
long sendPaymentNotification(byte[] receipt, String note, String recipient) throws Error.Failure;
void sendSyncRequest() throws Error.Failure;
- long sendNoteToSelfMessage(
- String message, List<String> attachments
- ) throws Error.AttachmentInvalid, Error.Failure;
+ long sendNoteToSelfMessage(String message, List<String> attachments) throws Error.AttachmentInvalid, Error.Failure;
void sendEndSessionMessage(List<String> recipients) throws Error.Failure, Error.InvalidNumber, Error.UntrustedIdentity;
void deleteContact(final String recipient) throws Error.Failure;
long sendGroupMessage(
- String message, List<String> attachments, byte[] groupId
+ String message,
+ List<String> attachments,
+ byte[] groupId
) throws Error.GroupNotFound, Error.Failure, Error.AttachmentInvalid, Error.InvalidGroupId;
void sendGroupTyping(
- final byte[] groupId, final boolean stop
+ final byte[] groupId,
+ final boolean stop
) throws Error.Failure, Error.GroupNotFound, Error.UntrustedIdentity;
long sendGroupRemoteDeleteMessage(
- long targetSentTimestamp, byte[] groupId
+ long targetSentTimestamp,
+ byte[] groupId
) throws Error.Failure, Error.GroupNotFound, Error.InvalidGroupId;
long sendGroupMessageReaction(
- String emoji, boolean remove, String targetAuthor, long targetSentTimestamp, byte[] groupId
+ String emoji,
+ boolean remove,
+ String targetAuthor,
+ long targetSentTimestamp,
+ byte[] groupId
) throws Error.GroupNotFound, Error.Failure, Error.InvalidNumber, Error.InvalidGroupId;
String getContactName(String number) throws Error.InvalidNumber;
List<String> getGroupMembers(byte[] groupId) throws Error.InvalidGroupId;
byte[] createGroup(
- String name, List<String> members, String avatar
+ String name,
+ List<String> members,
+ String avatar
) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber;
@Deprecated
byte[] updateGroup(
- byte[] groupId, String name, List<String> members, String avatar
+ byte[] groupId,
+ String name,
+ List<String> members,
+ String avatar
) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber, Error.GroupNotFound, Error.InvalidGroupId;
@Deprecated
) throws Error.Failure;
void updateProfile(
- String name, String about, String aboutEmoji, String avatarPath, boolean removeAvatar
+ String name,
+ String about,
+ String aboutEmoji,
+ String avatarPath,
+ boolean removeAvatar
) throws Error.Failure;
void removePin();
public interface SignalControl extends DBusInterface {
void register(
- String number, boolean voiceVerification
+ String number,
+ boolean voiceVerification
) throws Error.Failure, Error.InvalidNumber, Error.RequiresCaptcha;
void registerWithCaptcha(
- String number, boolean voiceVerification, String captcha
+ String number,
+ boolean voiceVerification,
+ String captcha
) throws Error.Failure, Error.InvalidNumber, Error.RequiresCaptcha;
void verify(String number, String verificationCode) throws Error.Failure, Error.InvalidNumber;
}
private RegistrationManager loadRegistrationManager(
- final String account, final SignalAccountFiles signalAccountFiles
+ final String account,
+ final SignalAccountFiles signalAccountFiles
) throws UnexpectedErrorException {
try {
return signalAccountFiles.initRegistrationManager(account);
}
private Manager loadManager(
- final String account, final SignalAccountFiles signalAccountFiles
+ final String account,
+ final SignalAccountFiles signalAccountFiles
) throws CommandException {
logger.trace("Loading account file for {}", account);
try {
writer.println();
}
- private void printDataMessage(
- PlainTextWriter writer, MessageEnvelope.Data message
- ) {
+ private void printDataMessage(PlainTextWriter writer, MessageEnvelope.Data message) {
writer.println("Message timestamp: {}", DateUtils.formatTimestamp(message.timestamp()));
if (message.isViewOnce()) {
writer.println("=VIEW ONCE=");
}
}
- private void printEditMessage(
- PlainTextWriter writer, MessageEnvelope.Edit message
- ) {
+ private void printEditMessage(PlainTextWriter writer, MessageEnvelope.Edit message) {
writer.println("Edit: Target message timestamp: {}", DateUtils.formatTimestamp(message.targetSentTimestamp()));
printDataMessage(writer.indentedWriter(), message.dataMessage());
}
- private void printStoryMessage(
- PlainTextWriter writer, MessageEnvelope.Story message
- ) {
+ private void printStoryMessage(PlainTextWriter writer, MessageEnvelope.Story message) {
writer.println("Story: with replies: {}", message.allowsReplies());
if (message.groupId().isPresent()) {
writer.println("Group info:");
}
}
- private void printTypingMessage(
- final PlainTextWriter writer, final MessageEnvelope.Typing typingMessage
- ) {
+ private void printTypingMessage(final PlainTextWriter writer, final MessageEnvelope.Typing typingMessage) {
writer.println("Action: {}", typingMessage.type());
writer.println("Timestamp: {}", DateUtils.formatTimestamp(typingMessage.timestamp()));
if (typingMessage.groupId().isPresent()) {
}
}
- private void printReceiptMessage(
- final PlainTextWriter writer, final MessageEnvelope.Receipt receiptMessage
- ) {
+ private void printReceiptMessage(final PlainTextWriter writer, final MessageEnvelope.Receipt receiptMessage) {
writer.println("When: {}", DateUtils.formatTimestamp(receiptMessage.when()));
if (receiptMessage.type() == MessageEnvelope.Receipt.Type.DELIVERY) {
writer.println("Is delivery receipt");
}
}
- private void printCallMessage(
- final PlainTextWriter writer, final MessageEnvelope.Call callMessage
- ) {
+ private void printCallMessage(final PlainTextWriter writer, final MessageEnvelope.Call callMessage) {
if (callMessage.destinationDeviceId().isPresent()) {
final var deviceId = callMessage.destinationDeviceId().get();
writer.println("Destination device id: {}", deviceId);
}
}
- private void printSyncMessage(
- final PlainTextWriter writer, final MessageEnvelope.Sync syncMessage
- ) {
+ private void printSyncMessage(final PlainTextWriter writer, final MessageEnvelope.Sync syncMessage) {
if (syncMessage.contacts().isPresent()) {
final var contactsMessage = syncMessage.contacts().get();
var type = contactsMessage.isComplete() ? "complete" : "partial";
}
}
- private void printPreview(
- final PlainTextWriter writer, final MessageEnvelope.Data.Preview preview
- ) {
+ private void printPreview(final PlainTextWriter writer, final MessageEnvelope.Data.Preview preview) {
writer.println("Title: {}", preview.title());
writer.println("Description: {}", preview.description());
writer.println("Date: {}", DateUtils.formatTimestamp(preview.date()));
}
}
- private void printSticker(
- final PlainTextWriter writer, final MessageEnvelope.Data.Sticker sticker
- ) {
+ private void printSticker(final PlainTextWriter writer, final MessageEnvelope.Data.Sticker sticker) {
writer.println("Pack id: {}", Hex.toStringCondensed(sticker.packId().serialize()));
writer.println("Sticker id: {}", sticker.stickerId());
}
- private void printReaction(
- final PlainTextWriter writer, final MessageEnvelope.Data.Reaction reaction
- ) {
+ private void printReaction(final PlainTextWriter writer, final MessageEnvelope.Data.Reaction reaction) {
writer.println("Emoji: {}", reaction.emoji());
writer.println("Target author: {}", formatContact(reaction.targetAuthor()));
writer.println("Target timestamp: {}", DateUtils.formatTimestamp(reaction.targetSentTimestamp()));
writer.println("Is remove: {}", reaction.isRemove());
}
- private void printQuote(
- final PlainTextWriter writer, final MessageEnvelope.Data.Quote quote
- ) {
+ private void printQuote(final PlainTextWriter writer, final MessageEnvelope.Data.Quote quote) {
writer.println("Id: {}", quote.id());
writer.println("Author: {}", formatContact(quote.author()));
if (quote.text().isPresent()) {
}
}
- private void printGroupContext(
- final PlainTextWriter writer, final MessageEnvelope.Data.GroupContext groupContext
- ) {
+ private void printGroupContext(final PlainTextWriter writer, final MessageEnvelope.Data.GroupContext groupContext) {
printGroupInfo(writer, groupContext.groupId());
writer.println("Revision: {}", groupContext.revision());
writer.println("Type: {}", groupContext.isGroupUpdate() ? "UPDATE" : "DELIVER");
}
- private void printStoryContext(
- final PlainTextWriter writer, final MessageEnvelope.Data.StoryContext storyContext
- ) {
+ private void printStoryContext(final PlainTextWriter writer, final MessageEnvelope.Data.StoryContext storyContext) {
writer.println("Sender: {}", formatContact(storyContext.author()));
writer.println("Sent timestamp: {}", storyContext.sentTimestamp());
}
}
}
- private void printMention(
- PlainTextWriter writer, MessageEnvelope.Data.Mention mention
- ) {
+ private void printMention(PlainTextWriter writer, MessageEnvelope.Data.Mention mention) {
writer.println("- {}: {} (length: {})", formatContact(mention.recipient()), mention.start(), mention.length());
}
- private void printTextStyle(
- PlainTextWriter writer, TextStyle textStyle
- ) {
+ private void printTextStyle(PlainTextWriter writer, TextStyle textStyle) {
writer.println("- {}: {} (length: {})", textStyle.style().name(), textStyle.start(), textStyle.length());
}
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
final URI linkUri;
try {
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
final var uris = ns.<String>getList("uri");
for (final var uri : uris) {
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
final var contacts = ns.<String>getList("recipient");
final var recipients = CommandUtil.getSingleRecipientIdentifiers(contacts, m.getSelfNumber());
}
public void handleProvisioningCommand(
- final ProvisioningCommand command, final ProvisioningManager provisioningManager
+ final ProvisioningCommand command,
+ final ProvisioningManager provisioningManager
) throws CommandException {
command.handleCommand(ns, provisioningManager, outputWriter);
}
public void handleRegistrationCommand(
- final RegistrationCommand command, final RegistrationManager registrationManager
+ final RegistrationCommand command,
+ final RegistrationManager registrationManager
) throws CommandException {
command.handleCommand(ns, registrationManager);
}
}
public void handleMultiLocalCommand(
- final MultiLocalCommand command, MultiAccountManager multiAccountManager
+ final MultiLocalCommand command,
+ MultiAccountManager multiAccountManager
) throws CommandException {
command.handleCommand(ns, multiAccountManager, outputWriter);
}
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
Shutdown.installHandler();
logger.info("Starting daemon in single-account mode for " + m.getSelfNumber());
@Override
public void handleCommand(
- final Namespace ns, final MultiAccountManager c, final OutputWriter outputWriter
+ final Namespace ns,
+ final MultiAccountManager c,
+ final OutputWriter outputWriter
) throws CommandException {
Shutdown.installHandler();
logger.info("Starting daemon in multi-account mode");
@Override
public void handleCommand(
- Map<String, Object> request, RegistrationManager m, JsonWriter jsonWriter
+ Map<String, Object> request,
+ RegistrationManager m,
+ JsonWriter jsonWriter
) throws CommandException {
Namespace commandNamespace = new JsonRpcNamespace(request == null ? Map.of() : request);
handleCommand(commandNamespace, m);
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
final var newNumber = ns.getString("number");
final var verificationCode = ns.getString("verification-code");
@Override
public void handleCommand(
- final FinishLinkParams request, final MultiAccountManager m, final JsonWriter jsonWriter
+ final FinishLinkParams request,
+ final MultiAccountManager m,
+ final JsonWriter jsonWriter
) throws CommandException {
if (request.deviceLinkUri() == null) {
throw new UserErrorException("Missing deviceLinkUri.");
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
final var id = ns.getString("id");
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
final var contactRecipient = ns.getString("contact");
final var profileRecipient = ns.getString("profile");
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
final var packId = StickerPackId.deserialize(Hex.toByteArray(ns.getString("pack-id")));
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
// Get a map of registration statuses
Map<String, UserStatus> registered;
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
final GroupInviteLinkUrl linkUrl;
var uri = ns.getString("uri");
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
Shutdown.installHandler();
final var receiveMode = ns.<ReceiveMode>get("receive-mode");
@Override
public void handleCommand(
- final Namespace ns, final MultiAccountManager c, final OutputWriter outputWriter
+ final Namespace ns,
+ final MultiAccountManager c,
+ final OutputWriter outputWriter
) throws CommandException {
Shutdown.installHandler();
final var receiveMode = ns.<ReceiveMode>get("receive-mode");
return new TypeReference<>() {};
}
- default void handleCommand(
- Map<String, Object> request, Manager m, JsonWriter jsonWriter
- ) throws CommandException {
+ default void handleCommand(Map<String, Object> request, Manager m, JsonWriter jsonWriter) throws CommandException {
Namespace commandNamespace = new JsonRpcNamespace(request == null ? Map.of() : request);
handleCommand(commandNamespace, m, jsonWriter);
}
}
default void handleCommand(
- Map<String, Object> request, MultiAccountManager c, JsonWriter jsonWriter
+ Map<String, Object> request,
+ MultiAccountManager c,
+ JsonWriter jsonWriter
) throws CommandException {
Namespace commandNamespace = new JsonRpcNamespace(request == null ? Map.of() : request);
handleCommand(commandNamespace, c, jsonWriter);
@Override
public void handleCommand(
- final Namespace ns, final ProvisioningManager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final ProvisioningManager m,
+ final OutputWriter outputWriter
) throws CommandException {
final var writer = (PlainTextWriter) outputWriter;
@Override
public void handleCommand(
- final Namespace ns, final MultiAccountManager c, final OutputWriter outputWriter
+ final Namespace ns,
+ final MultiAccountManager c,
+ final OutputWriter outputWriter
) throws CommandException {
final var accountNumbers = c.getAccountNumbers();
switch (outputWriter) {
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
final var allRecipients = Boolean.TRUE.equals(ns.getBoolean("all-recipients"));
final var blocked = ns.getBoolean("blocked");
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
List<Device> devices;
try {
.collect(Collectors.toSet());
}
- private static void printGroupPlainText(
- PlainTextWriter writer, Group group, boolean detailed
- ) {
+ private static void printGroupPlainText(PlainTextWriter writer, Group group, boolean detailed) {
if (detailed) {
final var groupInviteLink = group.groupInviteLinkUrl();
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
var groups = m.getGroups();
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
var number = ns.getString("number");
@Override
public void handleCommand(
- final Namespace ns, final Manager c, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager c,
+ final OutputWriter outputWriter
) throws CommandException {
final var stickerPacks = c.getStickerPacks();
switch (outputWriter) {
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
final var groupId = CommandUtil.getGroupId(ns.getString("group-id"));
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
Shutdown.installHandler();
final var timeout = ns.getDouble("timeout");
@Override
public void handleCommand(
- final ReceiveParams request, final Manager m, final JsonWriter jsonWriter
+ final ReceiveParams request,
+ final Manager m,
+ final JsonWriter jsonWriter
) throws CommandException {
final var timeout = request.timeout() == null ? 3.0 : request.timeout();
final var maxMessagesRaw = request.maxMessages() == null ? -1 : request.maxMessages();
@Override
public void handleCommand(
- final RegistrationParams request, final RegistrationManager m, final JsonWriter jsonWriter
+ final RegistrationParams request,
+ final RegistrationManager m,
+ final JsonWriter jsonWriter
) throws CommandException {
register(m, Boolean.TRUE.equals(request.voice()), request.captcha(), Boolean.TRUE.equals(request.reregister()));
}
private void register(
- final RegistrationManager m, final boolean voiceVerification, final String captcha, final boolean reregister
+ final RegistrationManager m,
+ final boolean voiceVerification,
+ final String captcha,
+ final boolean reregister
) throws CommandException {
try {
m.register(voiceVerification, captcha, reregister);
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
final var isNoteToSelf = Boolean.TRUE.equals(ns.getBoolean("note-to-self"));
final var recipientStrings = ns.<String>getList("recipient");
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
var recipientString = ns.getString("recipient");
var recipient = CommandUtil.getSingleRecipientIdentifier(recipientString, m.getSelfNumber());
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
try {
final var deviceId = ns.getInt("device-id");
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
try {
m.setRegistrationLockPin(Optional.empty());
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
final var notifySelf = Boolean.TRUE.equals(ns.getBoolean("notify-self"));
final var isNoteToSelf = Boolean.TRUE.equals(ns.getBoolean("note-to-self"));
}
private List<Message.Mention> parseMentions(
- final String selfNumber, final List<String> mentionStrings
+ final String selfNumber,
+ final List<String> mentionStrings
) throws UserErrorException {
final var mentionPattern = Pattern.compile("(\\d+):(\\d+):(.+)");
final var mentions = new ArrayList<Message.Mention>();
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
try {
m.sendContacts();
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
final var recipientStrings = ns.<String>getList("recipient");
final var groupIdStrings = ns.<String>getList("group-id");
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
final var recipientString = ns.getString("recipient");
final var recipientIdentifier = CommandUtil.getSingleRecipientIdentifier(recipientString, m.getSelfNumber());
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
final var isNoteToSelf = Boolean.TRUE.equals(ns.getBoolean("note-to-self"));
final var recipientStrings = ns.<String>getList("recipient");
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
final var recipientString = ns.getString("recipient");
final var recipient = CommandUtil.getSingleRecipientIdentifier(recipientString, m.getSelfNumber());
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
try {
m.requestAllSyncData();
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
final var recipientStrings = ns.<String>getList("recipient");
final var groupIdStrings = ns.<String>getList("group-id");
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
try {
var registrationLockPin = ns.getString("pin");
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
final var newNumber = ns.getString("number");
final var voiceVerification = Boolean.TRUE.equals(ns.getBoolean("voice"));
@Override
public void handleCommand(
- final Void request, final MultiAccountManager m, final JsonWriter jsonWriter
+ final Void request,
+ final MultiAccountManager m,
+ final JsonWriter jsonWriter
) throws CommandException {
final URI deviceLinkUri;
try {
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
var recipientString = ns.getString("recipient");
var recipient = CommandUtil.getSingleRecipientIdentifier(recipientString, m.getSelfNumber());
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
final var contacts = ns.<String>getList("recipient");
final var recipients = CommandUtil.getSingleRecipientIdentifiers(contacts, m.getSelfNumber());
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
try {
if (Boolean.TRUE.equals(ns.getBoolean("delete-account"))) {
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
final var deviceName = ns.getString("device-name");
final var unrestrictedUnidentifiedSender = ns.getBoolean("unrestricted-unidentified-sender");
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
final var readReceipts = ns.getBoolean("read-receipts");
final var unidentifiedDeliveryIndicators = ns.getBoolean("unidentified-delivery-indicators");
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
var recipientString = ns.getString("recipient");
var recipient = CommandUtil.getSingleRecipientIdentifier(recipientString, m.getSelfNumber());
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
final var groupIdString = ns.getString("group-id");
var groupId = CommandUtil.getGroupId(groupIdString);
}
private void outputResult(
- final OutputWriter outputWriter, final SendGroupMessageResults results, final GroupId groupId
+ final OutputWriter outputWriter,
+ final SendGroupMessageResults results,
+ final GroupId groupId
) {
switch (outputWriter) {
case PlainTextWriter writer -> {
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
var givenName = ns.getString("given-name");
var familyName = ns.getString("family-name");
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
var path = new File(ns.getString("path"));
@Override
public void handleCommand(
- final VerifyParams request, final RegistrationManager m, final JsonWriter jsonWriter
+ final VerifyParams request,
+ final RegistrationManager m,
+ final JsonWriter jsonWriter
) throws CommandException {
verify(m, request.verificationCode(), request.pin());
}
private void verify(
- final RegistrationManager m, final String verificationCode, final String pin
+ final RegistrationManager m,
+ final String verificationCode,
+ final String pin
) throws UserErrorException, IOErrorException {
try {
m.verifyAccount(verificationCode, pin);
@Override
public void handleCommand(
- final Namespace ns, final Manager m, final OutputWriter outputWriter
+ final Namespace ns,
+ final Manager m,
+ final OutputWriter outputWriter
) throws CommandException {
outputVersion(outputWriter);
}
@Override
public void handleCommand(
- final Namespace ns, final MultiAccountManager c, final OutputWriter outputWriter
+ final Namespace ns,
+ final MultiAccountManager c,
+ final OutputWriter outputWriter
) throws CommandException {
outputVersion(outputWriter);
}
}
private static String tryGetSingleAccountObjectPath(
- final DBusConnection dBusConn, final String busname
+ final DBusConnection dBusConn,
+ final String busname
) throws DBusException, CommandException {
var control = dBusConn.getRemoteObject(busname, DbusConfig.getObjectPath(), SignalControl.class);
try {
private final boolean noReceiveOnStart;
public DbusHandler(
- final boolean isDbusSystem, final String busname, final Manager m, final boolean noReceiveOnStart
+ final boolean isDbusSystem,
+ final String busname,
+ final Manager m,
+ final boolean noReceiveOnStart
) {
this.isDbusSystem = isDbusSystem;
this.dbusRunner = (connection) -> {
private final String interfaceName;
private final List<DbusProperty<?>> properties;
- public DbusInterfacePropertiesHandler(
- final String interfaceName, final List<DbusProperty<?>> properties
- ) {
+ public DbusInterfacePropertiesHandler(final String interfaceName, final List<DbusProperty<?>> properties) {
this.interfaceName = interfaceName;
this.properties = properties;
}
@Override
public void startChangeNumber(
- final String newNumber, final boolean voiceVerification, final String captcha
+ final String newNumber,
+ final boolean voiceVerification,
+ final String captcha
) throws RateLimitException, IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException {
throw new UnsupportedOperationException();
}
@Override
public void finishChangeNumber(
- final String newNumber, final String verificationCode, final String pin
+ final String newNumber,
+ final String verificationCode,
+ final String pin
) throws IncorrectPinException, PinLockedException, IOException {
throw new UnsupportedOperationException();
}
@Override
public SendGroupMessageResults quitGroup(
- final GroupId groupId, final Set<RecipientIdentifier.Single> groupAdmins
+ final GroupId groupId,
+ final Set<RecipientIdentifier.Single> groupAdmins
) throws GroupNotFoundException, IOException, NotAGroupMemberException, LastGroupAdminException {
if (!groupAdmins.isEmpty()) {
throw new UnsupportedOperationException();
@Override
public Pair<GroupId, SendGroupMessageResults> createGroup(
- final String name, final Set<RecipientIdentifier.Single> members, final String avatarFile
+ final String name,
+ final Set<RecipientIdentifier.Single> members,
+ final String avatarFile
) throws IOException, AttachmentInvalidException {
final var newGroupId = signal.createGroup(emptyIfNull(name),
members.stream().map(RecipientIdentifier.Single::getIdentifier).toList(),
@Override
public SendGroupMessageResults updateGroup(
- final GroupId groupId, final UpdateGroup updateGroup
+ final GroupId groupId,
+ final UpdateGroup updateGroup
) throws IOException, GroupNotFoundException, AttachmentInvalidException, NotAGroupMemberException, GroupSendingNotAllowedException {
final var group = getRemoteObject(signal.getGroup(groupId.serialize()), Signal.Group.class);
if (updateGroup.getName() != null) {
@Override
public SendMessageResults sendTypingMessage(
- final TypingAction action, final Set<RecipientIdentifier> recipients
+ final TypingAction action,
+ final Set<RecipientIdentifier> recipients
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException {
return handleMessage(recipients, numbers -> {
numbers.forEach(n -> signal.sendTyping(n, action == TypingAction.STOP));
}
@Override
- public SendMessageResults sendReadReceipt(
- final RecipientIdentifier.Single sender, final List<Long> messageIds
- ) {
+ public SendMessageResults sendReadReceipt(final RecipientIdentifier.Single sender, final List<Long> messageIds) {
signal.sendReadReceipt(sender.getIdentifier(), messageIds);
return new SendMessageResults(0, Map.of());
}
@Override
- public SendMessageResults sendViewedReceipt(
- final RecipientIdentifier.Single sender, final List<Long> messageIds
- ) {
+ public SendMessageResults sendViewedReceipt(final RecipientIdentifier.Single sender, final List<Long> messageIds) {
signal.sendViewedReceipt(sender.getIdentifier(), messageIds);
return new SendMessageResults(0, Map.of());
}
@Override
public SendMessageResults sendMessage(
- final Message message, final Set<RecipientIdentifier> recipients, final boolean notifySelf
+ final Message message,
+ final Set<RecipientIdentifier> recipients,
+ final boolean notifySelf
) throws IOException, AttachmentInvalidException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException {
return handleMessage(recipients,
numbers -> signal.sendMessage(message.messageText(), message.attachments(), numbers),
@Override
public SendMessageResults sendEditMessage(
- final Message message, final Set<RecipientIdentifier> recipients, final long editTargetTimestamp
+ final Message message,
+ final Set<RecipientIdentifier> recipients,
+ final long editTargetTimestamp
) throws IOException, AttachmentInvalidException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException, UnregisteredRecipientException, InvalidStickerException {
throw new UnsupportedOperationException();
}
@Override
public SendMessageResults sendRemoteDeleteMessage(
- final long targetSentTimestamp, final Set<RecipientIdentifier> recipients
+ final long targetSentTimestamp,
+ final Set<RecipientIdentifier> recipients
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException {
return handleMessage(recipients,
numbers -> signal.sendRemoteDeleteMessage(targetSentTimestamp, numbers),
@Override
public SendMessageResults sendPaymentNotificationMessage(
- final byte[] receipt, final String note, final RecipientIdentifier.Single recipient
+ final byte[] receipt,
+ final String note,
+ final RecipientIdentifier.Single recipient
) throws IOException {
final var timestamp = signal.sendPaymentNotification(receipt, note, recipient.getIdentifier());
return new SendMessageResults(timestamp, Map.of());
@Override
public void setContactName(
- final RecipientIdentifier.Single recipient, final String givenName, final String familyName
+ final RecipientIdentifier.Single recipient,
+ final String givenName,
+ final String familyName
) throws NotPrimaryDeviceException {
signal.setContactName(recipient.getIdentifier(), givenName);
}
@Override
public void setContactsBlocked(
- final Collection<RecipientIdentifier.Single> recipients, final boolean blocked
+ final Collection<RecipientIdentifier.Single> recipients,
+ final boolean blocked
) throws NotPrimaryDeviceException, IOException {
for (final var recipient : recipients) {
signal.setContactBlocked(recipient.getIdentifier(), blocked);
@Override
public void setGroupsBlocked(
- final Collection<GroupId> groupIds, final boolean blocked
+ final Collection<GroupId> groupIds,
+ final boolean blocked
) throws GroupNotFoundException, IOException {
for (final var groupId : groupIds) {
setGroupProperty(groupId, "IsBlocked", blocked);
@Override
public void setExpirationTimer(
- final RecipientIdentifier.Single recipient, final int messageExpirationTimer
+ final RecipientIdentifier.Single recipient,
+ final int messageExpirationTimer
) throws IOException {
signal.setExpirationTimer(recipient.getIdentifier(), messageExpirationTimer);
}
@Override
public void receiveMessages(
- Optional<Duration> timeout, Optional<Integer> maxMessages, ReceiveMessageHandler handler
+ Optional<Duration> timeout,
+ Optional<Integer> maxMessages,
+ ReceiveMessageHandler handler
) throws IOException, AlreadyReceivingException {
if (receiveThread != null) {
throw new AlreadyReceivingException("Already receiving message.");
@Override
public boolean trustIdentityVerified(
- final RecipientIdentifier.Single recipient, final IdentityVerificationCode verificationCode
+ final RecipientIdentifier.Single recipient,
+ final IdentityVerificationCode verificationCode
) {
throw new UnsupportedOperationException();
}
}
@SuppressWarnings("unchecked")
- private <T> T getValue(
- final Map<String, Variant<?>> stringVariantMap, final String field
- ) {
+ private <T> T getValue(final Map<String, Variant<?>> stringVariantMap, final String field) {
return (T) stringVariantMap.get(field).getValue();
}
}
private final String busname;
public DbusMultiAccountManagerImpl(
- final SignalControl signalControl, DBusConnection connection, final String busname
+ final SignalControl signalControl,
+ DBusConnection connection,
+ final String busname
) {
this.signalControl = signalControl;
this.connection = connection;
}
public DbusProvisioningManagerImpl(
- final SignalControl signalControl, DBusConnection connection, URI deviceLinkUri
+ final SignalControl signalControl,
+ DBusConnection connection,
+ URI deviceLinkUri
) {
this.signalControl = signalControl;
this.connection = connection;
@Override
public void register(
- final boolean voiceVerification, final String captcha, final boolean forceRegister
+ final boolean voiceVerification,
+ final String captcha,
+ final boolean forceRegister
) throws IOException, CaptchaRequiredException {
if (forceRegister) {
throw new UnsupportedOperationException();
@Override
public void verifyAccount(
- final String verificationCode, final String pin
+ final String verificationCode,
+ final String pin
) throws IOException, PinLockedException, IncorrectPinException {
if (pin == null) {
signalControl.verify(number, verificationCode);
@Override
public void register(
- final String number, final boolean voiceVerification
+ final String number,
+ final boolean voiceVerification
) throws Error.Failure, Error.InvalidNumber {
registerWithCaptcha(number, voiceVerification, null);
}
@Override
public void registerWithCaptcha(
- final String number, final boolean voiceVerification, final String captcha
+ final String number,
+ final boolean voiceVerification,
+ final String captcha
) throws Error.Failure, Error.InvalidNumber {
if (!Manager.isValidNumber(number, null)) {
throw new SignalControl.Error.InvalidNumber(
@Override
public void verifyWithPin(
- final String number, final String verificationCode, final String pin
+ final String number,
+ final String verificationCode,
+ final String pin
) throws Error.Failure, Error.InvalidNumber {
try (final RegistrationManager registrationManager = c.getNewRegistrationManager(number)) {
registrationManager.verifyAccount(verificationCode, pin);
private static final Logger logger = LoggerFactory.getLogger(DbusSignalImpl.class);
public DbusSignalImpl(
- final Manager m, DBusConnection connection, final String objectPath, final boolean noReceiveOnStart
+ final Manager m,
+ DBusConnection connection,
+ final String objectPath,
+ final boolean noReceiveOnStart
) {
this.m = m;
this.connection = connection;
}
@Override
- public long sendRemoteDeleteMessage(
- final long targetSentTimestamp, final String recipient
- ) {
+ public long sendRemoteDeleteMessage(final long targetSentTimestamp, final String recipient) {
return sendRemoteDeleteMessage(targetSentTimestamp, List.of(recipient));
}
@Override
- public long sendRemoteDeleteMessage(
- final long targetSentTimestamp, final List<String> recipients
- ) {
+ public long sendRemoteDeleteMessage(final long targetSentTimestamp, final List<String> recipients) {
try {
final var results = m.sendRemoteDeleteMessage(targetSentTimestamp,
getSingleRecipientIdentifiers(recipients, m.getSelfNumber()).stream()
@Override
public long sendPaymentNotification(
- final byte[] receipt, final String note, final String recipient
+ final byte[] receipt,
+ final String note,
+ final String recipient
) throws Error.Failure {
try {
final var results = m.sendPaymentNotificationMessage(receipt,
@Override
public void sendTyping(
- final String recipient, final boolean stop
+ final String recipient,
+ final boolean stop
) throws Error.Failure, Error.GroupNotFound, Error.UntrustedIdentity {
try {
final var results = m.sendTypingMessage(stop ? TypingAction.STOP : TypingAction.START,
@Override
public void sendReadReceipt(
- final String recipient, final List<Long> messageIds
+ final String recipient,
+ final List<Long> messageIds
) throws Error.Failure, Error.UntrustedIdentity {
final var results = m.sendReadReceipt(getSingleRecipientIdentifier(recipient, m.getSelfNumber()), messageIds);
checkSendMessageResults(results);
@Override
public void sendViewedReceipt(
- final String recipient, final List<Long> messageIds
+ final String recipient,
+ final List<Long> messageIds
) throws Error.Failure, Error.UntrustedIdentity {
final var results = m.sendViewedReceipt(getSingleRecipientIdentifier(recipient, m.getSelfNumber()), messageIds);
checkSendMessageResults(results);
@Override
public long sendNoteToSelfMessage(
- final String messageText, final List<String> attachments
+ final String messageText,
+ final List<String> attachments
) throws Error.AttachmentInvalid, Error.Failure, Error.UntrustedIdentity {
try {
final var message = new Message(messageText,
@Override
public void sendGroupTyping(
- final byte[] groupId, final boolean stop
+ final byte[] groupId,
+ final boolean stop
) throws Error.Failure, Error.GroupNotFound, Error.UntrustedIdentity {
try {
final var results = m.sendTypingMessage(stop ? TypingAction.STOP : TypingAction.START,
}
@Override
- public long sendGroupRemoteDeleteMessage(
- final long targetSentTimestamp, final byte[] groupId
- ) {
+ public long sendGroupRemoteDeleteMessage(final long targetSentTimestamp, final byte[] groupId) {
try {
final var results = m.sendRemoteDeleteMessage(targetSentTimestamp,
Set.of(getGroupRecipientIdentifier(groupId)));
@Override
public byte[] createGroup(
- final String name, final List<String> members, final String avatar
+ final String name,
+ final List<String> members,
+ final String avatar
) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber {
return updateGroupInternal(new byte[0], name, members, avatar);
}
}
private static void checkGroupSendMessageResults(
- long timestamp, Collection<SendMessageResult> results
+ long timestamp,
+ Collection<SendMessageResult> results
) throws DBusExecutionException {
if (results.size() == 1) {
checkSendMessageResult(timestamp, results.stream().findFirst().get());
}
private static Set<RecipientIdentifier.Single> getSingleRecipientIdentifiers(
- final Collection<String> recipientStrings, final String localNumber
+ final Collection<String> recipientStrings,
+ final String localNumber
) throws DBusExecutionException {
final var identifiers = new HashSet<RecipientIdentifier.Single>();
for (var recipientString : recipientStrings) {
}
private static RecipientIdentifier.Single getSingleRecipientIdentifier(
- final String recipientString, final String localNumber
+ final String recipientString,
+ final String localNumber
) throws DBusExecutionException {
try {
return RecipientIdentifier.Single.fromString(recipientString, localNumber);
}
private List<Pair<Manager, Manager.ReceiveMessageHandler>> subscribeReceiveHandlers(
- final List<Manager> managers, final ServerSentEventSender sender, Callable unsubscribe
+ final List<Manager> managers,
+ final ServerSentEventSender sender,
+ Callable unsubscribe
) {
return managers.stream().map(m1 -> {
final var receiveMessageHandler = new JsonReceiveMessageHandler(m1, s -> {
@JsonInclude(JsonInclude.Include.NON_NULL) JsonTypingMessage typingMessage
) {
- public static JsonMessageEnvelope from(
- MessageEnvelope envelope, Throwable exception, Manager m
- ) {
+ public static JsonMessageEnvelope from(MessageEnvelope envelope, Throwable exception, Manager m) {
final RecipientAddress sourceAddress;
final Integer sourceDevice;
if (envelope.sourceAddress().isPresent()) {
private ValueNode id;
public static JsonRpcRequest forNotification(
- final String method, final ContainerNode<?> params, final ValueNode id
+ final String method,
+ final ContainerNode<?> params,
+ final ValueNode id
) {
return new JsonRpcRequest("2.0", method, params, id);
}
}
private JsonRpcRequest(
- final String jsonrpc, final String method, final ContainerNode<?> params, final ValueNode id
+ final String jsonrpc,
+ final String method,
+ final ContainerNode<?> params,
+ final ValueNode id
) {
this.jsonrpc = jsonrpc;
this.method = method;
}
public JsonNode handleRequest(
- final ObjectMapper objectMapper, final String method, ContainerNode<?> params
+ final ObjectMapper objectMapper,
+ final String method,
+ ContainerNode<?> params
) throws JsonRpcException {
var command = getCommand(method);
if (c != null) {
}
private JsonNode runCommand(
- final ObjectMapper objectMapper, final ContainerNode<?> params, final CommandRunner<?> command
+ final ObjectMapper objectMapper,
+ final ContainerNode<?> params,
+ final CommandRunner<?> command
) throws JsonRpcException {
final Object[] result = {null};
final JsonWriter commandJsonWriter = s -> {
private SignalJsonRpcCommandHandler commandHandler;
public SignalJsonRpcDispatcherHandler(
- final JsonWriter jsonWriter, final Supplier<String> lineSupplier, final boolean noReceiveOnStart
+ final JsonWriter jsonWriter,
+ final Supplier<String> lineSupplier,
+ final boolean noReceiveOnStart
) {
this.noReceiveOnStart = noReceiveOnStart;
this.objectMapper = Util.createJsonObjectMapper();
@Override
public void handleCommand(
- final Void request, final Manager m, final JsonWriter jsonWriter
+ final Void request,
+ final Manager m,
+ final JsonWriter jsonWriter
) throws CommandException {
final var subscriptionId = subscribeReceive(m, false);
jsonWriter.write(subscriptionId);
@Override
public void handleCommand(
- final Void request, final MultiAccountManager c, final JsonWriter jsonWriter
+ final Void request,
+ final MultiAccountManager c,
+ final JsonWriter jsonWriter
) throws CommandException {
final var subscriptionId = subscribeReceive(c.getManagers(), false);
jsonWriter.write(subscriptionId);
@Override
public void handleCommand(
- final JsonNode request, final Manager m, final JsonWriter jsonWriter
+ final JsonNode request,
+ final Manager m,
+ final JsonWriter jsonWriter
) throws CommandException {
final var subscriptionId = getSubscriptionId(request);
if (subscriptionId == null) {
@Override
public void handleCommand(
- final JsonNode request, final MultiAccountManager c, final JsonWriter jsonWriter
+ final JsonNode request,
+ final MultiAccountManager c,
+ final JsonWriter jsonWriter
) throws CommandException {
final var subscriptionId = getSubscriptionId(request);
if (subscriptionId == null) {
}
public SocketHandler(
- final ServerSocketChannel serverChannel, final MultiAccountManager c, final boolean noReceiveOnStart
+ final ServerSocketChannel serverChannel,
+ final MultiAccountManager c,
+ final boolean noReceiveOnStart
) {
this.serverChannel = serverChannel;
this.socketHandler = channel -> getSignalJsonRpcDispatcherHandler(channel).handleConnection(c);
}
private ConsoleAppender<ILoggingEvent> createLoggingConsoleAppender(
- final LoggerContext lc, final LayoutWrappingEncoder<ILoggingEvent> layoutEncoder
+ final LoggerContext lc,
+ final LayoutWrappingEncoder<ILoggingEvent> layoutEncoder
) {
return new ConsoleAppender<>() {{
setContext(lc);
}
private FileAppender<ILoggingEvent> createLoggingFileAppender(
- final LoggerContext lc, final LayoutWrappingEncoder<ILoggingEvent> layoutEncoder
+ final LoggerContext lc,
+ final LayoutWrappingEncoder<ILoggingEvent> layoutEncoder
) {
return new FileAppender<>() {{
setContext(lc);
return scrub(in, IPV4_PATTERN, (matcher, output) -> output.append(IPV4_CENSOR));
}
- private static CharSequence scrub(
- CharSequence in, Pattern pattern, ProcessMatch processMatch
- ) {
+ private static CharSequence scrub(CharSequence in, Pattern pattern, ProcessMatch processMatch) {
final StringBuilder output = new StringBuilder(in.length());
final Matcher matcher = pattern.matcher(in);
}
public static Set<RecipientIdentifier.Single> getSingleRecipientIdentifiers(
- final Collection<String> recipientStrings, final String localNumber
+ final Collection<String> recipientStrings,
+ final String localNumber
) throws UserErrorException {
if (recipientStrings == null) {
return Set.of();
}
public static RecipientIdentifier.Single getSingleRecipientIdentifier(
- final String recipientString, final String localNumber
+ final String recipientString,
+ final String localNumber
) throws UserErrorException {
try {
return RecipientIdentifier.Single.fromString(recipientString, localNumber);
}
public static void outputResult(
- final OutputWriter outputWriter, final SendMessageResults sendMessageResults
+ final OutputWriter outputWriter,
+ final SendMessageResults sendMessageResults
) throws CommandException {
switch (outputWriter) {
case PlainTextWriter writer -> {