mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
Reformat files
This commit is contained in:
parent
3533500b73
commit
f2005593ec
148 changed files with 1056 additions and 578 deletions
|
@ -130,11 +130,15 @@ public interface Manager extends Closeable {
|
|||
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;
|
||||
|
@ -142,7 +146,8 @@ public interface Manager extends Closeable {
|
|||
void deleteAccount() throws IOException;
|
||||
|
||||
void submitRateLimitRecaptchaChallenge(
|
||||
String challenge, String captcha
|
||||
String challenge,
|
||||
String captcha
|
||||
) throws IOException, CaptchaRejectedException;
|
||||
|
||||
List<Device> getLinkedDevices() throws IOException;
|
||||
|
@ -156,17 +161,21 @@ public interface Manager extends Closeable {
|
|||
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(
|
||||
|
@ -174,27 +183,29 @@ public interface Manager extends Closeable {
|
|||
) 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(
|
||||
|
@ -207,13 +218,16 @@ public interface Manager extends Closeable {
|
|||
) 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);
|
||||
|
@ -223,22 +237,27 @@ public interface Manager extends Closeable {
|
|||
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;
|
||||
|
||||
/**
|
||||
|
@ -277,7 +296,9 @@ public interface Manager extends Closeable {
|
|||
* 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();
|
||||
|
@ -309,7 +330,8 @@ public interface Manager extends Closeable {
|
|||
* @param recipient account of the identity
|
||||
*/
|
||||
boolean trustIdentityVerified(
|
||||
RecipientIdentifier.Single recipient, IdentityVerificationCode verificationCode
|
||||
RecipientIdentifier.Single recipient,
|
||||
IdentityVerificationCode verificationCode
|
||||
) throws UnregisteredRecipientException;
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,11 +13,14 @@ import java.io.IOException;
|
|||
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;
|
||||
|
|
|
@ -85,7 +85,8 @@ public class SignalAccountFiles {
|
|||
}
|
||||
|
||||
private Manager initManager(
|
||||
String number, String accountPath
|
||||
String number,
|
||||
String accountPath
|
||||
) throws IOException, NotRegisteredException, AccountCheckException {
|
||||
if (accountPath == null) {
|
||||
throw new NotRegisteredException();
|
||||
|
@ -152,7 +153,8 @@ public class SignalAccountFiles {
|
|||
}
|
||||
|
||||
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)) {
|
||||
|
|
|
@ -13,7 +13,9 @@ public class ResendMessageAction implements HandleAction {
|
|||
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;
|
||||
|
|
|
@ -15,7 +15,9 @@ public class SendReceiptAction implements HandleAction {
|
|||
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;
|
||||
|
|
|
@ -27,7 +27,9 @@ public record Group(
|
|||
) {
|
||||
|
||||
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(),
|
||||
|
|
|
@ -338,7 +338,8 @@ public record MessageEnvelope(
|
|||
}
|
||||
|
||||
static Attachment from(
|
||||
SignalServiceDataMessage.Quote.QuotedAttachment a, final AttachmentFileProvider fileProvider
|
||||
SignalServiceDataMessage.Quote.QuotedAttachment a,
|
||||
final AttachmentFileProvider fileProvider
|
||||
) {
|
||||
return new Attachment(Optional.empty(),
|
||||
Optional.empty(),
|
||||
|
@ -510,9 +511,7 @@ public record MessageEnvelope(
|
|||
|
||||
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(),
|
||||
|
@ -832,9 +831,7 @@ public record MessageEnvelope(
|
|||
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)),
|
||||
|
@ -852,7 +849,8 @@ public record MessageEnvelope(
|
|||
) {
|
||||
|
||||
static TextAttachment from(
|
||||
SignalServiceTextAttachment textAttachment, final AttachmentFileProvider fileProvider
|
||||
SignalServiceTextAttachment textAttachment,
|
||||
final AttachmentFileProvider fileProvider
|
||||
) {
|
||||
return new TextAttachment(textAttachment.getText(),
|
||||
textAttachment.getStyle().map(Style::from),
|
||||
|
|
|
@ -33,7 +33,8 @@ public class ServiceConfig {
|
|||
}
|
||||
|
||||
public static ServiceEnvironmentConfig getServiceEnvironmentConfig(
|
||||
ServiceEnvironment serviceEnvironment, String userAgent
|
||||
ServiceEnvironment serviceEnvironment,
|
||||
String userAgent
|
||||
) {
|
||||
final Interceptor userAgentInterceptor = chain -> chain.proceed(chain.request()
|
||||
.newBuilder()
|
||||
|
|
|
@ -18,7 +18,8 @@ import org.whispersystems.signalservice.api.messages.SignalServiceGroupV2;
|
|||
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)
|
||||
|
|
|
@ -165,7 +165,9 @@ public class AccountHelper {
|
|||
}
|
||||
|
||||
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();
|
||||
|
@ -178,7 +180,9 @@ public class AccountHelper {
|
|||
}
|
||||
|
||||
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 {
|
||||
|
@ -196,7 +200,9 @@ public class AccountHelper {
|
|||
}
|
||||
|
||||
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>();
|
||||
|
@ -308,9 +314,7 @@ public class AccountHelper {
|
|||
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) {
|
||||
|
|
|
@ -104,9 +104,7 @@ public class AttachmentHelper {
|
|||
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 ...)
|
||||
|
@ -131,7 +129,8 @@ public class AttachmentHelper {
|
|||
}
|
||||
|
||||
private InputStream retrieveAttachmentAsStream(
|
||||
SignalServiceAttachmentPointer pointer, File tmpFile
|
||||
SignalServiceAttachmentPointer pointer,
|
||||
File tmpFile
|
||||
) throws IOException {
|
||||
try {
|
||||
return dependencies.getMessageReceiver()
|
||||
|
|
|
@ -49,7 +49,9 @@ public class ContactHelper {
|
|||
}
|
||||
|
||||
public void setExpirationTimer(
|
||||
RecipientId recipientId, int messageExpirationTimer, int messageExpirationTimerVersion
|
||||
RecipientId recipientId,
|
||||
int messageExpirationTimer,
|
||||
int messageExpirationTimerVersion
|
||||
) {
|
||||
var contact = account.getContactStore().getContact(recipientId);
|
||||
if (contact != null && (
|
||||
|
|
|
@ -118,7 +118,9 @@ public class GroupHelper {
|
|||
}
|
||||
|
||||
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);
|
||||
|
||||
|
@ -166,7 +168,8 @@ public class GroupHelper {
|
|||
}
|
||||
|
||||
private DecryptedGroup handleDecryptedGroupResponse(
|
||||
GroupInfoV2 groupInfoV2, final DecryptedGroupResponse decryptedGroupResponse
|
||||
GroupInfoV2 groupInfoV2,
|
||||
final DecryptedGroupResponse decryptedGroupResponse
|
||||
) {
|
||||
final var groupSecretParams = GroupSecretParams.deriveFromMasterKey(groupInfoV2.getMasterKey());
|
||||
ReceivedGroupSendEndorsements groupSendEndorsements = dependencies.getGroupsV2Operations()
|
||||
|
@ -181,7 +184,8 @@ public class GroupHelper {
|
|||
}
|
||||
|
||||
private GroupChange handleGroupChangeResponse(
|
||||
final GroupInfoV2 groupInfoV2, final GroupChangeResponse groupChangeResponse
|
||||
final GroupInfoV2 groupInfoV2,
|
||||
final GroupChangeResponse groupChangeResponse
|
||||
) {
|
||||
ReceivedGroupSendEndorsements groupSendEndorsements = dependencies.getGroupsV2Operations()
|
||||
.forGroup(GroupSecretParams.deriveFromMasterKey(groupInfoV2.getMasterKey()))
|
||||
|
@ -195,7 +199,9 @@ public class GroupHelper {
|
|||
}
|
||||
|
||||
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)) {
|
||||
|
@ -363,7 +369,8 @@ public class GroupHelper {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
@ -396,9 +403,7 @@ public class GroupHelper {
|
|||
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());
|
||||
|
@ -408,7 +413,8 @@ public class GroupHelper {
|
|||
}
|
||||
|
||||
public SendGroupMessageResults sendGroupInfoMessage(
|
||||
GroupIdV1 groupId, RecipientId recipientId
|
||||
GroupIdV1 groupId,
|
||||
RecipientId recipientId
|
||||
) throws IOException, NotAGroupMemberException, GroupNotFoundException, AttachmentInvalidException {
|
||||
GroupInfoV1 g;
|
||||
var group = getGroupForUpdating(groupId);
|
||||
|
@ -480,7 +486,9 @@ public class GroupHelper {
|
|||
}
|
||||
|
||||
private void retrieveGroupV2Avatar(
|
||||
GroupSecretParams groupSecretParams, String cdnKey, OutputStream outputStream
|
||||
GroupSecretParams groupSecretParams,
|
||||
String cdnKey,
|
||||
OutputStream outputStream
|
||||
) throws IOException {
|
||||
var groupOperations = dependencies.getGroupsV2Operations().forGroup(groupSecretParams);
|
||||
|
||||
|
@ -583,7 +591,10 @@ public class GroupHelper {
|
|||
}
|
||||
|
||||
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);
|
||||
|
||||
|
@ -596,7 +607,10 @@ public class GroupHelper {
|
|||
}
|
||||
|
||||
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;
|
||||
|
@ -615,7 +629,8 @@ public class GroupHelper {
|
|||
* 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);
|
||||
|
@ -828,7 +843,8 @@ public class GroupHelper {
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -882,7 +898,9 @@ public class GroupHelper {
|
|||
}
|
||||
|
||||
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);
|
||||
|
|
|
@ -94,7 +94,8 @@ class GroupV2Helper {
|
|||
}
|
||||
|
||||
DecryptedGroupJoinInfo getDecryptedGroupJoinInfo(
|
||||
GroupMasterKey groupMasterKey, GroupLinkPassword password
|
||||
GroupMasterKey groupMasterKey,
|
||||
GroupLinkPassword password
|
||||
) throws IOException, GroupLinkNotActiveException {
|
||||
var groupSecretParams = GroupSecretParams.deriveFromMasterKey(groupMasterKey);
|
||||
|
||||
|
@ -105,7 +106,9 @@ class GroupV2Helper {
|
|||
}
|
||||
|
||||
GroupHistoryPage getDecryptedGroupHistoryPage(
|
||||
final GroupSecretParams groupSecretParams, int fromRevision, long sendEndorsementsExpirationMs
|
||||
final GroupSecretParams groupSecretParams,
|
||||
int fromRevision,
|
||||
long sendEndorsementsExpirationMs
|
||||
) throws NotAGroupMemberException {
|
||||
try {
|
||||
final var groupsV2AuthorizationString = getGroupAuthForToday(groupSecretParams);
|
||||
|
@ -138,9 +141,7 @@ class GroupV2Helper {
|
|||
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;
|
||||
|
@ -170,9 +171,7 @@ class GroupV2Helper {
|
|||
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) {
|
||||
|
@ -202,7 +201,10 @@ class GroupV2Helper {
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -225,7 +227,8 @@ class GroupV2Helper {
|
|||
}
|
||||
|
||||
Pair<DecryptedGroup, GroupChangeResponse> addMembers(
|
||||
GroupInfoV2 groupInfoV2, Set<RecipientId> newMembers
|
||||
GroupInfoV2 groupInfoV2,
|
||||
Set<RecipientId> newMembers
|
||||
) throws IOException {
|
||||
GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
||||
|
||||
|
@ -251,7 +254,8 @@ class GroupV2Helper {
|
|||
}
|
||||
|
||||
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();
|
||||
|
@ -271,7 +275,8 @@ class GroupV2Helper {
|
|||
}
|
||||
|
||||
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)
|
||||
|
@ -283,7 +288,8 @@ class GroupV2Helper {
|
|||
}
|
||||
|
||||
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)
|
||||
|
@ -294,7 +300,8 @@ class GroupV2Helper {
|
|||
}
|
||||
|
||||
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)
|
||||
|
@ -304,7 +311,8 @@ class GroupV2Helper {
|
|||
}
|
||||
|
||||
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()
|
||||
|
@ -318,7 +326,8 @@ class GroupV2Helper {
|
|||
}
|
||||
|
||||
Pair<DecryptedGroup, GroupChangeResponse> banMembers(
|
||||
GroupInfoV2 groupInfoV2, Set<RecipientId> block
|
||||
GroupInfoV2 groupInfoV2,
|
||||
Set<RecipientId> block
|
||||
) throws IOException {
|
||||
GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
||||
|
||||
|
@ -336,7 +345,8 @@ class GroupV2Helper {
|
|||
}
|
||||
|
||||
Pair<DecryptedGroup, GroupChangeResponse> unbanMembers(
|
||||
GroupInfoV2 groupInfoV2, Set<RecipientId> block
|
||||
GroupInfoV2 groupInfoV2,
|
||||
Set<RecipientId> block
|
||||
) throws IOException {
|
||||
GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
||||
|
||||
|
@ -359,7 +369,8 @@ class GroupV2Helper {
|
|||
}
|
||||
|
||||
Pair<DecryptedGroup, GroupChangeResponse> setGroupLinkState(
|
||||
GroupInfoV2 groupInfoV2, GroupLinkState state
|
||||
GroupInfoV2 groupInfoV2,
|
||||
GroupLinkState state
|
||||
) throws IOException {
|
||||
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
||||
|
||||
|
@ -374,7 +385,8 @@ class GroupV2Helper {
|
|||
}
|
||||
|
||||
Pair<DecryptedGroup, GroupChangeResponse> setEditDetailsPermission(
|
||||
GroupInfoV2 groupInfoV2, GroupPermission permission
|
||||
GroupInfoV2 groupInfoV2,
|
||||
GroupPermission permission
|
||||
) throws IOException {
|
||||
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
||||
|
||||
|
@ -384,7 +396,8 @@ class GroupV2Helper {
|
|||
}
|
||||
|
||||
Pair<DecryptedGroup, GroupChangeResponse> setAddMemberPermission(
|
||||
GroupInfoV2 groupInfoV2, GroupPermission permission
|
||||
GroupInfoV2 groupInfoV2,
|
||||
GroupPermission permission
|
||||
) throws IOException {
|
||||
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
||||
|
||||
|
@ -468,7 +481,9 @@ class GroupV2Helper {
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -482,7 +497,8 @@ class GroupV2Helper {
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -490,7 +506,8 @@ class GroupV2Helper {
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -518,7 +535,8 @@ class GroupV2Helper {
|
|||
}
|
||||
|
||||
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 -> {
|
||||
|
@ -532,28 +550,32 @@ class GroupV2Helper {
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -676,7 +698,8 @@ class GroupV2Helper {
|
|||
}
|
||||
|
||||
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();
|
||||
|
|
|
@ -66,9 +66,7 @@ public class IdentityHelper {
|
|||
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(),
|
||||
|
@ -89,7 +87,9 @@ public class IdentityHelper {
|
|||
}
|
||||
|
||||
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);
|
||||
|
|
|
@ -190,7 +190,9 @@ public final class IncomingMessageHandler {
|
|||
}
|
||||
|
||||
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();
|
||||
|
@ -280,7 +282,9 @@ public final class IncomingMessageHandler {
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -381,7 +385,8 @@ public final class IncomingMessageHandler {
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -865,7 +870,9 @@ public final class IncomingMessageHandler {
|
|||
}
|
||||
|
||||
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()) {
|
||||
|
|
|
@ -21,9 +21,7 @@ public class PinHelper {
|
|||
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 {
|
||||
|
@ -82,7 +80,8 @@ public class PinHelper {
|
|||
}
|
||||
|
||||
public SecureValueRecovery.RestoreResponse.Success getRegistrationLockData(
|
||||
String pin, LockedException lockedException
|
||||
String pin,
|
||||
LockedException lockedException
|
||||
) throws IOException, IncorrectPinException {
|
||||
var svr2Credentials = lockedException.getSvr2Credentials();
|
||||
if (svr2Credentials != null) {
|
||||
|
@ -103,7 +102,9 @@ public class PinHelper {
|
|||
}
|
||||
|
||||
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);
|
||||
|
||||
|
|
|
@ -30,9 +30,7 @@ public class PreKeyHelper {
|
|||
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;
|
||||
}
|
||||
|
@ -79,7 +77,8 @@ public class PreKeyHelper {
|
|||
}
|
||||
|
||||
private boolean refreshPreKeysIfNecessary(
|
||||
final ServiceIdType serviceIdType, final IdentityKeyPair identityKeyPair
|
||||
final ServiceIdType serviceIdType,
|
||||
final IdentityKeyPair identityKeyPair
|
||||
) throws IOException {
|
||||
OneTimePreKeyCounts preKeyCounts;
|
||||
try {
|
||||
|
@ -221,7 +220,8 @@ public class PreKeyHelper {
|
|||
}
|
||||
|
||||
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();
|
||||
|
@ -246,7 +246,9 @@ public class PreKeyHelper {
|
|||
}
|
||||
|
||||
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;
|
||||
|
|
|
@ -271,7 +271,9 @@ public final class ProfileHelper {
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -280,7 +282,9 @@ public final class ProfileHelper {
|
|||
}
|
||||
|
||||
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())) {
|
||||
|
@ -308,7 +312,8 @@ public final class ProfileHelper {
|
|||
}
|
||||
|
||||
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));
|
||||
|
@ -408,9 +413,7 @@ public final class ProfileHelper {
|
|||
});
|
||||
}
|
||||
|
||||
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);
|
||||
|
@ -430,7 +433,9 @@ public final class ProfileHelper {
|
|||
}
|
||||
|
||||
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()
|
||||
|
|
|
@ -83,7 +83,10 @@ public class ReceiveHelper {
|
|||
}
|
||||
|
||||
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;
|
||||
|
@ -264,7 +267,8 @@ public class ReceiveHelper {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
|
|
@ -97,7 +97,8 @@ public class RecipientHelper {
|
|||
}
|
||||
|
||||
public RecipientId resolveRecipientByUsernameOrLink(
|
||||
String username, boolean forceRefresh
|
||||
String username,
|
||||
boolean forceRefresh
|
||||
) throws UnregisteredRecipientException {
|
||||
final Username finalUsername;
|
||||
try {
|
||||
|
@ -180,7 +181,8 @@ public class RecipientHelper {
|
|||
}
|
||||
|
||||
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);
|
||||
|
||||
|
@ -211,7 +213,8 @@ public class RecipientHelper {
|
|||
}
|
||||
|
||||
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) {{
|
||||
|
|
|
@ -125,7 +125,8 @@ public class SendHelper {
|
|||
}
|
||||
|
||||
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,
|
||||
|
@ -157,7 +158,9 @@ public class SendHelper {
|
|||
}
|
||||
|
||||
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(),
|
||||
|
@ -183,7 +186,8 @@ public class SendHelper {
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -214,9 +218,7 @@ public class SendHelper {
|
|||
}
|
||||
}
|
||||
|
||||
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());
|
||||
|
@ -225,7 +227,8 @@ public class SendHelper {
|
|||
}
|
||||
|
||||
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())) {
|
||||
|
@ -238,7 +241,9 @@ public class SendHelper {
|
|||
}
|
||||
|
||||
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()) {
|
||||
|
@ -552,7 +557,9 @@ public class SendHelper {
|
|||
}
|
||||
|
||||
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()
|
||||
|
@ -644,7 +651,9 @@ public class SendHelper {
|
|||
}
|
||||
|
||||
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;
|
||||
|
|
|
@ -30,7 +30,9 @@ public class StickerHelper {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
@ -50,7 +52,8 @@ public class StickerHelper {
|
|||
}
|
||||
|
||||
public JsonStickerPack getOrRetrieveStickerPack(
|
||||
StickerPackId packId, byte[] packKey
|
||||
StickerPackId packId,
|
||||
byte[] packKey
|
||||
) throws InvalidStickerException {
|
||||
try {
|
||||
retrieveStickerPack(packId, packKey);
|
||||
|
|
|
@ -218,7 +218,9 @@ public class StorageHelper {
|
|||
}
|
||||
|
||||
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()) {
|
||||
|
@ -408,7 +410,8 @@ public class StorageHelper {
|
|||
}
|
||||
|
||||
private List<SignalStorageRecord> getSignalStorageRecords(
|
||||
final StorageKey storageKey, final List<StorageId> storageIds
|
||||
final StorageKey storageKey,
|
||||
final List<StorageId> storageIds
|
||||
) throws IOException {
|
||||
List<SignalStorageRecord> records;
|
||||
try {
|
||||
|
@ -430,7 +433,8 @@ public class StorageHelper {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
@ -443,7 +447,8 @@ public class StorageHelper {
|
|||
}
|
||||
|
||||
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 -> {
|
||||
|
@ -484,7 +489,8 @@ public class StorageHelper {
|
|||
* 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()
|
||||
|
@ -520,7 +526,8 @@ public class StorageHelper {
|
|||
}
|
||||
|
||||
private List<StorageId> processKnownRecords(
|
||||
final Connection connection, List<SignalStorageRecord> records
|
||||
final Connection connection,
|
||||
List<SignalStorageRecord> records
|
||||
) throws SQLException {
|
||||
final var unknownRecords = new ArrayList<StorageId>();
|
||||
|
||||
|
|
|
@ -217,7 +217,9 @@ public class SyncHelper {
|
|||
|
||||
@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
|
||||
|
@ -262,7 +264,9 @@ public class SyncHelper {
|
|||
}
|
||||
|
||||
public SendMessageResult sendVerifiedMessage(
|
||||
SignalServiceAddress destination, IdentityKey identityKey, TrustLevel trustLevel
|
||||
SignalServiceAddress destination,
|
||||
IdentityKey identityKey,
|
||||
TrustLevel trustLevel
|
||||
) {
|
||||
var verifiedMessage = new VerifiedMessage(destination,
|
||||
identityKey,
|
||||
|
@ -278,7 +282,8 @@ public class SyncHelper {
|
|||
}
|
||||
|
||||
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));
|
||||
|
@ -288,7 +293,8 @@ public class SyncHelper {
|
|||
}
|
||||
|
||||
private static StickerPackOperationMessage getStickerPackOperationMessage(
|
||||
final StickerPack s, final boolean installed
|
||||
final StickerPack s,
|
||||
final boolean installed
|
||||
) {
|
||||
return new StickerPackOperationMessage(s.packId().serialize(),
|
||||
s.packKey(),
|
||||
|
@ -414,15 +420,14 @@ public class SyncHelper {
|
|||
}
|
||||
}
|
||||
|
||||
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()) {
|
||||
|
|
|
@ -158,7 +158,8 @@ public class UnidentifiedAccessHelper {
|
|||
}
|
||||
|
||||
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);
|
||||
|
|
|
@ -417,7 +417,9 @@ public class ManagerImpl implements Manager {
|
|||
|
||||
@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();
|
||||
|
@ -427,7 +429,9 @@ public class ManagerImpl implements Manager {
|
|||
|
||||
@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();
|
||||
|
@ -447,7 +451,8 @@ public class ManagerImpl implements Manager {
|
|||
|
||||
@Override
|
||||
public void submitRateLimitRecaptchaChallenge(
|
||||
String challenge, String captcha
|
||||
String challenge,
|
||||
String captcha
|
||||
) throws IOException, CaptchaRejectedException {
|
||||
captcha = captcha == null ? null : captcha.replace("signalcaptcha://", "");
|
||||
|
||||
|
@ -527,7 +532,8 @@ public class ManagerImpl implements Manager {
|
|||
|
||||
@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);
|
||||
|
@ -545,7 +551,9 @@ public class ManagerImpl implements Manager {
|
|||
|
||||
@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,
|
||||
|
@ -555,7 +563,8 @@ public class ManagerImpl implements Manager {
|
|||
|
||||
@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,
|
||||
|
@ -596,7 +605,9 @@ public class ManagerImpl implements Manager {
|
|||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
@ -644,7 +655,8 @@ public class ManagerImpl implements Manager {
|
|||
}
|
||||
|
||||
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();
|
||||
|
@ -671,15 +683,14 @@ public class ManagerImpl implements Manager {
|
|||
|
||||
@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,
|
||||
|
@ -689,9 +700,7 @@ public class ManagerImpl implements Manager {
|
|||
}
|
||||
|
||||
@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,
|
||||
|
@ -724,7 +733,9 @@ public class ManagerImpl implements Manager {
|
|||
|
||||
@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()) {
|
||||
|
@ -738,7 +749,9 @@ public class ManagerImpl implements Manager {
|
|||
|
||||
@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);
|
||||
|
@ -746,7 +759,8 @@ public class ManagerImpl implements Manager {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
@ -863,7 +877,8 @@ public class ManagerImpl implements Manager {
|
|||
|
||||
@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);
|
||||
|
@ -915,7 +930,9 @@ public class ManagerImpl implements Manager {
|
|||
|
||||
@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);
|
||||
|
@ -958,7 +975,8 @@ public class ManagerImpl implements Manager {
|
|||
|
||||
@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) {
|
||||
|
@ -1021,7 +1039,9 @@ public class ManagerImpl implements Manager {
|
|||
|
||||
@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();
|
||||
|
@ -1033,7 +1053,8 @@ public class ManagerImpl implements Manager {
|
|||
|
||||
@Override
|
||||
public void setContactsBlocked(
|
||||
Collection<RecipientIdentifier.Single> recipients, boolean blocked
|
||||
Collection<RecipientIdentifier.Single> recipients,
|
||||
boolean blocked
|
||||
) throws IOException, UnregisteredRecipientException {
|
||||
if (recipients.isEmpty()) {
|
||||
return;
|
||||
|
@ -1067,7 +1088,8 @@ public class ManagerImpl implements Manager {
|
|||
|
||||
@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;
|
||||
|
@ -1093,7 +1115,8 @@ public class ManagerImpl implements Manager {
|
|||
|
||||
@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);
|
||||
|
@ -1255,7 +1278,9 @@ public class ManagerImpl implements Manager {
|
|||
|
||||
@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);
|
||||
}
|
||||
|
@ -1275,7 +1300,10 @@ public class ManagerImpl implements Manager {
|
|||
}
|
||||
|
||||
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()) {
|
||||
|
@ -1431,7 +1459,8 @@ public class ManagerImpl implements Manager {
|
|||
|
||||
@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,
|
||||
|
@ -1450,7 +1479,8 @@ public class ManagerImpl implements Manager {
|
|||
}
|
||||
|
||||
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);
|
||||
|
|
|
@ -105,7 +105,9 @@ public class RegistrationManagerImpl implements RegistrationManager {
|
|||
|
||||
@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
|
||||
|
@ -145,7 +147,8 @@ public class RegistrationManagerImpl implements RegistrationManager {
|
|||
|
||||
@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");
|
||||
|
|
|
@ -611,7 +611,8 @@ public class AccountDatabase extends Database {
|
|||
}
|
||||
|
||||
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 (
|
||||
|
|
|
@ -22,7 +22,8 @@ public class AttachmentStore {
|
|||
}
|
||||
|
||||
public void storeAttachmentPreview(
|
||||
final SignalServiceAttachmentPointer pointer, final AttachmentStorer storer
|
||||
final SignalServiceAttachmentPointer pointer,
|
||||
final AttachmentStorer storer
|
||||
) throws IOException {
|
||||
storeAttachment(getAttachmentPreviewFile(pointer.getRemoteId(),
|
||||
pointer.getFileName(),
|
||||
|
@ -30,7 +31,8 @@ public class AttachmentStore {
|
|||
}
|
||||
|
||||
public void storeAttachment(
|
||||
final SignalServiceAttachmentPointer pointer, final AttachmentStorer storer
|
||||
final SignalServiceAttachmentPointer pointer,
|
||||
final AttachmentStorer storer
|
||||
) throws IOException {
|
||||
storeAttachment(getAttachmentFile(pointer), storer);
|
||||
}
|
||||
|
@ -54,22 +56,24 @@ public class AttachmentStore {
|
|||
}
|
||||
|
||||
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))
|
||||
|
|
|
@ -24,7 +24,8 @@ public abstract class Database implements AutoCloseable {
|
|||
}
|
||||
|
||||
public static <T extends Database> T initDatabase(
|
||||
File databaseFile, Function<HikariDataSource, T> newDatabase
|
||||
File databaseFile,
|
||||
Function<HikariDataSource, T> newDatabase
|
||||
) throws SQLException {
|
||||
HikariDataSource dataSource = null;
|
||||
|
||||
|
|
|
@ -189,7 +189,10 @@ public class SignalAccount implements Closeable {
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -316,7 +319,9 @@ public class SignalAccount implements Closeable {
|
|||
}
|
||||
|
||||
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;
|
||||
|
@ -375,7 +380,9 @@ public class SignalAccount implements Closeable {
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -438,9 +445,7 @@ public class SignalAccount implements Closeable {
|
|||
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;
|
||||
|
@ -786,7 +791,8 @@ public class SignalAccount implements Closeable {
|
|||
}
|
||||
|
||||
private void loadLegacyStores(
|
||||
final JsonNode rootNode, final LegacyJsonSignalProtocolStore legacySignalProtocolStore
|
||||
final JsonNode rootNode,
|
||||
final LegacyJsonSignalProtocolStore legacySignalProtocolStore
|
||||
) {
|
||||
var legacyRecipientStoreNode = rootNode.get("recipientStore");
|
||||
if (legacyRecipientStoreNode != null) {
|
||||
|
|
|
@ -41,9 +41,7 @@ public class UnknownStorageIdStore {
|
|||
}
|
||||
}
|
||||
|
||||
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 = (
|
||||
"""
|
||||
|
|
|
@ -72,7 +72,8 @@ public class Utils {
|
|||
}
|
||||
|
||||
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()) {
|
||||
|
@ -82,7 +83,8 @@ public class Utils {
|
|||
}
|
||||
|
||||
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()) {
|
||||
|
@ -92,7 +94,8 @@ public class Utils {
|
|||
}
|
||||
|
||||
public static <T> Stream<T> executeQueryForStream(
|
||||
PreparedStatement statement, ResultSetMapper<T> mapper
|
||||
PreparedStatement statement,
|
||||
ResultSetMapper<T> mapper
|
||||
) throws SQLException {
|
||||
final var resultSet = statement.executeQuery();
|
||||
|
||||
|
|
|
@ -41,7 +41,9 @@ public class AccountsStore {
|
|||
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);
|
||||
|
@ -202,7 +204,9 @@ public class AccountsStore {
|
|||
}
|
||||
|
||||
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();
|
||||
|
|
|
@ -59,7 +59,8 @@ public class ConfigurationStore {
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -125,7 +126,8 @@ public class ConfigurationStore {
|
|||
}
|
||||
|
||||
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);
|
||||
|
|
|
@ -31,7 +31,9 @@ public final class GroupInfoV2 extends GroupInfo {
|
|||
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;
|
||||
|
|
|
@ -121,7 +121,10 @@ public class GroupStore {
|
|||
}
|
||||
|
||||
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 = (
|
||||
|
@ -250,7 +253,8 @@ public class GroupStore {
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -258,9 +262,7 @@ public class GroupStore {
|
|||
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) {
|
||||
|
@ -269,7 +271,9 @@ public class GroupStore {
|
|||
}
|
||||
|
||||
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 -> {
|
||||
|
@ -325,7 +329,9 @@ public class GroupStore {
|
|||
}
|
||||
|
||||
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 = (
|
||||
"""
|
||||
|
@ -360,7 +366,9 @@ public class GroupStore {
|
|||
}
|
||||
|
||||
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 = (
|
||||
"""
|
||||
|
@ -385,9 +393,7 @@ public class GroupStore {
|
|||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -460,7 +466,9 @@ public class GroupStore {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
|
|
@ -151,7 +151,8 @@ public class LegacyGroupStore {
|
|||
|
||||
@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);
|
||||
|
@ -184,7 +185,8 @@ public class LegacyGroupStore {
|
|||
|
||||
@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);
|
||||
|
|
|
@ -11,9 +11,7 @@ public class IdentityInfo {
|
|||
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;
|
||||
|
|
|
@ -49,7 +49,9 @@ public class IdentityKeyStore {
|
|||
}
|
||||
|
||||
public IdentityKeyStore(
|
||||
final Database database, final TrustNewIdentity trustNewIdentity, RecipientStore recipientStore
|
||||
final Database database,
|
||||
final TrustNewIdentity trustNewIdentity,
|
||||
RecipientStore recipientStore
|
||||
) {
|
||||
this.database = database;
|
||||
this.trustNewIdentity = trustNewIdentity;
|
||||
|
@ -65,7 +67,9 @@ public class IdentityKeyStore {
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -82,7 +86,9 @@ public class IdentityKeyStore {
|
|||
}
|
||||
|
||||
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)) {
|
||||
|
@ -230,9 +236,7 @@ public class IdentityKeyStore {
|
|||
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
|
||||
|
|
|
@ -41,7 +41,9 @@ public class LegacyIdentityKeyStore {
|
|||
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) {
|
||||
|
@ -66,7 +68,9 @@ public class LegacyIdentityKeyStore {
|
|||
}
|
||||
|
||||
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()) {
|
||||
|
|
|
@ -74,7 +74,9 @@ public class KeyValueStore {
|
|||
}
|
||||
|
||||
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)) {
|
||||
|
@ -98,7 +100,8 @@ public class KeyValueStore {
|
|||
|
||||
@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();
|
||||
|
@ -134,7 +137,10 @@ public class KeyValueStore {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
|
|
@ -34,7 +34,8 @@ public class LegacyProfileStore {
|
|||
|
||||
@Override
|
||||
public List<LegacySignalProfileEntry> deserialize(
|
||||
JsonParser jsonParser, DeserializationContext deserializationContext
|
||||
JsonParser jsonParser,
|
||||
DeserializationContext deserializationContext
|
||||
) throws IOException {
|
||||
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ public interface ProfileStore {
|
|||
void storeProfileKey(RecipientId recipientId, ProfileKey profileKey);
|
||||
|
||||
void storeExpiringProfileKeyCredential(
|
||||
RecipientId recipientId, ExpiringProfileKeyCredential expiringProfileKeyCredential
|
||||
RecipientId recipientId,
|
||||
ExpiringProfileKeyCredential expiringProfileKeyCredential
|
||||
);
|
||||
}
|
||||
|
|
|
@ -32,7 +32,9 @@ public class LegacyJsonIdentityKeyStore {
|
|||
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;
|
||||
|
@ -77,7 +79,8 @@ public class LegacyJsonIdentityKeyStore {
|
|||
|
||||
@Override
|
||||
public LegacyJsonIdentityKeyStore deserialize(
|
||||
JsonParser jsonParser, DeserializationContext deserializationContext
|
||||
JsonParser jsonParser,
|
||||
DeserializationContext deserializationContext
|
||||
) throws IOException {
|
||||
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
|
||||
|
||||
|
|
|
@ -26,7 +26,8 @@ public class LegacyJsonPreKeyStore {
|
|||
|
||||
@Override
|
||||
public LegacyJsonPreKeyStore deserialize(
|
||||
JsonParser jsonParser, DeserializationContext deserializationContext
|
||||
JsonParser jsonParser,
|
||||
DeserializationContext deserializationContext
|
||||
) throws IOException {
|
||||
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
|
||||
|
||||
|
|
|
@ -31,7 +31,8 @@ public class LegacyJsonSessionStore {
|
|||
|
||||
@Override
|
||||
public LegacyJsonSessionStore deserialize(
|
||||
JsonParser jsonParser, DeserializationContext deserializationContext
|
||||
JsonParser jsonParser,
|
||||
DeserializationContext deserializationContext
|
||||
) throws IOException {
|
||||
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
|
||||
|
||||
|
|
|
@ -26,7 +26,8 @@ public class LegacyJsonSignedPreKeyStore {
|
|||
|
||||
@Override
|
||||
public LegacyJsonSignedPreKeyStore deserialize(
|
||||
JsonParser jsonParser, DeserializationContext deserializationContext
|
||||
JsonParser jsonParser,
|
||||
DeserializationContext deserializationContext
|
||||
) throws IOException {
|
||||
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
|
||||
|
||||
|
|
|
@ -172,7 +172,9 @@ public class SignalProtocolStore implements SignalServiceAccountDataStore {
|
|||
|
||||
@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);
|
||||
}
|
||||
|
@ -189,7 +191,8 @@ public class SignalProtocolStore implements SignalServiceAccountDataStore {
|
|||
|
||||
@Override
|
||||
public void markSenderKeySharedWith(
|
||||
final DistributionId distributionId, final Collection<SignalProtocolAddress> addresses
|
||||
final DistributionId distributionId,
|
||||
final Collection<SignalProtocolAddress> addresses
|
||||
) {
|
||||
senderKeyStore.markSenderKeySharedWith(distributionId, addresses);
|
||||
}
|
||||
|
|
|
@ -98,9 +98,7 @@ public class CdsiStore {
|
|||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -116,7 +114,9 @@ public class CdsiStore {
|
|||
}
|
||||
|
||||
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 = (
|
||||
"""
|
||||
|
@ -135,7 +135,9 @@ public class CdsiStore {
|
|||
}
|
||||
|
||||
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 = (
|
||||
"""
|
||||
|
|
|
@ -27,7 +27,8 @@ public class LegacyRecipientStore {
|
|||
|
||||
@Override
|
||||
public List<RecipientAddress> deserialize(
|
||||
JsonParser jsonParser, DeserializationContext deserializationContext
|
||||
JsonParser jsonParser,
|
||||
DeserializationContext deserializationContext
|
||||
) throws IOException {
|
||||
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
|
||||
|
||||
|
|
|
@ -15,7 +15,8 @@ public class MergeRecipientHelper {
|
|||
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
|
||||
|
||||
|
|
|
@ -208,7 +208,8 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||
}
|
||||
|
||||
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()) {
|
||||
|
@ -238,7 +239,8 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||
}
|
||||
|
||||
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()) {
|
||||
|
@ -301,7 +303,9 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||
|
||||
@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()));
|
||||
}
|
||||
|
@ -392,7 +396,10 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||
}
|
||||
|
||||
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) {
|
||||
|
@ -614,14 +621,17 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -661,7 +671,9 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||
}
|
||||
|
||||
public void updateStorageId(
|
||||
Connection connection, RecipientId recipientId, StorageId storageId
|
||||
Connection connection,
|
||||
RecipientId recipientId,
|
||||
StorageId storageId
|
||||
) throws SQLException {
|
||||
final var sql = (
|
||||
"""
|
||||
|
@ -813,7 +825,9 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||
}
|
||||
|
||||
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 = (
|
||||
"""
|
||||
|
@ -852,7 +866,8 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||
}
|
||||
|
||||
public int removeStorageIdsFromLocalOnlyUnregisteredRecipients(
|
||||
final Connection connection, final List<StorageId> storageIds
|
||||
final Connection connection,
|
||||
final List<StorageId> storageIds
|
||||
) throws SQLException {
|
||||
final var sql = (
|
||||
"""
|
||||
|
@ -965,7 +980,8 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -977,7 +993,9 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||
}
|
||||
|
||||
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 = (
|
||||
"""
|
||||
|
@ -993,9 +1011,7 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -1009,9 +1025,7 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -1046,7 +1060,9 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||
}
|
||||
|
||||
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 = (
|
||||
"""
|
||||
|
@ -1079,7 +1095,10 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -1111,7 +1130,8 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||
}
|
||||
|
||||
private RecipientAddress resolveRecipientAddress(
|
||||
final Connection connection, final RecipientId recipientId
|
||||
final Connection connection,
|
||||
final RecipientId recipientId
|
||||
) throws SQLException {
|
||||
final var sql = (
|
||||
"""
|
||||
|
@ -1150,7 +1170,9 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||
}
|
||||
|
||||
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)
|
||||
|
@ -1168,7 +1190,9 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -1177,9 +1201,7 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||
}
|
||||
}
|
||||
|
||||
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());
|
||||
|
@ -1236,7 +1258,8 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||
}
|
||||
|
||||
private RecipientId addNewRecipient(
|
||||
final Connection connection, final RecipientAddress address
|
||||
final Connection connection,
|
||||
final RecipientAddress address
|
||||
) throws SQLException {
|
||||
final var sql = (
|
||||
"""
|
||||
|
@ -1277,7 +1300,9 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||
}
|
||||
|
||||
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 = (
|
||||
|
@ -1312,7 +1337,9 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||
}
|
||||
|
||||
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) {
|
||||
|
@ -1343,7 +1370,8 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||
}
|
||||
|
||||
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
|
||||
|
@ -1358,7 +1386,8 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||
}
|
||||
|
||||
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
|
||||
|
@ -1373,7 +1402,8 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||
}
|
||||
|
||||
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()) {
|
||||
|
@ -1394,7 +1424,8 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||
}
|
||||
|
||||
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
|
||||
|
@ -1447,7 +1478,8 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||
}
|
||||
|
||||
private ExpiringProfileKeyCredential getExpiringProfileKeyCredential(
|
||||
final Connection connection, final RecipientId recipientId
|
||||
final Connection connection,
|
||||
final RecipientId recipientId
|
||||
) throws SQLException {
|
||||
final var sql = (
|
||||
"""
|
||||
|
@ -1593,7 +1625,9 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||
public interface RecipientMergeHandler {
|
||||
|
||||
void mergeRecipients(
|
||||
final Connection connection, RecipientId recipientId, RecipientId toBeMergedRecipientId
|
||||
final Connection connection,
|
||||
RecipientId recipientId,
|
||||
RecipientId toBeMergedRecipientId
|
||||
) throws SQLException;
|
||||
}
|
||||
|
||||
|
@ -1617,7 +1651,8 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||
|
||||
@Override
|
||||
public void updateRecipientAddress(
|
||||
final RecipientId recipientId, final RecipientAddress address
|
||||
final RecipientId recipientId,
|
||||
final RecipientAddress address
|
||||
) throws SQLException {
|
||||
RecipientStore.this.updateRecipientAddress(connection, recipientId, address);
|
||||
}
|
||||
|
|
|
@ -44,7 +44,9 @@ public interface RecipientTrustedResolver {
|
|||
|
||||
@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);
|
||||
}
|
||||
|
|
|
@ -83,7 +83,10 @@ public class MessageSendLogStore implements AutoCloseable {
|
|||
}
|
||||
|
||||
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
|
||||
|
@ -111,7 +114,10 @@ public class MessageSendLogStore implements AutoCloseable {
|
|||
}
|
||||
|
||||
public long insertIfPossible(
|
||||
long sentTimestamp, SendMessageResult sendMessageResult, ContentHint contentHint, boolean urgent
|
||||
long sentTimestamp,
|
||||
SendMessageResult sendMessageResult,
|
||||
ContentHint contentHint,
|
||||
boolean urgent
|
||||
) {
|
||||
if (sendLogDisabled) {
|
||||
return -1;
|
||||
|
@ -129,7 +135,10 @@ public class MessageSendLogStore implements AutoCloseable {
|
|||
}
|
||||
|
||||
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;
|
||||
|
@ -164,7 +173,8 @@ public class MessageSendLogStore implements AutoCloseable {
|
|||
}
|
||||
|
||||
public void addRecipientToExistingEntryIfPossible(
|
||||
final long contentId, final List<SendMessageResult> sendMessageResults
|
||||
final long contentId,
|
||||
final List<SendMessageResult> sendMessageResults
|
||||
) {
|
||||
if (sendLogDisabled) {
|
||||
return;
|
||||
|
@ -322,7 +332,8 @@ public class MessageSendLogStore implements AutoCloseable {
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -334,7 +345,9 @@ public class MessageSendLogStore implements AutoCloseable {
|
|||
}
|
||||
|
||||
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)
|
||||
|
|
|
@ -59,7 +59,9 @@ public class SenderKeyRecordStore implements SenderKeyStore {
|
|||
|
||||
@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);
|
||||
|
||||
|
@ -165,7 +167,9 @@ public class SenderKeyRecordStore implements SenderKeyStore {
|
|||
}
|
||||
|
||||
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
|
||||
|
|
|
@ -65,7 +65,8 @@ public class SenderKeySharedStore {
|
|||
}
|
||||
|
||||
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()))
|
||||
|
@ -138,9 +139,7 @@ public class SenderKeySharedStore {
|
|||
}
|
||||
}
|
||||
|
||||
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 = (
|
||||
"""
|
||||
|
@ -192,7 +191,9 @@ public class SenderKeySharedStore {
|
|||
}
|
||||
|
||||
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 = (
|
||||
"""
|
||||
|
|
|
@ -25,7 +25,9 @@ public class SenderKeyStore implements SignalServiceSenderKeyStore {
|
|||
|
||||
@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);
|
||||
}
|
||||
|
@ -42,7 +44,8 @@ public class SenderKeyStore implements SignalServiceSenderKeyStore {
|
|||
|
||||
@Override
|
||||
public void markSenderKeySharedWith(
|
||||
final DistributionId distributionId, final Collection<SignalProtocolAddress> addresses
|
||||
final DistributionId distributionId,
|
||||
final Collection<SignalProtocolAddress> addresses
|
||||
) {
|
||||
senderKeySharedStore.markSenderKeySharedWith(distributionId, addresses);
|
||||
}
|
||||
|
|
|
@ -342,7 +342,9 @@ public class SessionStore implements SignalServiceSessionStore {
|
|||
}
|
||||
|
||||
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);
|
||||
|
|
|
@ -35,7 +35,9 @@ public class LegacyJsonThreadStore {
|
|||
|
||||
@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());
|
||||
}
|
||||
|
@ -45,7 +47,8 @@ public class LegacyJsonThreadStore {
|
|||
|
||||
@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);
|
||||
|
|
|
@ -33,7 +33,9 @@ public class AccountRecordProcessor extends DefaultStorageRecordProcessor<Signal
|
|||
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;
|
||||
|
|
|
@ -91,9 +91,7 @@ public class ContactRecordProcessor extends DefaultStorageRecordProcessor<Signal
|
|||
}
|
||||
|
||||
@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()) {
|
||||
|
|
|
@ -80,7 +80,9 @@ public final class StorageSyncModels {
|
|||
}
|
||||
|
||||
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,
|
||||
|
@ -121,9 +123,7 @@ public final class StorageSyncModels {
|
|||
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());
|
||||
|
@ -133,9 +133,7 @@ public final class StorageSyncModels {
|
|||
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());
|
||||
|
|
|
@ -112,13 +112,17 @@ public final class StorageSyncValidations {
|
|||
}
|
||||
|
||||
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()) {
|
||||
|
|
|
@ -13,7 +13,8 @@ import java.util.UUID;
|
|||
public class AttachmentUtils {
|
||||
|
||||
public static SignalServiceAttachmentStream createAttachmentStream(
|
||||
String attachment, ResumableUploadSpec resumableUploadSpec
|
||||
String attachment,
|
||||
ResumableUploadSpec resumableUploadSpec
|
||||
) throws AttachmentInvalidException {
|
||||
try {
|
||||
final var streamDetails = Utils.createStreamDetails(attachment);
|
||||
|
@ -25,7 +26,9 @@ public class AttachmentUtils {
|
|||
}
|
||||
|
||||
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();
|
||||
|
|
|
@ -63,7 +63,8 @@ public class KeyUtils {
|
|||
}
|
||||
|
||||
public static SignedPreKeyRecord generateSignedPreKeyRecord(
|
||||
final int signedPreKeyId, final ECPrivateKey privateKey
|
||||
final int signedPreKeyId,
|
||||
final ECPrivateKey privateKey
|
||||
) {
|
||||
var keyPair = Curve.generateKeyPair();
|
||||
byte[] signature;
|
||||
|
@ -75,9 +76,7 @@ public class KeyUtils {
|
|||
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;
|
||||
|
|
|
@ -88,7 +88,9 @@ public class NumberVerificationUtils {
|
|||
}
|
||||
|
||||
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,
|
||||
|
@ -108,7 +110,11 @@ public class NumberVerificationUtils {
|
|||
}
|
||||
|
||||
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 {
|
||||
|
@ -138,7 +144,8 @@ public class NumberVerificationUtils {
|
|||
}
|
||||
|
||||
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();
|
||||
|
@ -153,7 +160,8 @@ public class NumberVerificationUtils {
|
|||
}
|
||||
|
||||
private static RegistrationSessionMetadataResponse getValidSession(
|
||||
final RegistrationApi registrationApi, final String sessionId
|
||||
final RegistrationApi registrationApi,
|
||||
final String sessionId
|
||||
) throws IOException {
|
||||
try {
|
||||
return validateSession(registrationApi, sessionId);
|
||||
|
@ -164,7 +172,9 @@ public class NumberVerificationUtils {
|
|||
}
|
||||
|
||||
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 {
|
||||
|
@ -184,7 +194,9 @@ public class NumberVerificationUtils {
|
|||
public interface Verifier {
|
||||
|
||||
VerifyAccountResponse verify(
|
||||
String sessionId, String verificationCode, String registrationLock
|
||||
String sessionId,
|
||||
String verificationCode,
|
||||
String registrationLock
|
||||
) throws IOException;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,9 +20,7 @@ public class PaymentUtils {
|
|||
/**
|
||||
* 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(
|
||||
|
@ -34,9 +32,7 @@ public class PaymentUtils {
|
|||
* <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.");
|
||||
|
|
|
@ -23,9 +23,7 @@ public class ProfileUtils {
|
|||
|
||||
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 {
|
||||
|
@ -64,7 +62,8 @@ public class ProfileUtils {
|
|||
}
|
||||
|
||||
public static Profile.UnidentifiedAccessMode getUnidentifiedAccessMode(
|
||||
final SignalServiceProfile encryptedProfile, final ProfileCipher profileCipher
|
||||
final SignalServiceProfile encryptedProfile,
|
||||
final ProfileCipher profileCipher
|
||||
) {
|
||||
if (encryptedProfile.isUnrestrictedUnidentifiedAccess()) {
|
||||
return Profile.UnidentifiedAccessMode.UNRESTRICTED;
|
||||
|
@ -90,7 +89,8 @@ public class ProfileUtils {
|
|||
}
|
||||
|
||||
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));
|
||||
|
@ -100,7 +100,8 @@ public class ProfileUtils {
|
|||
}
|
||||
|
||||
private static Optional<Boolean> decryptBoolean(
|
||||
final String encrypted, final ProfileCipher profileCipher
|
||||
final String encrypted,
|
||||
final ProfileCipher profileCipher
|
||||
) throws InvalidCiphertextException {
|
||||
try {
|
||||
return encrypted == null
|
||||
|
@ -112,7 +113,9 @@ public class ProfileUtils {
|
|||
}
|
||||
|
||||
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 {
|
||||
|
|
|
@ -100,7 +100,9 @@ public class StickerUtils {
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -112,7 +114,9 @@ public class StickerUtils {
|
|||
}
|
||||
|
||||
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);
|
||||
|
|
|
@ -59,7 +59,10 @@ public class Utils {
|
|||
}
|
||||
|
||||
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;
|
||||
|
@ -70,7 +73,10 @@ public class Utils {
|
|||
}
|
||||
|
||||
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;
|
||||
|
|
|
@ -217,9 +217,7 @@ class MergeRecipientHelperTest {
|
|||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
|
|
|
@ -27,39 +27,44 @@ public interface Signal extends DBusInterface {
|
|||
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;
|
||||
|
@ -68,9 +73,7 @@ public interface Signal extends DBusInterface {
|
|||
|
||||
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;
|
||||
|
||||
|
@ -79,19 +82,27 @@ public interface Signal extends DBusInterface {
|
|||
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;
|
||||
|
@ -119,12 +130,17 @@ public interface Signal extends DBusInterface {
|
|||
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
|
||||
|
@ -156,7 +172,11 @@ public interface Signal extends DBusInterface {
|
|||
) 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();
|
||||
|
|
|
@ -13,11 +13,14 @@ import java.util.List;
|
|||
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;
|
||||
|
|
|
@ -292,7 +292,8 @@ public class App {
|
|||
}
|
||||
|
||||
private RegistrationManager loadRegistrationManager(
|
||||
final String account, final SignalAccountFiles signalAccountFiles
|
||||
final String account,
|
||||
final SignalAccountFiles signalAccountFiles
|
||||
) throws UnexpectedErrorException {
|
||||
try {
|
||||
return signalAccountFiles.initRegistrationManager(account);
|
||||
|
@ -306,7 +307,8 @@ public class App {
|
|||
}
|
||||
|
||||
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 {
|
||||
|
|
|
@ -101,9 +101,7 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
|||
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=");
|
||||
|
@ -197,16 +195,12 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
|||
}
|
||||
}
|
||||
|
||||
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:");
|
||||
|
@ -226,9 +220,7 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
|||
}
|
||||
}
|
||||
|
||||
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()) {
|
||||
|
@ -238,9 +230,7 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
|||
}
|
||||
}
|
||||
|
||||
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");
|
||||
|
@ -257,9 +247,7 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
|||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
@ -302,9 +290,7 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
|||
}
|
||||
}
|
||||
|
||||
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";
|
||||
|
@ -392,9 +378,7 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
|||
}
|
||||
}
|
||||
|
||||
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()));
|
||||
|
@ -405,25 +389,19 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
|||
}
|
||||
}
|
||||
|
||||
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()) {
|
||||
|
@ -541,17 +519,13 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
|||
}
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
@ -567,15 +541,11 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
|||
}
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,9 @@ public class AddDeviceCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@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 {
|
||||
|
|
|
@ -36,7 +36,9 @@ public class AddStickerPackCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@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) {
|
||||
|
|
|
@ -35,7 +35,9 @@ public class BlockCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@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());
|
||||
|
|
|
@ -20,13 +20,15 @@ public class CommandHandler {
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -36,7 +38,8 @@ public class CommandHandler {
|
|||
}
|
||||
|
||||
public void handleMultiLocalCommand(
|
||||
final MultiLocalCommand command, MultiAccountManager multiAccountManager
|
||||
final MultiLocalCommand command,
|
||||
MultiAccountManager multiAccountManager
|
||||
) throws CommandException {
|
||||
command.handleCommand(ns, multiAccountManager, outputWriter);
|
||||
}
|
||||
|
|
|
@ -92,7 +92,9 @@ public class DaemonCommand implements MultiLocalCommand, LocalCommand {
|
|||
|
||||
@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());
|
||||
|
@ -117,7 +119,9 @@ public class DaemonCommand implements MultiLocalCommand, LocalCommand {
|
|||
|
||||
@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");
|
||||
|
|
|
@ -60,7 +60,9 @@ public class DeleteLocalAccountDataCommand implements RegistrationCommand, JsonR
|
|||
|
||||
@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);
|
||||
|
|
|
@ -33,7 +33,9 @@ public class FinishChangeNumberCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@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");
|
||||
|
|
|
@ -32,7 +32,9 @@ public class FinishLinkCommand implements JsonRpcMultiCommand<FinishLinkCommand.
|
|||
|
||||
@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.");
|
||||
|
|
|
@ -35,7 +35,9 @@ public class GetAttachmentCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@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");
|
||||
|
|
|
@ -37,7 +37,9 @@ public class GetAvatarCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@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");
|
||||
|
|
|
@ -35,7 +35,9 @@ public class GetStickerCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@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")));
|
||||
|
|
|
@ -43,7 +43,9 @@ public class GetUserStatusCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@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;
|
||||
|
|
|
@ -33,7 +33,9 @@ public class JoinGroupCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@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");
|
||||
|
|
|
@ -59,7 +59,9 @@ public class JsonRpcDispatcherCommand implements LocalCommand, MultiLocalCommand
|
|||
|
||||
@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");
|
||||
|
@ -79,7 +81,9 @@ public class JsonRpcDispatcherCommand implements LocalCommand, MultiLocalCommand
|
|||
|
||||
@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");
|
||||
|
|
|
@ -18,9 +18,7 @@ public interface JsonRpcLocalCommand extends JsonRpcSingleCommand<Map<String, Ob
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,9 @@ public interface JsonRpcMultiLocalCommand extends JsonRpcMultiCommand<Map<String
|
|||
}
|
||||
|
||||
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);
|
||||
|
|
|
@ -33,7 +33,9 @@ public class LinkCommand implements ProvisioningCommand {
|
|||
|
||||
@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;
|
||||
|
||||
|
|
|
@ -23,7 +23,9 @@ public class ListAccountsCommand implements JsonRpcMultiLocalCommand {
|
|||
|
||||
@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) {
|
||||
|
|
|
@ -47,7 +47,9 @@ public class ListContactsCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@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");
|
||||
|
|
|
@ -33,7 +33,9 @@ public class ListDevicesCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@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 {
|
||||
|
|
|
@ -48,9 +48,7 @@ public class ListGroupsCommand implements JsonRpcLocalCommand {
|
|||
.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();
|
||||
|
||||
|
@ -79,7 +77,9 @@ public class ListGroupsCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@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();
|
||||
|
||||
|
|
|
@ -46,7 +46,9 @@ public class ListIdentitiesCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@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");
|
||||
|
||||
|
|
|
@ -27,7 +27,9 @@ public class ListStickerPacksCommand implements JsonRpcLocalCommand {
|
|||
|
||||
@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) {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue