Reformat files
This commit is contained in:
parent
3533500b73
commit
f2005593ec
@ -130,11 +130,15 @@ public interface Manager extends Closeable {
|
|||||||
void deleteUsername() throws IOException;
|
void deleteUsername() throws IOException;
|
||||||
|
|
||||||
void startChangeNumber(
|
void startChangeNumber(
|
||||||
String newNumber, boolean voiceVerification, String captcha
|
String newNumber,
|
||||||
|
boolean voiceVerification,
|
||||||
|
String captcha
|
||||||
) throws RateLimitException, IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, NotPrimaryDeviceException, VerificationMethodNotAvailableException;
|
) throws RateLimitException, IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, NotPrimaryDeviceException, VerificationMethodNotAvailableException;
|
||||||
|
|
||||||
void finishChangeNumber(
|
void finishChangeNumber(
|
||||||
String newNumber, String verificationCode, String pin
|
String newNumber,
|
||||||
|
String verificationCode,
|
||||||
|
String pin
|
||||||
) throws IncorrectPinException, PinLockedException, IOException, NotPrimaryDeviceException;
|
) throws IncorrectPinException, PinLockedException, IOException, NotPrimaryDeviceException;
|
||||||
|
|
||||||
void unregister() throws IOException;
|
void unregister() throws IOException;
|
||||||
@ -142,7 +146,8 @@ public interface Manager extends Closeable {
|
|||||||
void deleteAccount() throws IOException;
|
void deleteAccount() throws IOException;
|
||||||
|
|
||||||
void submitRateLimitRecaptchaChallenge(
|
void submitRateLimitRecaptchaChallenge(
|
||||||
String challenge, String captcha
|
String challenge,
|
||||||
|
String captcha
|
||||||
) throws IOException, CaptchaRejectedException;
|
) throws IOException, CaptchaRejectedException;
|
||||||
|
|
||||||
List<Device> getLinkedDevices() throws IOException;
|
List<Device> getLinkedDevices() throws IOException;
|
||||||
@ -156,17 +161,21 @@ public interface Manager extends Closeable {
|
|||||||
List<Group> getGroups();
|
List<Group> getGroups();
|
||||||
|
|
||||||
SendGroupMessageResults quitGroup(
|
SendGroupMessageResults quitGroup(
|
||||||
GroupId groupId, Set<RecipientIdentifier.Single> groupAdmins
|
GroupId groupId,
|
||||||
|
Set<RecipientIdentifier.Single> groupAdmins
|
||||||
) throws GroupNotFoundException, IOException, NotAGroupMemberException, LastGroupAdminException, UnregisteredRecipientException;
|
) throws GroupNotFoundException, IOException, NotAGroupMemberException, LastGroupAdminException, UnregisteredRecipientException;
|
||||||
|
|
||||||
void deleteGroup(GroupId groupId) throws IOException;
|
void deleteGroup(GroupId groupId) throws IOException;
|
||||||
|
|
||||||
Pair<GroupId, SendGroupMessageResults> createGroup(
|
Pair<GroupId, SendGroupMessageResults> createGroup(
|
||||||
String name, Set<RecipientIdentifier.Single> members, String avatarFile
|
String name,
|
||||||
|
Set<RecipientIdentifier.Single> members,
|
||||||
|
String avatarFile
|
||||||
) throws IOException, AttachmentInvalidException, UnregisteredRecipientException;
|
) throws IOException, AttachmentInvalidException, UnregisteredRecipientException;
|
||||||
|
|
||||||
SendGroupMessageResults updateGroup(
|
SendGroupMessageResults updateGroup(
|
||||||
final GroupId groupId, final UpdateGroup updateGroup
|
final GroupId groupId,
|
||||||
|
final UpdateGroup updateGroup
|
||||||
) throws IOException, GroupNotFoundException, AttachmentInvalidException, NotAGroupMemberException, GroupSendingNotAllowedException, UnregisteredRecipientException;
|
) throws IOException, GroupNotFoundException, AttachmentInvalidException, NotAGroupMemberException, GroupSendingNotAllowedException, UnregisteredRecipientException;
|
||||||
|
|
||||||
Pair<GroupId, SendGroupMessageResults> joinGroup(
|
Pair<GroupId, SendGroupMessageResults> joinGroup(
|
||||||
@ -174,27 +183,29 @@ public interface Manager extends Closeable {
|
|||||||
) throws IOException, InactiveGroupLinkException, PendingAdminApprovalException;
|
) throws IOException, InactiveGroupLinkException, PendingAdminApprovalException;
|
||||||
|
|
||||||
SendMessageResults sendTypingMessage(
|
SendMessageResults sendTypingMessage(
|
||||||
TypingAction action, Set<RecipientIdentifier> recipients
|
TypingAction action,
|
||||||
|
Set<RecipientIdentifier> recipients
|
||||||
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException;
|
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException;
|
||||||
|
|
||||||
SendMessageResults sendReadReceipt(
|
SendMessageResults sendReadReceipt(RecipientIdentifier.Single sender, List<Long> messageIds);
|
||||||
RecipientIdentifier.Single sender, List<Long> messageIds
|
|
||||||
);
|
|
||||||
|
|
||||||
SendMessageResults sendViewedReceipt(
|
SendMessageResults sendViewedReceipt(RecipientIdentifier.Single sender, List<Long> messageIds);
|
||||||
RecipientIdentifier.Single sender, List<Long> messageIds
|
|
||||||
);
|
|
||||||
|
|
||||||
SendMessageResults sendMessage(
|
SendMessageResults sendMessage(
|
||||||
Message message, Set<RecipientIdentifier> recipients, boolean notifySelf
|
Message message,
|
||||||
|
Set<RecipientIdentifier> recipients,
|
||||||
|
boolean notifySelf
|
||||||
) throws IOException, AttachmentInvalidException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException, UnregisteredRecipientException, InvalidStickerException;
|
) throws IOException, AttachmentInvalidException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException, UnregisteredRecipientException, InvalidStickerException;
|
||||||
|
|
||||||
SendMessageResults sendEditMessage(
|
SendMessageResults sendEditMessage(
|
||||||
Message message, Set<RecipientIdentifier> recipients, long editTargetTimestamp
|
Message message,
|
||||||
|
Set<RecipientIdentifier> recipients,
|
||||||
|
long editTargetTimestamp
|
||||||
) throws IOException, AttachmentInvalidException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException, UnregisteredRecipientException, InvalidStickerException;
|
) throws IOException, AttachmentInvalidException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException, UnregisteredRecipientException, InvalidStickerException;
|
||||||
|
|
||||||
SendMessageResults sendRemoteDeleteMessage(
|
SendMessageResults sendRemoteDeleteMessage(
|
||||||
long targetSentTimestamp, Set<RecipientIdentifier> recipients
|
long targetSentTimestamp,
|
||||||
|
Set<RecipientIdentifier> recipients
|
||||||
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException;
|
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException;
|
||||||
|
|
||||||
SendMessageResults sendMessageReaction(
|
SendMessageResults sendMessageReaction(
|
||||||
@ -207,13 +218,16 @@ public interface Manager extends Closeable {
|
|||||||
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException, UnregisteredRecipientException;
|
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException, UnregisteredRecipientException;
|
||||||
|
|
||||||
SendMessageResults sendPaymentNotificationMessage(
|
SendMessageResults sendPaymentNotificationMessage(
|
||||||
byte[] receipt, String note, RecipientIdentifier.Single recipient
|
byte[] receipt,
|
||||||
|
String note,
|
||||||
|
RecipientIdentifier.Single recipient
|
||||||
) throws IOException;
|
) throws IOException;
|
||||||
|
|
||||||
SendMessageResults sendEndSessionMessage(Set<RecipientIdentifier.Single> recipients) throws IOException;
|
SendMessageResults sendEndSessionMessage(Set<RecipientIdentifier.Single> recipients) throws IOException;
|
||||||
|
|
||||||
SendMessageResults sendMessageRequestResponse(
|
SendMessageResults sendMessageRequestResponse(
|
||||||
MessageEnvelope.Sync.MessageRequestResponse.Type type, Set<RecipientIdentifier> recipientIdentifiers
|
MessageEnvelope.Sync.MessageRequestResponse.Type type,
|
||||||
|
Set<RecipientIdentifier> recipientIdentifiers
|
||||||
);
|
);
|
||||||
|
|
||||||
void hideRecipient(RecipientIdentifier.Single recipient);
|
void hideRecipient(RecipientIdentifier.Single recipient);
|
||||||
@ -223,22 +237,27 @@ public interface Manager extends Closeable {
|
|||||||
void deleteContact(RecipientIdentifier.Single recipient);
|
void deleteContact(RecipientIdentifier.Single recipient);
|
||||||
|
|
||||||
void setContactName(
|
void setContactName(
|
||||||
RecipientIdentifier.Single recipient, String givenName, final String familyName
|
RecipientIdentifier.Single recipient,
|
||||||
|
String givenName,
|
||||||
|
final String familyName
|
||||||
) throws NotPrimaryDeviceException, UnregisteredRecipientException;
|
) throws NotPrimaryDeviceException, UnregisteredRecipientException;
|
||||||
|
|
||||||
void setContactsBlocked(
|
void setContactsBlocked(
|
||||||
Collection<RecipientIdentifier.Single> recipient, boolean blocked
|
Collection<RecipientIdentifier.Single> recipient,
|
||||||
|
boolean blocked
|
||||||
) throws NotPrimaryDeviceException, IOException, UnregisteredRecipientException;
|
) throws NotPrimaryDeviceException, IOException, UnregisteredRecipientException;
|
||||||
|
|
||||||
void setGroupsBlocked(
|
void setGroupsBlocked(
|
||||||
Collection<GroupId> groupId, boolean blocked
|
Collection<GroupId> groupId,
|
||||||
|
boolean blocked
|
||||||
) throws GroupNotFoundException, IOException, NotPrimaryDeviceException;
|
) throws GroupNotFoundException, IOException, NotPrimaryDeviceException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change the expiration timer for a contact
|
* Change the expiration timer for a contact
|
||||||
*/
|
*/
|
||||||
void setExpirationTimer(
|
void setExpirationTimer(
|
||||||
RecipientIdentifier.Single recipient, int messageExpirationTimer
|
RecipientIdentifier.Single recipient,
|
||||||
|
int messageExpirationTimer
|
||||||
) throws IOException, UnregisteredRecipientException;
|
) 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.
|
* Receive new messages from server, returns if no new message arrive in a timespan of timeout.
|
||||||
*/
|
*/
|
||||||
void receiveMessages(
|
void receiveMessages(
|
||||||
Optional<Duration> timeout, Optional<Integer> maxMessages, ReceiveMessageHandler handler
|
Optional<Duration> timeout,
|
||||||
|
Optional<Integer> maxMessages,
|
||||||
|
ReceiveMessageHandler handler
|
||||||
) throws IOException, AlreadyReceivingException;
|
) throws IOException, AlreadyReceivingException;
|
||||||
|
|
||||||
void stopReceiveMessages();
|
void stopReceiveMessages();
|
||||||
@ -309,7 +330,8 @@ public interface Manager extends Closeable {
|
|||||||
* @param recipient account of the identity
|
* @param recipient account of the identity
|
||||||
*/
|
*/
|
||||||
boolean trustIdentityVerified(
|
boolean trustIdentityVerified(
|
||||||
RecipientIdentifier.Single recipient, IdentityVerificationCode verificationCode
|
RecipientIdentifier.Single recipient,
|
||||||
|
IdentityVerificationCode verificationCode
|
||||||
) throws UnregisteredRecipientException;
|
) throws UnregisteredRecipientException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,11 +13,14 @@ import java.io.IOException;
|
|||||||
public interface RegistrationManager extends Closeable {
|
public interface RegistrationManager extends Closeable {
|
||||||
|
|
||||||
void register(
|
void register(
|
||||||
boolean voiceVerification, String captcha, final boolean forceRegister
|
boolean voiceVerification,
|
||||||
|
String captcha,
|
||||||
|
final boolean forceRegister
|
||||||
) throws IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, RateLimitException, VerificationMethodNotAvailableException;
|
) throws IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, RateLimitException, VerificationMethodNotAvailableException;
|
||||||
|
|
||||||
void verifyAccount(
|
void verifyAccount(
|
||||||
String verificationCode, String pin
|
String verificationCode,
|
||||||
|
String pin
|
||||||
) throws IOException, PinLockedException, IncorrectPinException;
|
) throws IOException, PinLockedException, IncorrectPinException;
|
||||||
|
|
||||||
void deleteLocalAccountData() throws IOException;
|
void deleteLocalAccountData() throws IOException;
|
||||||
|
@ -85,7 +85,8 @@ public class SignalAccountFiles {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Manager initManager(
|
private Manager initManager(
|
||||||
String number, String accountPath
|
String number,
|
||||||
|
String accountPath
|
||||||
) throws IOException, NotRegisteredException, AccountCheckException {
|
) throws IOException, NotRegisteredException, AccountCheckException {
|
||||||
if (accountPath == null) {
|
if (accountPath == null) {
|
||||||
throw new NotRegisteredException();
|
throw new NotRegisteredException();
|
||||||
@ -152,7 +153,8 @@ public class SignalAccountFiles {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public RegistrationManager initRegistrationManager(
|
public RegistrationManager initRegistrationManager(
|
||||||
String number, Consumer<Manager> newManagerListener
|
String number,
|
||||||
|
Consumer<Manager> newManagerListener
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
final var accountPath = accountsStore.getPathByNumber(number);
|
final var accountPath = accountsStore.getPathByNumber(number);
|
||||||
if (accountPath == null || !SignalAccount.accountFileExists(pathConfig.dataPath(), accountPath)) {
|
if (accountPath == null || !SignalAccount.accountFileExists(pathConfig.dataPath(), accountPath)) {
|
||||||
|
@ -13,7 +13,9 @@ public class ResendMessageAction implements HandleAction {
|
|||||||
private final MessageSendLogEntry messageSendLogEntry;
|
private final MessageSendLogEntry messageSendLogEntry;
|
||||||
|
|
||||||
public ResendMessageAction(
|
public ResendMessageAction(
|
||||||
final RecipientId recipientId, final long timestamp, final MessageSendLogEntry messageSendLogEntry
|
final RecipientId recipientId,
|
||||||
|
final long timestamp,
|
||||||
|
final MessageSendLogEntry messageSendLogEntry
|
||||||
) {
|
) {
|
||||||
this.recipientId = recipientId;
|
this.recipientId = recipientId;
|
||||||
this.timestamp = timestamp;
|
this.timestamp = timestamp;
|
||||||
|
@ -15,7 +15,9 @@ public class SendReceiptAction implements HandleAction {
|
|||||||
private final List<Long> timestamps = new ArrayList<>();
|
private final List<Long> timestamps = new ArrayList<>();
|
||||||
|
|
||||||
public SendReceiptAction(
|
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.recipientId = recipientId;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
@ -27,7 +27,9 @@ public record Group(
|
|||||||
) {
|
) {
|
||||||
|
|
||||||
public static Group from(
|
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(),
|
return new Group(groupInfo.getGroupId(),
|
||||||
groupInfo.getTitle(),
|
groupInfo.getTitle(),
|
||||||
|
@ -338,7 +338,8 @@ public record MessageEnvelope(
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Attachment from(
|
static Attachment from(
|
||||||
SignalServiceDataMessage.Quote.QuotedAttachment a, final AttachmentFileProvider fileProvider
|
SignalServiceDataMessage.Quote.QuotedAttachment a,
|
||||||
|
final AttachmentFileProvider fileProvider
|
||||||
) {
|
) {
|
||||||
return new Attachment(Optional.empty(),
|
return new Attachment(Optional.empty(),
|
||||||
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) {
|
public record Preview(String title, String description, long date, String url, Optional<Attachment> image) {
|
||||||
|
|
||||||
static Preview from(
|
static Preview from(SignalServicePreview preview, final AttachmentFileProvider fileProvider) {
|
||||||
SignalServicePreview preview, final AttachmentFileProvider fileProvider
|
|
||||||
) {
|
|
||||||
return new Preview(preview.getTitle(),
|
return new Preview(preview.getTitle(),
|
||||||
preview.getDescription(),
|
preview.getDescription(),
|
||||||
preview.getDate(),
|
preview.getDate(),
|
||||||
@ -832,9 +831,7 @@ public record MessageEnvelope(
|
|||||||
Optional<TextAttachment> textAttachment
|
Optional<TextAttachment> textAttachment
|
||||||
) {
|
) {
|
||||||
|
|
||||||
public static Story from(
|
public static Story from(SignalServiceStoryMessage storyMessage, final AttachmentFileProvider fileProvider) {
|
||||||
SignalServiceStoryMessage storyMessage, final AttachmentFileProvider fileProvider
|
|
||||||
) {
|
|
||||||
return new Story(storyMessage.getAllowsReplies().orElse(false),
|
return new Story(storyMessage.getAllowsReplies().orElse(false),
|
||||||
storyMessage.getGroupContext().map(c -> GroupUtils.getGroupIdV2(c.getMasterKey())),
|
storyMessage.getGroupContext().map(c -> GroupUtils.getGroupIdV2(c.getMasterKey())),
|
||||||
storyMessage.getFileAttachment().map(f -> Data.Attachment.from(f, fileProvider)),
|
storyMessage.getFileAttachment().map(f -> Data.Attachment.from(f, fileProvider)),
|
||||||
@ -852,7 +849,8 @@ public record MessageEnvelope(
|
|||||||
) {
|
) {
|
||||||
|
|
||||||
static TextAttachment from(
|
static TextAttachment from(
|
||||||
SignalServiceTextAttachment textAttachment, final AttachmentFileProvider fileProvider
|
SignalServiceTextAttachment textAttachment,
|
||||||
|
final AttachmentFileProvider fileProvider
|
||||||
) {
|
) {
|
||||||
return new TextAttachment(textAttachment.getText(),
|
return new TextAttachment(textAttachment.getText(),
|
||||||
textAttachment.getStyle().map(Style::from),
|
textAttachment.getStyle().map(Style::from),
|
||||||
|
@ -33,7 +33,8 @@ public class ServiceConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ServiceEnvironmentConfig getServiceEnvironmentConfig(
|
public static ServiceEnvironmentConfig getServiceEnvironmentConfig(
|
||||||
ServiceEnvironment serviceEnvironment, String userAgent
|
ServiceEnvironment serviceEnvironment,
|
||||||
|
String userAgent
|
||||||
) {
|
) {
|
||||||
final Interceptor userAgentInterceptor = chain -> chain.proceed(chain.request()
|
final Interceptor userAgentInterceptor = chain -> chain.proceed(chain.request()
|
||||||
.newBuilder()
|
.newBuilder()
|
||||||
|
@ -18,7 +18,8 @@ import org.whispersystems.signalservice.api.messages.SignalServiceGroupV2;
|
|||||||
public class GroupUtils {
|
public class GroupUtils {
|
||||||
|
|
||||||
public static void setGroupContext(
|
public static void setGroupContext(
|
||||||
final SignalServiceDataMessage.Builder messageBuilder, final GroupInfo groupInfo
|
final SignalServiceDataMessage.Builder messageBuilder,
|
||||||
|
final GroupInfo groupInfo
|
||||||
) {
|
) {
|
||||||
if (groupInfo instanceof GroupInfoV1) {
|
if (groupInfo instanceof GroupInfoV1) {
|
||||||
var group = SignalServiceGroup.newBuilder(SignalServiceGroup.Type.DELIVER)
|
var group = SignalServiceGroup.newBuilder(SignalServiceGroup.Type.DELIVER)
|
||||||
|
@ -165,7 +165,9 @@ public class AccountHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void startChangeNumber(
|
public void startChangeNumber(
|
||||||
String newNumber, boolean voiceVerification, String captcha
|
String newNumber,
|
||||||
|
boolean voiceVerification,
|
||||||
|
String captcha
|
||||||
) throws IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, RateLimitException, VerificationMethodNotAvailableException {
|
) throws IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, RateLimitException, VerificationMethodNotAvailableException {
|
||||||
final var accountManager = dependencies.createUnauthenticatedAccountManager(newNumber, account.getPassword());
|
final var accountManager = dependencies.createUnauthenticatedAccountManager(newNumber, account.getPassword());
|
||||||
final var registrationApi = accountManager.getRegistrationApi();
|
final var registrationApi = accountManager.getRegistrationApi();
|
||||||
@ -178,7 +180,9 @@ public class AccountHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void finishChangeNumber(
|
public void finishChangeNumber(
|
||||||
String newNumber, String verificationCode, String pin
|
String newNumber,
|
||||||
|
String verificationCode,
|
||||||
|
String pin
|
||||||
) throws IncorrectPinException, PinLockedException, IOException {
|
) throws IncorrectPinException, PinLockedException, IOException {
|
||||||
for (var attempts = 0; attempts < 5; attempts++) {
|
for (var attempts = 0; attempts < 5; attempts++) {
|
||||||
try {
|
try {
|
||||||
@ -196,7 +200,9 @@ public class AccountHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void finishChangeNumberInternal(
|
private void finishChangeNumberInternal(
|
||||||
String newNumber, String verificationCode, String pin
|
String newNumber,
|
||||||
|
String verificationCode,
|
||||||
|
String pin
|
||||||
) throws IncorrectPinException, PinLockedException, IOException {
|
) throws IncorrectPinException, PinLockedException, IOException {
|
||||||
final var pniIdentity = KeyUtils.generateIdentityKeyPair();
|
final var pniIdentity = KeyUtils.generateIdentityKeyPair();
|
||||||
final var encryptedDeviceMessages = new ArrayList<OutgoingPushMessage>();
|
final var encryptedDeviceMessages = new ArrayList<OutgoingPushMessage>();
|
||||||
@ -308,9 +314,7 @@ public class AccountHelper {
|
|||||||
handlePniChangeNumberMessage(selfChangeNumber, updatePni);
|
handlePniChangeNumberMessage(selfChangeNumber, updatePni);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handlePniChangeNumberMessage(
|
public void handlePniChangeNumberMessage(final SyncMessage.PniChangeNumber pniChangeNumber, final PNI updatedPni) {
|
||||||
final SyncMessage.PniChangeNumber pniChangeNumber, final PNI updatedPni
|
|
||||||
) {
|
|
||||||
if (pniChangeNumber.identityKeyPair != null
|
if (pniChangeNumber.identityKeyPair != null
|
||||||
&& pniChangeNumber.registrationId != null
|
&& pniChangeNumber.registrationId != null
|
||||||
&& pniChangeNumber.signedPreKey != null) {
|
&& pniChangeNumber.signedPreKey != null) {
|
||||||
|
@ -104,9 +104,7 @@ public class AttachmentHelper {
|
|||||||
retrieveAttachment(attachment, input -> IOUtils.copyStream(input, outputStream));
|
retrieveAttachment(attachment, input -> IOUtils.copyStream(input, outputStream));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void retrieveAttachment(
|
public void retrieveAttachment(SignalServiceAttachment attachment, AttachmentHandler consumer) throws IOException {
|
||||||
SignalServiceAttachment attachment, AttachmentHandler consumer
|
|
||||||
) throws IOException {
|
|
||||||
if (attachment.isStream()) {
|
if (attachment.isStream()) {
|
||||||
var input = attachment.asStream().getInputStream();
|
var input = attachment.asStream().getInputStream();
|
||||||
// don't close input stream here, it might be reused later (e.g. with contact sync messages ...)
|
// 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(
|
private InputStream retrieveAttachmentAsStream(
|
||||||
SignalServiceAttachmentPointer pointer, File tmpFile
|
SignalServiceAttachmentPointer pointer,
|
||||||
|
File tmpFile
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
try {
|
try {
|
||||||
return dependencies.getMessageReceiver()
|
return dependencies.getMessageReceiver()
|
||||||
|
@ -49,7 +49,9 @@ public class ContactHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setExpirationTimer(
|
public void setExpirationTimer(
|
||||||
RecipientId recipientId, int messageExpirationTimer, int messageExpirationTimerVersion
|
RecipientId recipientId,
|
||||||
|
int messageExpirationTimer,
|
||||||
|
int messageExpirationTimerVersion
|
||||||
) {
|
) {
|
||||||
var contact = account.getContactStore().getContact(recipientId);
|
var contact = account.getContactStore().getContact(recipientId);
|
||||||
if (contact != null && (
|
if (contact != null && (
|
||||||
|
@ -118,7 +118,9 @@ public class GroupHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public GroupInfoV2 getOrMigrateGroup(
|
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);
|
final var groupSecretParams = GroupSecretParams.deriveFromMasterKey(groupMasterKey);
|
||||||
|
|
||||||
@ -166,7 +168,8 @@ public class GroupHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private DecryptedGroup handleDecryptedGroupResponse(
|
private DecryptedGroup handleDecryptedGroupResponse(
|
||||||
GroupInfoV2 groupInfoV2, final DecryptedGroupResponse decryptedGroupResponse
|
GroupInfoV2 groupInfoV2,
|
||||||
|
final DecryptedGroupResponse decryptedGroupResponse
|
||||||
) {
|
) {
|
||||||
final var groupSecretParams = GroupSecretParams.deriveFromMasterKey(groupInfoV2.getMasterKey());
|
final var groupSecretParams = GroupSecretParams.deriveFromMasterKey(groupInfoV2.getMasterKey());
|
||||||
ReceivedGroupSendEndorsements groupSendEndorsements = dependencies.getGroupsV2Operations()
|
ReceivedGroupSendEndorsements groupSendEndorsements = dependencies.getGroupsV2Operations()
|
||||||
@ -181,7 +184,8 @@ public class GroupHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private GroupChange handleGroupChangeResponse(
|
private GroupChange handleGroupChangeResponse(
|
||||||
final GroupInfoV2 groupInfoV2, final GroupChangeResponse groupChangeResponse
|
final GroupInfoV2 groupInfoV2,
|
||||||
|
final GroupChangeResponse groupChangeResponse
|
||||||
) {
|
) {
|
||||||
ReceivedGroupSendEndorsements groupSendEndorsements = dependencies.getGroupsV2Operations()
|
ReceivedGroupSendEndorsements groupSendEndorsements = dependencies.getGroupsV2Operations()
|
||||||
.forGroup(GroupSecretParams.deriveFromMasterKey(groupInfoV2.getMasterKey()))
|
.forGroup(GroupSecretParams.deriveFromMasterKey(groupInfoV2.getMasterKey()))
|
||||||
@ -195,7 +199,9 @@ public class GroupHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Pair<GroupId, SendGroupMessageResults> createGroup(
|
public Pair<GroupId, SendGroupMessageResults> createGroup(
|
||||||
String name, Set<RecipientId> members, String avatarFile
|
String name,
|
||||||
|
Set<RecipientId> members,
|
||||||
|
String avatarFile
|
||||||
) throws IOException, AttachmentInvalidException {
|
) throws IOException, AttachmentInvalidException {
|
||||||
final var selfRecipientId = account.getSelfRecipientId();
|
final var selfRecipientId = account.getSelfRecipientId();
|
||||||
if (members != null && members.contains(selfRecipientId)) {
|
if (members != null && members.contains(selfRecipientId)) {
|
||||||
@ -363,7 +369,8 @@ public class GroupHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public SendGroupMessageResults quitGroup(
|
public SendGroupMessageResults quitGroup(
|
||||||
final GroupId groupId, final Set<RecipientId> newAdmins
|
final GroupId groupId,
|
||||||
|
final Set<RecipientId> newAdmins
|
||||||
) throws IOException, LastGroupAdminException, NotAGroupMemberException, GroupNotFoundException {
|
) throws IOException, LastGroupAdminException, NotAGroupMemberException, GroupNotFoundException {
|
||||||
var group = getGroupForUpdating(groupId);
|
var group = getGroupForUpdating(groupId);
|
||||||
if (group instanceof GroupInfoV1) {
|
if (group instanceof GroupInfoV1) {
|
||||||
@ -396,9 +403,7 @@ public class GroupHelper {
|
|||||||
context.getJobExecutor().enqueueJob(new SyncStorageJob());
|
context.getJobExecutor().enqueueJob(new SyncStorageJob());
|
||||||
}
|
}
|
||||||
|
|
||||||
public SendGroupMessageResults sendGroupInfoRequest(
|
public SendGroupMessageResults sendGroupInfoRequest(GroupIdV1 groupId, RecipientId recipientId) throws IOException {
|
||||||
GroupIdV1 groupId, RecipientId recipientId
|
|
||||||
) throws IOException {
|
|
||||||
var group = SignalServiceGroup.newBuilder(SignalServiceGroup.Type.REQUEST_INFO).withId(groupId.serialize());
|
var group = SignalServiceGroup.newBuilder(SignalServiceGroup.Type.REQUEST_INFO).withId(groupId.serialize());
|
||||||
|
|
||||||
var messageBuilder = SignalServiceDataMessage.newBuilder().asGroupMessage(group.build());
|
var messageBuilder = SignalServiceDataMessage.newBuilder().asGroupMessage(group.build());
|
||||||
@ -408,7 +413,8 @@ public class GroupHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public SendGroupMessageResults sendGroupInfoMessage(
|
public SendGroupMessageResults sendGroupInfoMessage(
|
||||||
GroupIdV1 groupId, RecipientId recipientId
|
GroupIdV1 groupId,
|
||||||
|
RecipientId recipientId
|
||||||
) throws IOException, NotAGroupMemberException, GroupNotFoundException, AttachmentInvalidException {
|
) throws IOException, NotAGroupMemberException, GroupNotFoundException, AttachmentInvalidException {
|
||||||
GroupInfoV1 g;
|
GroupInfoV1 g;
|
||||||
var group = getGroupForUpdating(groupId);
|
var group = getGroupForUpdating(groupId);
|
||||||
@ -480,7 +486,9 @@ public class GroupHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void retrieveGroupV2Avatar(
|
private void retrieveGroupV2Avatar(
|
||||||
GroupSecretParams groupSecretParams, String cdnKey, OutputStream outputStream
|
GroupSecretParams groupSecretParams,
|
||||||
|
String cdnKey,
|
||||||
|
OutputStream outputStream
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
var groupOperations = dependencies.getGroupsV2Operations().forGroup(groupSecretParams);
|
var groupOperations = dependencies.getGroupsV2Operations().forGroup(groupSecretParams);
|
||||||
|
|
||||||
@ -583,7 +591,10 @@ public class GroupHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private SendGroupMessageResults updateGroupV1(
|
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 {
|
) throws IOException, AttachmentInvalidException {
|
||||||
updateGroupV1Details(gv1, name, members, avatarFile);
|
updateGroupV1Details(gv1, name, members, avatarFile);
|
||||||
|
|
||||||
@ -596,7 +607,10 @@ public class GroupHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateGroupV1Details(
|
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 {
|
) throws IOException {
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
g.name = name;
|
g.name = name;
|
||||||
@ -615,7 +629,8 @@ public class GroupHelper {
|
|||||||
* Change the expiration timer for a group
|
* Change the expiration timer for a group
|
||||||
*/
|
*/
|
||||||
private void setExpirationTimer(
|
private void setExpirationTimer(
|
||||||
GroupInfoV1 groupInfoV1, int messageExpirationTimer
|
GroupInfoV1 groupInfoV1,
|
||||||
|
int messageExpirationTimer
|
||||||
) throws NotAGroupMemberException, GroupNotFoundException, IOException, GroupSendingNotAllowedException {
|
) throws NotAGroupMemberException, GroupNotFoundException, IOException, GroupSendingNotAllowedException {
|
||||||
groupInfoV1.messageExpirationTime = messageExpirationTimer;
|
groupInfoV1.messageExpirationTime = messageExpirationTimer;
|
||||||
account.getGroupStore().updateGroup(groupInfoV1);
|
account.getGroupStore().updateGroup(groupInfoV1);
|
||||||
@ -828,7 +843,8 @@ public class GroupHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private SendGroupMessageResults quitGroupV2(
|
private SendGroupMessageResults quitGroupV2(
|
||||||
final GroupInfoV2 groupInfoV2, final Set<RecipientId> newAdmins
|
final GroupInfoV2 groupInfoV2,
|
||||||
|
final Set<RecipientId> newAdmins
|
||||||
) throws LastGroupAdminException, IOException {
|
) throws LastGroupAdminException, IOException {
|
||||||
final var currentAdmins = groupInfoV2.getAdminMembers();
|
final var currentAdmins = groupInfoV2.getAdminMembers();
|
||||||
newAdmins.removeAll(currentAdmins);
|
newAdmins.removeAll(currentAdmins);
|
||||||
@ -882,7 +898,9 @@ public class GroupHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private SendGroupMessageResults sendUpdateGroupV2Message(
|
private SendGroupMessageResults sendUpdateGroupV2Message(
|
||||||
GroupInfoV2 group, DecryptedGroup newDecryptedGroup, GroupChange groupChange
|
GroupInfoV2 group,
|
||||||
|
DecryptedGroup newDecryptedGroup,
|
||||||
|
GroupChange groupChange
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
final var selfRecipientId = account.getSelfRecipientId();
|
final var selfRecipientId = account.getSelfRecipientId();
|
||||||
final var members = group.getMembersIncludingPendingWithout(selfRecipientId);
|
final var members = group.getMembersIncludingPendingWithout(selfRecipientId);
|
||||||
|
@ -94,7 +94,8 @@ class GroupV2Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DecryptedGroupJoinInfo getDecryptedGroupJoinInfo(
|
DecryptedGroupJoinInfo getDecryptedGroupJoinInfo(
|
||||||
GroupMasterKey groupMasterKey, GroupLinkPassword password
|
GroupMasterKey groupMasterKey,
|
||||||
|
GroupLinkPassword password
|
||||||
) throws IOException, GroupLinkNotActiveException {
|
) throws IOException, GroupLinkNotActiveException {
|
||||||
var groupSecretParams = GroupSecretParams.deriveFromMasterKey(groupMasterKey);
|
var groupSecretParams = GroupSecretParams.deriveFromMasterKey(groupMasterKey);
|
||||||
|
|
||||||
@ -105,7 +106,9 @@ class GroupV2Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GroupHistoryPage getDecryptedGroupHistoryPage(
|
GroupHistoryPage getDecryptedGroupHistoryPage(
|
||||||
final GroupSecretParams groupSecretParams, int fromRevision, long sendEndorsementsExpirationMs
|
final GroupSecretParams groupSecretParams,
|
||||||
|
int fromRevision,
|
||||||
|
long sendEndorsementsExpirationMs
|
||||||
) throws NotAGroupMemberException {
|
) throws NotAGroupMemberException {
|
||||||
try {
|
try {
|
||||||
final var groupsV2AuthorizationString = getGroupAuthForToday(groupSecretParams);
|
final var groupsV2AuthorizationString = getGroupAuthForToday(groupSecretParams);
|
||||||
@ -138,9 +141,7 @@ class GroupV2Helper {
|
|||||||
return partialDecryptedGroup.revision;
|
return partialDecryptedGroup.revision;
|
||||||
}
|
}
|
||||||
|
|
||||||
Pair<GroupInfoV2, DecryptedGroupResponse> createGroup(
|
Pair<GroupInfoV2, DecryptedGroupResponse> createGroup(String name, Set<RecipientId> members, byte[] avatarFile) {
|
||||||
String name, Set<RecipientId> members, byte[] avatarFile
|
|
||||||
) {
|
|
||||||
final var newGroup = buildNewGroup(name, members, avatarFile);
|
final var newGroup = buildNewGroup(name, members, avatarFile);
|
||||||
if (newGroup == null) {
|
if (newGroup == null) {
|
||||||
return null;
|
return null;
|
||||||
@ -170,9 +171,7 @@ class GroupV2Helper {
|
|||||||
return new Pair<>(g, response);
|
return new Pair<>(g, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
private GroupsV2Operations.NewGroup buildNewGroup(
|
private GroupsV2Operations.NewGroup buildNewGroup(String name, Set<RecipientId> members, byte[] avatar) {
|
||||||
String name, Set<RecipientId> members, byte[] avatar
|
|
||||||
) {
|
|
||||||
final var profileKeyCredential = context.getProfileHelper()
|
final var profileKeyCredential = context.getProfileHelper()
|
||||||
.getExpiringProfileKeyCredential(context.getAccount().getSelfRecipientId());
|
.getExpiringProfileKeyCredential(context.getAccount().getSelfRecipientId());
|
||||||
if (profileKeyCredential == null) {
|
if (profileKeyCredential == null) {
|
||||||
@ -202,7 +201,10 @@ class GroupV2Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Pair<DecryptedGroup, GroupChangeResponse> updateGroup(
|
Pair<DecryptedGroup, GroupChangeResponse> updateGroup(
|
||||||
GroupInfoV2 groupInfoV2, String name, String description, byte[] avatarFile
|
GroupInfoV2 groupInfoV2,
|
||||||
|
String name,
|
||||||
|
String description,
|
||||||
|
byte[] avatarFile
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
final var groupSecretParams = GroupSecretParams.deriveFromMasterKey(groupInfoV2.getMasterKey());
|
final var groupSecretParams = GroupSecretParams.deriveFromMasterKey(groupInfoV2.getMasterKey());
|
||||||
var groupOperations = dependencies.getGroupsV2Operations().forGroup(groupSecretParams);
|
var groupOperations = dependencies.getGroupsV2Operations().forGroup(groupSecretParams);
|
||||||
@ -225,7 +227,8 @@ class GroupV2Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Pair<DecryptedGroup, GroupChangeResponse> addMembers(
|
Pair<DecryptedGroup, GroupChangeResponse> addMembers(
|
||||||
GroupInfoV2 groupInfoV2, Set<RecipientId> newMembers
|
GroupInfoV2 groupInfoV2,
|
||||||
|
Set<RecipientId> newMembers
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
||||||
|
|
||||||
@ -251,7 +254,8 @@ class GroupV2Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Pair<DecryptedGroup, GroupChangeResponse> leaveGroup(
|
Pair<DecryptedGroup, GroupChangeResponse> leaveGroup(
|
||||||
GroupInfoV2 groupInfoV2, Set<RecipientId> membersToMakeAdmin
|
GroupInfoV2 groupInfoV2,
|
||||||
|
Set<RecipientId> membersToMakeAdmin
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
var pendingMembersList = groupInfoV2.getGroup().pendingMembers;
|
var pendingMembersList = groupInfoV2.getGroup().pendingMembers;
|
||||||
final var selfAci = getSelfAci();
|
final var selfAci = getSelfAci();
|
||||||
@ -271,7 +275,8 @@ class GroupV2Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Pair<DecryptedGroup, GroupChangeResponse> removeMembers(
|
Pair<DecryptedGroup, GroupChangeResponse> removeMembers(
|
||||||
GroupInfoV2 groupInfoV2, Set<RecipientId> members
|
GroupInfoV2 groupInfoV2,
|
||||||
|
Set<RecipientId> members
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
final var memberUuids = members.stream()
|
final var memberUuids = members.stream()
|
||||||
.map(context.getRecipientHelper()::resolveSignalServiceAddress)
|
.map(context.getRecipientHelper()::resolveSignalServiceAddress)
|
||||||
@ -283,7 +288,8 @@ class GroupV2Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Pair<DecryptedGroup, GroupChangeResponse> approveJoinRequestMembers(
|
Pair<DecryptedGroup, GroupChangeResponse> approveJoinRequestMembers(
|
||||||
GroupInfoV2 groupInfoV2, Set<RecipientId> members
|
GroupInfoV2 groupInfoV2,
|
||||||
|
Set<RecipientId> members
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
final var memberUuids = members.stream()
|
final var memberUuids = members.stream()
|
||||||
.map(context.getRecipientHelper()::resolveSignalServiceAddress)
|
.map(context.getRecipientHelper()::resolveSignalServiceAddress)
|
||||||
@ -294,7 +300,8 @@ class GroupV2Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Pair<DecryptedGroup, GroupChangeResponse> refuseJoinRequestMembers(
|
Pair<DecryptedGroup, GroupChangeResponse> refuseJoinRequestMembers(
|
||||||
GroupInfoV2 groupInfoV2, Set<RecipientId> members
|
GroupInfoV2 groupInfoV2,
|
||||||
|
Set<RecipientId> members
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
final var memberUuids = members.stream()
|
final var memberUuids = members.stream()
|
||||||
.map(context.getRecipientHelper()::resolveSignalServiceAddress)
|
.map(context.getRecipientHelper()::resolveSignalServiceAddress)
|
||||||
@ -304,7 +311,8 @@ class GroupV2Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Pair<DecryptedGroup, GroupChangeResponse> revokeInvitedMembers(
|
Pair<DecryptedGroup, GroupChangeResponse> revokeInvitedMembers(
|
||||||
GroupInfoV2 groupInfoV2, Set<RecipientId> members
|
GroupInfoV2 groupInfoV2,
|
||||||
|
Set<RecipientId> members
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
var pendingMembersList = groupInfoV2.getGroup().pendingMembers;
|
var pendingMembersList = groupInfoV2.getGroup().pendingMembers;
|
||||||
final var memberUuids = members.stream()
|
final var memberUuids = members.stream()
|
||||||
@ -318,7 +326,8 @@ class GroupV2Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Pair<DecryptedGroup, GroupChangeResponse> banMembers(
|
Pair<DecryptedGroup, GroupChangeResponse> banMembers(
|
||||||
GroupInfoV2 groupInfoV2, Set<RecipientId> block
|
GroupInfoV2 groupInfoV2,
|
||||||
|
Set<RecipientId> block
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
||||||
|
|
||||||
@ -336,7 +345,8 @@ class GroupV2Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Pair<DecryptedGroup, GroupChangeResponse> unbanMembers(
|
Pair<DecryptedGroup, GroupChangeResponse> unbanMembers(
|
||||||
GroupInfoV2 groupInfoV2, Set<RecipientId> block
|
GroupInfoV2 groupInfoV2,
|
||||||
|
Set<RecipientId> block
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
||||||
|
|
||||||
@ -359,7 +369,8 @@ class GroupV2Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Pair<DecryptedGroup, GroupChangeResponse> setGroupLinkState(
|
Pair<DecryptedGroup, GroupChangeResponse> setGroupLinkState(
|
||||||
GroupInfoV2 groupInfoV2, GroupLinkState state
|
GroupInfoV2 groupInfoV2,
|
||||||
|
GroupLinkState state
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
||||||
|
|
||||||
@ -374,7 +385,8 @@ class GroupV2Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Pair<DecryptedGroup, GroupChangeResponse> setEditDetailsPermission(
|
Pair<DecryptedGroup, GroupChangeResponse> setEditDetailsPermission(
|
||||||
GroupInfoV2 groupInfoV2, GroupPermission permission
|
GroupInfoV2 groupInfoV2,
|
||||||
|
GroupPermission permission
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
||||||
|
|
||||||
@ -384,7 +396,8 @@ class GroupV2Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Pair<DecryptedGroup, GroupChangeResponse> setAddMemberPermission(
|
Pair<DecryptedGroup, GroupChangeResponse> setAddMemberPermission(
|
||||||
GroupInfoV2 groupInfoV2, GroupPermission permission
|
GroupInfoV2 groupInfoV2,
|
||||||
|
GroupPermission permission
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
||||||
|
|
||||||
@ -468,7 +481,9 @@ class GroupV2Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Pair<DecryptedGroup, GroupChangeResponse> setMemberAdmin(
|
Pair<DecryptedGroup, GroupChangeResponse> setMemberAdmin(
|
||||||
GroupInfoV2 groupInfoV2, RecipientId recipientId, boolean admin
|
GroupInfoV2 groupInfoV2,
|
||||||
|
RecipientId recipientId,
|
||||||
|
boolean admin
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
||||||
final var address = context.getRecipientHelper().resolveSignalServiceAddress(recipientId);
|
final var address = context.getRecipientHelper().resolveSignalServiceAddress(recipientId);
|
||||||
@ -482,7 +497,8 @@ class GroupV2Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Pair<DecryptedGroup, GroupChangeResponse> setMessageExpirationTimer(
|
Pair<DecryptedGroup, GroupChangeResponse> setMessageExpirationTimer(
|
||||||
GroupInfoV2 groupInfoV2, int messageExpirationTimer
|
GroupInfoV2 groupInfoV2,
|
||||||
|
int messageExpirationTimer
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
||||||
final var change = groupOperations.createModifyGroupTimerChange(messageExpirationTimer);
|
final var change = groupOperations.createModifyGroupTimerChange(messageExpirationTimer);
|
||||||
@ -490,7 +506,8 @@ class GroupV2Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Pair<DecryptedGroup, GroupChangeResponse> setIsAnnouncementGroup(
|
Pair<DecryptedGroup, GroupChangeResponse> setIsAnnouncementGroup(
|
||||||
GroupInfoV2 groupInfoV2, boolean isAnnouncementGroup
|
GroupInfoV2 groupInfoV2,
|
||||||
|
boolean isAnnouncementGroup
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
||||||
final var change = groupOperations.createAnnouncementGroupChange(isAnnouncementGroup);
|
final var change = groupOperations.createAnnouncementGroupChange(isAnnouncementGroup);
|
||||||
@ -518,7 +535,8 @@ class GroupV2Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Pair<DecryptedGroup, GroupChangeResponse> revokeInvites(
|
private Pair<DecryptedGroup, GroupChangeResponse> revokeInvites(
|
||||||
GroupInfoV2 groupInfoV2, Set<DecryptedPendingMember> pendingMembers
|
GroupInfoV2 groupInfoV2,
|
||||||
|
Set<DecryptedPendingMember> pendingMembers
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
||||||
final var uuidCipherTexts = pendingMembers.stream().map(member -> {
|
final var uuidCipherTexts = pendingMembers.stream().map(member -> {
|
||||||
@ -532,28 +550,32 @@ class GroupV2Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Pair<DecryptedGroup, GroupChangeResponse> approveJoinRequest(
|
private Pair<DecryptedGroup, GroupChangeResponse> approveJoinRequest(
|
||||||
GroupInfoV2 groupInfoV2, Set<UUID> uuids
|
GroupInfoV2 groupInfoV2,
|
||||||
|
Set<UUID> uuids
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
||||||
return commitChange(groupInfoV2, groupOperations.createApproveGroupJoinRequest(uuids));
|
return commitChange(groupInfoV2, groupOperations.createApproveGroupJoinRequest(uuids));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Pair<DecryptedGroup, GroupChangeResponse> refuseJoinRequest(
|
private Pair<DecryptedGroup, GroupChangeResponse> refuseJoinRequest(
|
||||||
GroupInfoV2 groupInfoV2, Set<ServiceId> serviceIds
|
GroupInfoV2 groupInfoV2,
|
||||||
|
Set<ServiceId> serviceIds
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
||||||
return commitChange(groupInfoV2, groupOperations.createRefuseGroupJoinRequest(serviceIds, false, List.of()));
|
return commitChange(groupInfoV2, groupOperations.createRefuseGroupJoinRequest(serviceIds, false, List.of()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Pair<DecryptedGroup, GroupChangeResponse> ejectMembers(
|
private Pair<DecryptedGroup, GroupChangeResponse> ejectMembers(
|
||||||
GroupInfoV2 groupInfoV2, Set<ACI> members
|
GroupInfoV2 groupInfoV2,
|
||||||
|
Set<ACI> members
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
final GroupsV2Operations.GroupOperations groupOperations = getGroupOperations(groupInfoV2);
|
||||||
return commitChange(groupInfoV2, groupOperations.createRemoveMembersChange(members, false, List.of()));
|
return commitChange(groupInfoV2, groupOperations.createRemoveMembersChange(members, false, List.of()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Pair<DecryptedGroup, GroupChangeResponse> commitChange(
|
private Pair<DecryptedGroup, GroupChangeResponse> commitChange(
|
||||||
GroupInfoV2 groupInfoV2, GroupChange.Actions.Builder change
|
GroupInfoV2 groupInfoV2,
|
||||||
|
GroupChange.Actions.Builder change
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
final var groupSecretParams = GroupSecretParams.deriveFromMasterKey(groupInfoV2.getMasterKey());
|
final var groupSecretParams = GroupSecretParams.deriveFromMasterKey(groupInfoV2.getMasterKey());
|
||||||
final var groupOperations = dependencies.getGroupsV2Operations().forGroup(groupSecretParams);
|
final var groupOperations = dependencies.getGroupsV2Operations().forGroup(groupSecretParams);
|
||||||
@ -676,7 +698,8 @@ class GroupV2Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private GroupsV2AuthorizationString getAuthorizationString(
|
private GroupsV2AuthorizationString getAuthorizationString(
|
||||||
final GroupSecretParams groupSecretParams, final long todaySeconds
|
final GroupSecretParams groupSecretParams,
|
||||||
|
final long todaySeconds
|
||||||
) throws VerificationFailedException {
|
) throws VerificationFailedException {
|
||||||
var authCredentialResponse = groupApiCredentials.get(todaySeconds);
|
var authCredentialResponse = groupApiCredentials.get(todaySeconds);
|
||||||
final var aci = getSelfAci();
|
final var aci = getSelfAci();
|
||||||
|
@ -66,9 +66,7 @@ public class IdentityHelper {
|
|||||||
return fingerprint == null ? null : fingerprint.getScannableFingerprint();
|
return fingerprint == null ? null : fingerprint.getScannableFingerprint();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Fingerprint computeSafetyNumberFingerprint(
|
private Fingerprint computeSafetyNumberFingerprint(final ServiceId serviceId, final IdentityKey theirIdentityKey) {
|
||||||
final ServiceId serviceId, final IdentityKey theirIdentityKey
|
|
||||||
) {
|
|
||||||
if (!serviceId.isUnknown()) {
|
if (!serviceId.isUnknown()) {
|
||||||
return Utils.computeSafetyNumberForUuid(account.getAci(),
|
return Utils.computeSafetyNumberForUuid(account.getAci(),
|
||||||
account.getAciIdentityKeyPair().getPublicKey(),
|
account.getAciIdentityKeyPair().getPublicKey(),
|
||||||
@ -89,7 +87,9 @@ public class IdentityHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean trustIdentity(
|
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 address = account.getRecipientAddressResolver().resolveRecipientAddress(recipientId);
|
||||||
final var serviceId = address.serviceId().orElse(null);
|
final var serviceId = address.serviceId().orElse(null);
|
||||||
|
@ -190,7 +190,9 @@ public final class IncomingMessageHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private SignalServiceContent validate(
|
private SignalServiceContent validate(
|
||||||
Envelope envelope, SignalServiceCipherResult cipherResult, long serverDeliveredTimestamp
|
Envelope envelope,
|
||||||
|
SignalServiceCipherResult cipherResult,
|
||||||
|
long serverDeliveredTimestamp
|
||||||
) throws ProtocolInvalidKeyException, ProtocolInvalidMessageException, UnsupportedDataMessageException, InvalidMessageStructureException {
|
) throws ProtocolInvalidKeyException, ProtocolInvalidMessageException, UnsupportedDataMessageException, InvalidMessageStructureException {
|
||||||
final var content = cipherResult.getContent();
|
final var content = cipherResult.getContent();
|
||||||
final var envelopeMetadata = cipherResult.getMetadata();
|
final var envelopeMetadata = cipherResult.getMetadata();
|
||||||
@ -280,7 +282,9 @@ public final class IncomingMessageHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<HandleAction> handleMessage(
|
public List<HandleAction> handleMessage(
|
||||||
SignalServiceEnvelope envelope, SignalServiceContent content, ReceiveConfig receiveConfig
|
SignalServiceEnvelope envelope,
|
||||||
|
SignalServiceContent content,
|
||||||
|
ReceiveConfig receiveConfig
|
||||||
) {
|
) {
|
||||||
var actions = new ArrayList<HandleAction>();
|
var actions = new ArrayList<HandleAction>();
|
||||||
final var senderDeviceAddress = getSender(envelope, content);
|
final var senderDeviceAddress = getSender(envelope, content);
|
||||||
@ -381,7 +385,8 @@ public final class IncomingMessageHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean handlePniSignatureMessage(
|
private boolean handlePniSignatureMessage(
|
||||||
final SignalServicePniSignatureMessage message, final SignalServiceAddress senderAddress
|
final SignalServicePniSignatureMessage message,
|
||||||
|
final SignalServiceAddress senderAddress
|
||||||
) {
|
) {
|
||||||
final var aci = senderAddress.getServiceId();
|
final var aci = senderAddress.getServiceId();
|
||||||
final var aciIdentity = account.getIdentityKeyStore().getIdentityInfo(aci);
|
final var aciIdentity = account.getIdentityKeyStore().getIdentityInfo(aci);
|
||||||
@ -865,7 +870,9 @@ public final class IncomingMessageHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<HandleAction> handleSignalServiceStoryMessage(
|
private List<HandleAction> handleSignalServiceStoryMessage(
|
||||||
SignalServiceStoryMessage message, RecipientId source, boolean ignoreAttachments
|
SignalServiceStoryMessage message,
|
||||||
|
RecipientId source,
|
||||||
|
boolean ignoreAttachments
|
||||||
) {
|
) {
|
||||||
var actions = new ArrayList<HandleAction>();
|
var actions = new ArrayList<HandleAction>();
|
||||||
if (message.getGroupContext().isPresent()) {
|
if (message.getGroupContext().isPresent()) {
|
||||||
|
@ -21,9 +21,7 @@ public class PinHelper {
|
|||||||
this.secureValueRecoveries = secureValueRecoveries;
|
this.secureValueRecoveries = secureValueRecoveries;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRegistrationLockPin(
|
public void setRegistrationLockPin(String pin, MasterKey masterKey) throws IOException {
|
||||||
String pin, MasterKey masterKey
|
|
||||||
) throws IOException {
|
|
||||||
IOException exception = null;
|
IOException exception = null;
|
||||||
for (final var secureValueRecovery : secureValueRecoveries) {
|
for (final var secureValueRecovery : secureValueRecoveries) {
|
||||||
try {
|
try {
|
||||||
@ -82,7 +80,8 @@ public class PinHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public SecureValueRecovery.RestoreResponse.Success getRegistrationLockData(
|
public SecureValueRecovery.RestoreResponse.Success getRegistrationLockData(
|
||||||
String pin, LockedException lockedException
|
String pin,
|
||||||
|
LockedException lockedException
|
||||||
) throws IOException, IncorrectPinException {
|
) throws IOException, IncorrectPinException {
|
||||||
var svr2Credentials = lockedException.getSvr2Credentials();
|
var svr2Credentials = lockedException.getSvr2Credentials();
|
||||||
if (svr2Credentials != null) {
|
if (svr2Credentials != null) {
|
||||||
@ -103,7 +102,9 @@ public class PinHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public SecureValueRecovery.RestoreResponse.Success getRegistrationLockData(
|
public SecureValueRecovery.RestoreResponse.Success getRegistrationLockData(
|
||||||
SecureValueRecovery secureValueRecovery, AuthCredentials authCredentials, String pin
|
SecureValueRecovery secureValueRecovery,
|
||||||
|
AuthCredentials authCredentials,
|
||||||
|
String pin
|
||||||
) throws IOException, IncorrectPinException {
|
) throws IOException, IncorrectPinException {
|
||||||
final var restoreResponse = secureValueRecovery.restoreDataPreRegistration(authCredentials, null, pin);
|
final var restoreResponse = secureValueRecovery.restoreDataPreRegistration(authCredentials, null, pin);
|
||||||
|
|
||||||
|
@ -30,9 +30,7 @@ public class PreKeyHelper {
|
|||||||
private final SignalAccount account;
|
private final SignalAccount account;
|
||||||
private final SignalDependencies dependencies;
|
private final SignalDependencies dependencies;
|
||||||
|
|
||||||
public PreKeyHelper(
|
public PreKeyHelper(final SignalAccount account, final SignalDependencies dependencies) {
|
||||||
final SignalAccount account, final SignalDependencies dependencies
|
|
||||||
) {
|
|
||||||
this.account = account;
|
this.account = account;
|
||||||
this.dependencies = dependencies;
|
this.dependencies = dependencies;
|
||||||
}
|
}
|
||||||
@ -79,7 +77,8 @@ public class PreKeyHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean refreshPreKeysIfNecessary(
|
private boolean refreshPreKeysIfNecessary(
|
||||||
final ServiceIdType serviceIdType, final IdentityKeyPair identityKeyPair
|
final ServiceIdType serviceIdType,
|
||||||
|
final IdentityKeyPair identityKeyPair
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
OneTimePreKeyCounts preKeyCounts;
|
OneTimePreKeyCounts preKeyCounts;
|
||||||
try {
|
try {
|
||||||
@ -221,7 +220,8 @@ public class PreKeyHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<KyberPreKeyRecord> generateKyberPreKeys(
|
private List<KyberPreKeyRecord> generateKyberPreKeys(
|
||||||
ServiceIdType serviceIdType, final IdentityKeyPair identityKeyPair
|
ServiceIdType serviceIdType,
|
||||||
|
final IdentityKeyPair identityKeyPair
|
||||||
) {
|
) {
|
||||||
final var accountData = account.getAccountData(serviceIdType);
|
final var accountData = account.getAccountData(serviceIdType);
|
||||||
final var offset = accountData.getPreKeyMetadata().getNextKyberPreKeyId();
|
final var offset = accountData.getPreKeyMetadata().getNextKyberPreKeyId();
|
||||||
@ -246,7 +246,9 @@ public class PreKeyHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private KyberPreKeyRecord generateLastResortKyberPreKey(
|
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 accountData = account.getAccountData(serviceIdType);
|
||||||
final var signedPreKeyId = accountData.getPreKeyMetadata().getNextKyberPreKeyId() + offset;
|
final var signedPreKeyId = accountData.getPreKeyMetadata().getNextKyberPreKeyId() + offset;
|
||||||
|
@ -271,7 +271,9 @@ public final class ProfileHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Profile decryptProfileAndDownloadAvatar(
|
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();
|
final var avatarPath = encryptedProfile.getAvatar();
|
||||||
downloadProfileAvatar(recipientId, avatarPath, profileKey);
|
downloadProfileAvatar(recipientId, avatarPath, profileKey);
|
||||||
@ -280,7 +282,9 @@ public final class ProfileHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void downloadProfileAvatar(
|
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);
|
var profile = account.getProfileStore().getProfile(recipientId);
|
||||||
if (profile == null || !Objects.equals(avatarPath, profile.getAvatarUrlPath())) {
|
if (profile == null || !Objects.equals(avatarPath, profile.getAvatarUrlPath())) {
|
||||||
@ -308,7 +312,8 @@ public final class ProfileHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Single<ProfileAndCredential> retrieveProfile(
|
private Single<ProfileAndCredential> retrieveProfile(
|
||||||
RecipientId recipientId, SignalServiceProfile.RequestType requestType
|
RecipientId recipientId,
|
||||||
|
SignalServiceProfile.RequestType requestType
|
||||||
) {
|
) {
|
||||||
var unidentifiedAccess = getUnidentifiedAccess(recipientId);
|
var unidentifiedAccess = getUnidentifiedAccess(recipientId);
|
||||||
var profileKey = Optional.ofNullable(account.getProfileStore().getProfileKey(recipientId));
|
var profileKey = Optional.ofNullable(account.getProfileStore().getProfileKey(recipientId));
|
||||||
@ -408,9 +413,7 @@ public final class ProfileHelper {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void downloadProfileAvatar(
|
private void downloadProfileAvatar(RecipientAddress address, String avatarPath, ProfileKey profileKey) {
|
||||||
RecipientAddress address, String avatarPath, ProfileKey profileKey
|
|
||||||
) {
|
|
||||||
if (avatarPath == null) {
|
if (avatarPath == null) {
|
||||||
try {
|
try {
|
||||||
context.getAvatarStore().deleteProfileAvatar(address);
|
context.getAvatarStore().deleteProfileAvatar(address);
|
||||||
@ -430,7 +433,9 @@ public final class ProfileHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void retrieveProfileAvatar(
|
private void retrieveProfileAvatar(
|
||||||
String avatarPath, ProfileKey profileKey, OutputStream outputStream
|
String avatarPath,
|
||||||
|
ProfileKey profileKey,
|
||||||
|
OutputStream outputStream
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
var tmpFile = IOUtils.createTempFile();
|
var tmpFile = IOUtils.createTempFile();
|
||||||
try (var input = dependencies.getMessageReceiver()
|
try (var input = dependencies.getMessageReceiver()
|
||||||
|
@ -83,7 +83,10 @@ public class ReceiveHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void receiveMessages(
|
public void receiveMessages(
|
||||||
Duration timeout, boolean returnOnTimeout, Integer maxMessages, Manager.ReceiveMessageHandler handler
|
Duration timeout,
|
||||||
|
boolean returnOnTimeout,
|
||||||
|
Integer maxMessages,
|
||||||
|
Manager.ReceiveMessageHandler handler
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
account.setNeedsToRetryFailedMessages(true);
|
account.setNeedsToRetryFailedMessages(true);
|
||||||
hasCaughtUpWithOldMessages = false;
|
hasCaughtUpWithOldMessages = false;
|
||||||
@ -264,7 +267,8 @@ public class ReceiveHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<HandleAction> retryFailedReceivedMessage(
|
private List<HandleAction> retryFailedReceivedMessage(
|
||||||
final Manager.ReceiveMessageHandler handler, final CachedMessage cachedMessage
|
final Manager.ReceiveMessageHandler handler,
|
||||||
|
final CachedMessage cachedMessage
|
||||||
) {
|
) {
|
||||||
var envelope = cachedMessage.loadEnvelope();
|
var envelope = cachedMessage.loadEnvelope();
|
||||||
if (envelope == null) {
|
if (envelope == null) {
|
||||||
|
@ -97,7 +97,8 @@ public class RecipientHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public RecipientId resolveRecipientByUsernameOrLink(
|
public RecipientId resolveRecipientByUsernameOrLink(
|
||||||
String username, boolean forceRefresh
|
String username,
|
||||||
|
boolean forceRefresh
|
||||||
) throws UnregisteredRecipientException {
|
) throws UnregisteredRecipientException {
|
||||||
final Username finalUsername;
|
final Username finalUsername;
|
||||||
try {
|
try {
|
||||||
@ -180,7 +181,8 @@ public class RecipientHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, RegisteredUser> getRegisteredUsers(
|
private Map<String, RegisteredUser> getRegisteredUsers(
|
||||||
final Set<String> numbers, final boolean isPartialRefresh
|
final Set<String> numbers,
|
||||||
|
final boolean isPartialRefresh
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
Map<String, RegisteredUser> registeredUsers = getRegisteredUsersV2(numbers, isPartialRefresh);
|
Map<String, RegisteredUser> registeredUsers = getRegisteredUsersV2(numbers, isPartialRefresh);
|
||||||
|
|
||||||
@ -211,7 +213,8 @@ public class RecipientHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, RegisteredUser> getRegisteredUsersV2(
|
private Map<String, RegisteredUser> getRegisteredUsersV2(
|
||||||
final Set<String> numbers, boolean isPartialRefresh
|
final Set<String> numbers,
|
||||||
|
boolean isPartialRefresh
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
final var previousNumbers = isPartialRefresh ? Set.<String>of() : account.getCdsiStore().getAllNumbers();
|
final var previousNumbers = isPartialRefresh ? Set.<String>of() : account.getCdsiStore().getAllNumbers();
|
||||||
final var newNumbers = new HashSet<>(numbers) {{
|
final var newNumbers = new HashSet<>(numbers) {{
|
||||||
|
@ -125,7 +125,8 @@ public class SendHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public SendMessageResult sendReceiptMessage(
|
public SendMessageResult sendReceiptMessage(
|
||||||
final SignalServiceReceiptMessage receiptMessage, final RecipientId recipientId
|
final SignalServiceReceiptMessage receiptMessage,
|
||||||
|
final RecipientId recipientId
|
||||||
) {
|
) {
|
||||||
final var messageSendLogStore = account.getMessageSendLogStore();
|
final var messageSendLogStore = account.getMessageSendLogStore();
|
||||||
final var result = handleSendMessage(recipientId,
|
final var result = handleSendMessage(recipientId,
|
||||||
@ -157,7 +158,9 @@ public class SendHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public SendMessageResult sendRetryReceipt(
|
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: {}",
|
logger.debug("Sending retry receipt for {} to {}, device: {}",
|
||||||
errorMessage.getTimestamp(),
|
errorMessage.getTimestamp(),
|
||||||
@ -183,7 +186,8 @@ public class SendHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public SendMessageResult sendSelfMessage(
|
public SendMessageResult sendSelfMessage(
|
||||||
SignalServiceDataMessage.Builder messageBuilder, Optional<Long> editTargetTimestamp
|
SignalServiceDataMessage.Builder messageBuilder,
|
||||||
|
Optional<Long> editTargetTimestamp
|
||||||
) {
|
) {
|
||||||
final var recipientId = account.getSelfRecipientId();
|
final var recipientId = account.getSelfRecipientId();
|
||||||
final var contact = account.getContactStore().getContact(recipientId);
|
final var contact = account.getContactStore().getContact(recipientId);
|
||||||
@ -214,9 +218,7 @@ public class SendHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SendMessageResult sendTypingMessage(
|
public SendMessageResult sendTypingMessage(SignalServiceTypingMessage message, RecipientId recipientId) {
|
||||||
SignalServiceTypingMessage message, RecipientId recipientId
|
|
||||||
) {
|
|
||||||
final var result = handleSendMessage(recipientId,
|
final var result = handleSendMessage(recipientId,
|
||||||
(messageSender, address, unidentifiedAccess, includePniSignature) -> messageSender.sendTyping(List.of(
|
(messageSender, address, unidentifiedAccess, includePniSignature) -> messageSender.sendTyping(List.of(
|
||||||
address), List.of(unidentifiedAccess), message, null).getFirst());
|
address), List.of(unidentifiedAccess), message, null).getFirst());
|
||||||
@ -225,7 +227,8 @@ public class SendHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<SendMessageResult> sendGroupTypingMessage(
|
public List<SendMessageResult> sendGroupTypingMessage(
|
||||||
SignalServiceTypingMessage message, GroupId groupId
|
SignalServiceTypingMessage message,
|
||||||
|
GroupId groupId
|
||||||
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException {
|
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException {
|
||||||
final var g = getGroupForSending(groupId);
|
final var g = getGroupForSending(groupId);
|
||||||
if (g.isAnnouncementGroup() && !g.isAdmin(account.getSelfRecipientId())) {
|
if (g.isAnnouncementGroup() && !g.isAdmin(account.getSelfRecipientId())) {
|
||||||
@ -238,7 +241,9 @@ public class SendHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public SendMessageResult resendMessage(
|
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);
|
logger.trace("Resending message {} to {}", timestamp, recipientId);
|
||||||
if (messageSendLogEntry.groupId().isEmpty()) {
|
if (messageSendLogEntry.groupId().isEmpty()) {
|
||||||
@ -552,7 +557,9 @@ public class SendHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<SendMessageResult> sendGroupMessageInternalWithLegacy(
|
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 {
|
) throws IOException {
|
||||||
final var recipientIdList = new ArrayList<>(recipientIds);
|
final var recipientIdList = new ArrayList<>(recipientIds);
|
||||||
final var addresses = recipientIdList.stream()
|
final var addresses = recipientIdList.stream()
|
||||||
@ -644,7 +651,9 @@ public class SendHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private SendMessageResult sendMessage(
|
private SendMessageResult sendMessage(
|
||||||
SignalServiceDataMessage message, RecipientId recipientId, Optional<Long> editTargetTimestamp
|
SignalServiceDataMessage message,
|
||||||
|
RecipientId recipientId,
|
||||||
|
Optional<Long> editTargetTimestamp
|
||||||
) {
|
) {
|
||||||
final var messageSendLogStore = account.getMessageSendLogStore();
|
final var messageSendLogStore = account.getMessageSendLogStore();
|
||||||
final var urgent = true;
|
final var urgent = true;
|
||||||
|
@ -30,7 +30,9 @@ public class StickerHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public StickerPack addOrUpdateStickerPack(
|
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);
|
final var sticker = account.getStickerStore().getStickerPack(stickerPackId);
|
||||||
if (sticker != null) {
|
if (sticker != null) {
|
||||||
@ -50,7 +52,8 @@ public class StickerHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public JsonStickerPack getOrRetrieveStickerPack(
|
public JsonStickerPack getOrRetrieveStickerPack(
|
||||||
StickerPackId packId, byte[] packKey
|
StickerPackId packId,
|
||||||
|
byte[] packKey
|
||||||
) throws InvalidStickerException {
|
) throws InvalidStickerException {
|
||||||
try {
|
try {
|
||||||
retrieveStickerPack(packId, packKey);
|
retrieveStickerPack(packId, packKey);
|
||||||
|
@ -218,7 +218,9 @@ public class StorageHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean writeToStorage(
|
private boolean writeToStorage(
|
||||||
final StorageKey storageKey, final SignalStorageManifest remoteManifest, final boolean needsForcePush
|
final StorageKey storageKey,
|
||||||
|
final SignalStorageManifest remoteManifest,
|
||||||
|
final boolean needsForcePush
|
||||||
) throws IOException, RetryLaterException {
|
) throws IOException, RetryLaterException {
|
||||||
final WriteOperationResult remoteWriteOperation;
|
final WriteOperationResult remoteWriteOperation;
|
||||||
try (final var connection = account.getAccountDatabase().getConnection()) {
|
try (final var connection = account.getAccountDatabase().getConnection()) {
|
||||||
@ -408,7 +410,8 @@ public class StorageHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<SignalStorageRecord> getSignalStorageRecords(
|
private List<SignalStorageRecord> getSignalStorageRecords(
|
||||||
final StorageKey storageKey, final List<StorageId> storageIds
|
final StorageKey storageKey,
|
||||||
|
final List<StorageId> storageIds
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
List<SignalStorageRecord> records;
|
List<SignalStorageRecord> records;
|
||||||
try {
|
try {
|
||||||
@ -430,7 +433,8 @@ public class StorageHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<SignalStorageRecord> buildLocalStorageRecords(
|
private List<SignalStorageRecord> buildLocalStorageRecords(
|
||||||
final Connection connection, final List<StorageId> storageIds
|
final Connection connection,
|
||||||
|
final List<StorageId> storageIds
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
final var records = new ArrayList<SignalStorageRecord>();
|
final var records = new ArrayList<SignalStorageRecord>();
|
||||||
for (final var storageId : storageIds) {
|
for (final var storageId : storageIds) {
|
||||||
@ -443,7 +447,8 @@ public class StorageHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private SignalStorageRecord buildLocalStorageRecord(
|
private SignalStorageRecord buildLocalStorageRecord(
|
||||||
Connection connection, StorageId storageId
|
Connection connection,
|
||||||
|
StorageId storageId
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
return switch (ManifestRecord.Identifier.Type.fromValue(storageId.getType())) {
|
return switch (ManifestRecord.Identifier.Type.fromValue(storageId.getType())) {
|
||||||
case ManifestRecord.Identifier.Type.CONTACT -> {
|
case ManifestRecord.Identifier.Type.CONTACT -> {
|
||||||
@ -484,7 +489,8 @@ public class StorageHelper {
|
|||||||
* exclusive to the local data set.
|
* exclusive to the local data set.
|
||||||
*/
|
*/
|
||||||
private static IdDifferenceResult findIdDifference(
|
private static IdDifferenceResult findIdDifference(
|
||||||
Collection<StorageId> remoteIds, Collection<StorageId> localIds
|
Collection<StorageId> remoteIds,
|
||||||
|
Collection<StorageId> localIds
|
||||||
) {
|
) {
|
||||||
final var base64Encoder = Base64.getEncoder();
|
final var base64Encoder = Base64.getEncoder();
|
||||||
final var remoteByRawId = remoteIds.stream()
|
final var remoteByRawId = remoteIds.stream()
|
||||||
@ -520,7 +526,8 @@ public class StorageHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<StorageId> processKnownRecords(
|
private List<StorageId> processKnownRecords(
|
||||||
final Connection connection, List<SignalStorageRecord> records
|
final Connection connection,
|
||||||
|
List<SignalStorageRecord> records
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
final var unknownRecords = new ArrayList<StorageId>();
|
final var unknownRecords = new ArrayList<StorageId>();
|
||||||
|
|
||||||
|
@ -217,7 +217,9 @@ public class SyncHelper {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private DeviceContact getDeviceContact(
|
private DeviceContact getDeviceContact(
|
||||||
final RecipientAddress address, final RecipientId recipientId, final Contact contact
|
final RecipientAddress address,
|
||||||
|
final RecipientId recipientId,
|
||||||
|
final Contact contact
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
var currentIdentity = address.serviceId().isEmpty()
|
var currentIdentity = address.serviceId().isEmpty()
|
||||||
? null
|
? null
|
||||||
@ -262,7 +264,9 @@ public class SyncHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public SendMessageResult sendVerifiedMessage(
|
public SendMessageResult sendVerifiedMessage(
|
||||||
SignalServiceAddress destination, IdentityKey identityKey, TrustLevel trustLevel
|
SignalServiceAddress destination,
|
||||||
|
IdentityKey identityKey,
|
||||||
|
TrustLevel trustLevel
|
||||||
) {
|
) {
|
||||||
var verifiedMessage = new VerifiedMessage(destination,
|
var verifiedMessage = new VerifiedMessage(destination,
|
||||||
identityKey,
|
identityKey,
|
||||||
@ -278,7 +282,8 @@ public class SyncHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public SendMessageResult sendStickerOperationsMessage(
|
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 installStickerMessages = installStickers.stream().map(s -> getStickerPackOperationMessage(s, true));
|
||||||
var removeStickerMessages = removeStickers.stream().map(s -> getStickerPackOperationMessage(s, false));
|
var removeStickerMessages = removeStickers.stream().map(s -> getStickerPackOperationMessage(s, false));
|
||||||
@ -288,7 +293,8 @@ public class SyncHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static StickerPackOperationMessage getStickerPackOperationMessage(
|
private static StickerPackOperationMessage getStickerPackOperationMessage(
|
||||||
final StickerPack s, final boolean installed
|
final StickerPack s,
|
||||||
|
final boolean installed
|
||||||
) {
|
) {
|
||||||
return new StickerPackOperationMessage(s.packId().serialize(),
|
return new StickerPackOperationMessage(s.packId().serialize(),
|
||||||
s.packKey(),
|
s.packKey(),
|
||||||
@ -414,15 +420,14 @@ public class SyncHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SendMessageResult sendMessageRequestResponse(
|
public SendMessageResult sendMessageRequestResponse(final MessageRequestResponse.Type type, final GroupId groupId) {
|
||||||
final MessageRequestResponse.Type type, final GroupId groupId
|
|
||||||
) {
|
|
||||||
final var response = MessageRequestResponseMessage.forGroup(groupId.serialize(), localToRemoteType(type));
|
final var response = MessageRequestResponseMessage.forGroup(groupId.serialize(), localToRemoteType(type));
|
||||||
return context.getSendHelper().sendSyncMessage(SignalServiceSyncMessage.forMessageRequestResponse(response));
|
return context.getSendHelper().sendSyncMessage(SignalServiceSyncMessage.forMessageRequestResponse(response));
|
||||||
}
|
}
|
||||||
|
|
||||||
public SendMessageResult sendMessageRequestResponse(
|
public SendMessageResult sendMessageRequestResponse(
|
||||||
final MessageRequestResponse.Type type, final RecipientId recipientId
|
final MessageRequestResponse.Type type,
|
||||||
|
final RecipientId recipientId
|
||||||
) {
|
) {
|
||||||
final var address = account.getRecipientAddressResolver().resolveRecipientAddress(recipientId);
|
final var address = account.getRecipientAddressResolver().resolveRecipientAddress(recipientId);
|
||||||
if (address.serviceId().isEmpty()) {
|
if (address.serviceId().isEmpty()) {
|
||||||
|
@ -158,7 +158,8 @@ public class UnidentifiedAccessHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static byte[] getTargetUnidentifiedAccessKey(
|
private static byte[] getTargetUnidentifiedAccessKey(
|
||||||
final Profile targetProfile, final ProfileKey theirProfileKey
|
final Profile targetProfile,
|
||||||
|
final ProfileKey theirProfileKey
|
||||||
) {
|
) {
|
||||||
return switch (targetProfile.getUnidentifiedAccessMode()) {
|
return switch (targetProfile.getUnidentifiedAccessMode()) {
|
||||||
case ENABLED -> theirProfileKey == null ? null : UnidentifiedAccess.deriveAccessKeyFrom(theirProfileKey);
|
case ENABLED -> theirProfileKey == null ? null : UnidentifiedAccess.deriveAccessKeyFrom(theirProfileKey);
|
||||||
|
@ -417,7 +417,9 @@ public class ManagerImpl implements Manager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startChangeNumber(
|
public void startChangeNumber(
|
||||||
String newNumber, boolean voiceVerification, String captcha
|
String newNumber,
|
||||||
|
boolean voiceVerification,
|
||||||
|
String captcha
|
||||||
) throws RateLimitException, IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, NotPrimaryDeviceException, VerificationMethodNotAvailableException {
|
) throws RateLimitException, IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, NotPrimaryDeviceException, VerificationMethodNotAvailableException {
|
||||||
if (!account.isPrimaryDevice()) {
|
if (!account.isPrimaryDevice()) {
|
||||||
throw new NotPrimaryDeviceException();
|
throw new NotPrimaryDeviceException();
|
||||||
@ -427,7 +429,9 @@ public class ManagerImpl implements Manager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void finishChangeNumber(
|
public void finishChangeNumber(
|
||||||
String newNumber, String verificationCode, String pin
|
String newNumber,
|
||||||
|
String verificationCode,
|
||||||
|
String pin
|
||||||
) throws IncorrectPinException, PinLockedException, IOException, NotPrimaryDeviceException {
|
) throws IncorrectPinException, PinLockedException, IOException, NotPrimaryDeviceException {
|
||||||
if (!account.isPrimaryDevice()) {
|
if (!account.isPrimaryDevice()) {
|
||||||
throw new NotPrimaryDeviceException();
|
throw new NotPrimaryDeviceException();
|
||||||
@ -447,7 +451,8 @@ public class ManagerImpl implements Manager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void submitRateLimitRecaptchaChallenge(
|
public void submitRateLimitRecaptchaChallenge(
|
||||||
String challenge, String captcha
|
String challenge,
|
||||||
|
String captcha
|
||||||
) throws IOException, CaptchaRejectedException {
|
) throws IOException, CaptchaRejectedException {
|
||||||
captcha = captcha == null ? null : captcha.replace("signalcaptcha://", "");
|
captcha = captcha == null ? null : captcha.replace("signalcaptcha://", "");
|
||||||
|
|
||||||
@ -527,7 +532,8 @@ public class ManagerImpl implements Manager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SendGroupMessageResults quitGroup(
|
public SendGroupMessageResults quitGroup(
|
||||||
GroupId groupId, Set<RecipientIdentifier.Single> groupAdmins
|
GroupId groupId,
|
||||||
|
Set<RecipientIdentifier.Single> groupAdmins
|
||||||
) throws GroupNotFoundException, IOException, NotAGroupMemberException, LastGroupAdminException, UnregisteredRecipientException {
|
) throws GroupNotFoundException, IOException, NotAGroupMemberException, LastGroupAdminException, UnregisteredRecipientException {
|
||||||
final var newAdmins = context.getRecipientHelper().resolveRecipients(groupAdmins);
|
final var newAdmins = context.getRecipientHelper().resolveRecipients(groupAdmins);
|
||||||
return context.getGroupHelper().quitGroup(groupId, newAdmins);
|
return context.getGroupHelper().quitGroup(groupId, newAdmins);
|
||||||
@ -545,7 +551,9 @@ public class ManagerImpl implements Manager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Pair<GroupId, SendGroupMessageResults> createGroup(
|
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 {
|
) throws IOException, AttachmentInvalidException, UnregisteredRecipientException {
|
||||||
return context.getGroupHelper()
|
return context.getGroupHelper()
|
||||||
.createGroup(name,
|
.createGroup(name,
|
||||||
@ -555,7 +563,8 @@ public class ManagerImpl implements Manager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SendGroupMessageResults updateGroup(
|
public SendGroupMessageResults updateGroup(
|
||||||
final GroupId groupId, final UpdateGroup updateGroup
|
final GroupId groupId,
|
||||||
|
final UpdateGroup updateGroup
|
||||||
) throws IOException, GroupNotFoundException, AttachmentInvalidException, NotAGroupMemberException, GroupSendingNotAllowedException, UnregisteredRecipientException {
|
) throws IOException, GroupNotFoundException, AttachmentInvalidException, NotAGroupMemberException, GroupSendingNotAllowedException, UnregisteredRecipientException {
|
||||||
return context.getGroupHelper()
|
return context.getGroupHelper()
|
||||||
.updateGroup(groupId,
|
.updateGroup(groupId,
|
||||||
@ -596,7 +605,9 @@ public class ManagerImpl implements Manager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private SendMessageResults sendMessage(
|
private SendMessageResults sendMessage(
|
||||||
SignalServiceDataMessage.Builder messageBuilder, Set<RecipientIdentifier> recipients, boolean notifySelf
|
SignalServiceDataMessage.Builder messageBuilder,
|
||||||
|
Set<RecipientIdentifier> recipients,
|
||||||
|
boolean notifySelf
|
||||||
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException {
|
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException {
|
||||||
return sendMessage(messageBuilder, recipients, notifySelf, Optional.empty());
|
return sendMessage(messageBuilder, recipients, notifySelf, Optional.empty());
|
||||||
}
|
}
|
||||||
@ -644,7 +655,8 @@ public class ManagerImpl implements Manager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private SendMessageResults sendTypingMessage(
|
private SendMessageResults sendTypingMessage(
|
||||||
SignalServiceTypingMessage.Action action, Set<RecipientIdentifier> recipients
|
SignalServiceTypingMessage.Action action,
|
||||||
|
Set<RecipientIdentifier> recipients
|
||||||
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException {
|
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException {
|
||||||
var results = new HashMap<RecipientIdentifier, List<SendMessageResult>>();
|
var results = new HashMap<RecipientIdentifier, List<SendMessageResult>>();
|
||||||
final var timestamp = System.currentTimeMillis();
|
final var timestamp = System.currentTimeMillis();
|
||||||
@ -671,15 +683,14 @@ public class ManagerImpl implements Manager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SendMessageResults sendTypingMessage(
|
public SendMessageResults sendTypingMessage(
|
||||||
TypingAction action, Set<RecipientIdentifier> recipients
|
TypingAction action,
|
||||||
|
Set<RecipientIdentifier> recipients
|
||||||
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException {
|
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException {
|
||||||
return sendTypingMessage(action.toSignalService(), recipients);
|
return sendTypingMessage(action.toSignalService(), recipients);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SendMessageResults sendReadReceipt(
|
public SendMessageResults sendReadReceipt(RecipientIdentifier.Single sender, List<Long> messageIds) {
|
||||||
RecipientIdentifier.Single sender, List<Long> messageIds
|
|
||||||
) {
|
|
||||||
final var timestamp = System.currentTimeMillis();
|
final var timestamp = System.currentTimeMillis();
|
||||||
var receiptMessage = new SignalServiceReceiptMessage(SignalServiceReceiptMessage.Type.READ,
|
var receiptMessage = new SignalServiceReceiptMessage(SignalServiceReceiptMessage.Type.READ,
|
||||||
messageIds,
|
messageIds,
|
||||||
@ -689,9 +700,7 @@ public class ManagerImpl implements Manager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SendMessageResults sendViewedReceipt(
|
public SendMessageResults sendViewedReceipt(RecipientIdentifier.Single sender, List<Long> messageIds) {
|
||||||
RecipientIdentifier.Single sender, List<Long> messageIds
|
|
||||||
) {
|
|
||||||
final var timestamp = System.currentTimeMillis();
|
final var timestamp = System.currentTimeMillis();
|
||||||
var receiptMessage = new SignalServiceReceiptMessage(SignalServiceReceiptMessage.Type.VIEWED,
|
var receiptMessage = new SignalServiceReceiptMessage(SignalServiceReceiptMessage.Type.VIEWED,
|
||||||
messageIds,
|
messageIds,
|
||||||
@ -724,7 +733,9 @@ public class ManagerImpl implements Manager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SendMessageResults sendMessage(
|
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 {
|
) throws IOException, AttachmentInvalidException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException, UnregisteredRecipientException, InvalidStickerException {
|
||||||
final var selfProfile = context.getProfileHelper().getSelfProfile();
|
final var selfProfile = context.getProfileHelper().getSelfProfile();
|
||||||
if (selfProfile == null || selfProfile.getDisplayName().isEmpty()) {
|
if (selfProfile == null || selfProfile.getDisplayName().isEmpty()) {
|
||||||
@ -738,7 +749,9 @@ public class ManagerImpl implements Manager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SendMessageResults sendEditMessage(
|
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 {
|
) throws IOException, AttachmentInvalidException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException, UnregisteredRecipientException, InvalidStickerException {
|
||||||
final var messageBuilder = SignalServiceDataMessage.newBuilder();
|
final var messageBuilder = SignalServiceDataMessage.newBuilder();
|
||||||
applyMessage(messageBuilder, message);
|
applyMessage(messageBuilder, message);
|
||||||
@ -746,7 +759,8 @@ public class ManagerImpl implements Manager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void applyMessage(
|
private void applyMessage(
|
||||||
final SignalServiceDataMessage.Builder messageBuilder, final Message message
|
final SignalServiceDataMessage.Builder messageBuilder,
|
||||||
|
final Message message
|
||||||
) throws AttachmentInvalidException, IOException, UnregisteredRecipientException, InvalidStickerException {
|
) throws AttachmentInvalidException, IOException, UnregisteredRecipientException, InvalidStickerException {
|
||||||
final var additionalAttachments = new ArrayList<SignalServiceAttachment>();
|
final var additionalAttachments = new ArrayList<SignalServiceAttachment>();
|
||||||
if (message.messageText().length() > ServiceConfig.MAX_MESSAGE_BODY_SIZE) {
|
if (message.messageText().length() > ServiceConfig.MAX_MESSAGE_BODY_SIZE) {
|
||||||
@ -863,7 +877,8 @@ public class ManagerImpl implements Manager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SendMessageResults sendRemoteDeleteMessage(
|
public SendMessageResults sendRemoteDeleteMessage(
|
||||||
long targetSentTimestamp, Set<RecipientIdentifier> recipients
|
long targetSentTimestamp,
|
||||||
|
Set<RecipientIdentifier> recipients
|
||||||
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException {
|
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException {
|
||||||
var delete = new SignalServiceDataMessage.RemoteDelete(targetSentTimestamp);
|
var delete = new SignalServiceDataMessage.RemoteDelete(targetSentTimestamp);
|
||||||
final var messageBuilder = SignalServiceDataMessage.newBuilder().withRemoteDelete(delete);
|
final var messageBuilder = SignalServiceDataMessage.newBuilder().withRemoteDelete(delete);
|
||||||
@ -915,7 +930,9 @@ public class ManagerImpl implements Manager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SendMessageResults sendPaymentNotificationMessage(
|
public SendMessageResults sendPaymentNotificationMessage(
|
||||||
byte[] receipt, String note, RecipientIdentifier.Single recipient
|
byte[] receipt,
|
||||||
|
String note,
|
||||||
|
RecipientIdentifier.Single recipient
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
final var paymentNotification = new SignalServiceDataMessage.PaymentNotification(receipt, note);
|
final var paymentNotification = new SignalServiceDataMessage.PaymentNotification(receipt, note);
|
||||||
final var payment = new SignalServiceDataMessage.Payment(paymentNotification, null);
|
final var payment = new SignalServiceDataMessage.Payment(paymentNotification, null);
|
||||||
@ -958,7 +975,8 @@ public class ManagerImpl implements Manager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SendMessageResults sendMessageRequestResponse(
|
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>>();
|
var results = new HashMap<RecipientIdentifier, List<SendMessageResult>>();
|
||||||
for (final var recipient : recipients) {
|
for (final var recipient : recipients) {
|
||||||
@ -1021,7 +1039,9 @@ public class ManagerImpl implements Manager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setContactName(
|
public void setContactName(
|
||||||
RecipientIdentifier.Single recipient, String givenName, final String familyName
|
RecipientIdentifier.Single recipient,
|
||||||
|
String givenName,
|
||||||
|
final String familyName
|
||||||
) throws NotPrimaryDeviceException, UnregisteredRecipientException {
|
) throws NotPrimaryDeviceException, UnregisteredRecipientException {
|
||||||
if (!account.isPrimaryDevice()) {
|
if (!account.isPrimaryDevice()) {
|
||||||
throw new NotPrimaryDeviceException();
|
throw new NotPrimaryDeviceException();
|
||||||
@ -1033,7 +1053,8 @@ public class ManagerImpl implements Manager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setContactsBlocked(
|
public void setContactsBlocked(
|
||||||
Collection<RecipientIdentifier.Single> recipients, boolean blocked
|
Collection<RecipientIdentifier.Single> recipients,
|
||||||
|
boolean blocked
|
||||||
) throws IOException, UnregisteredRecipientException {
|
) throws IOException, UnregisteredRecipientException {
|
||||||
if (recipients.isEmpty()) {
|
if (recipients.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
@ -1067,7 +1088,8 @@ public class ManagerImpl implements Manager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setGroupsBlocked(
|
public void setGroupsBlocked(
|
||||||
final Collection<GroupId> groupIds, final boolean blocked
|
final Collection<GroupId> groupIds,
|
||||||
|
final boolean blocked
|
||||||
) throws GroupNotFoundException, IOException {
|
) throws GroupNotFoundException, IOException {
|
||||||
if (groupIds.isEmpty()) {
|
if (groupIds.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
@ -1093,7 +1115,8 @@ public class ManagerImpl implements Manager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setExpirationTimer(
|
public void setExpirationTimer(
|
||||||
RecipientIdentifier.Single recipient, int messageExpirationTimer
|
RecipientIdentifier.Single recipient,
|
||||||
|
int messageExpirationTimer
|
||||||
) throws IOException, UnregisteredRecipientException {
|
) throws IOException, UnregisteredRecipientException {
|
||||||
var recipientId = context.getRecipientHelper().resolveRecipient(recipient);
|
var recipientId = context.getRecipientHelper().resolveRecipient(recipient);
|
||||||
context.getContactHelper().setExpirationTimer(recipientId, messageExpirationTimer);
|
context.getContactHelper().setExpirationTimer(recipientId, messageExpirationTimer);
|
||||||
@ -1255,7 +1278,9 @@ public class ManagerImpl implements Manager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void receiveMessages(
|
public void receiveMessages(
|
||||||
Optional<Duration> timeout, Optional<Integer> maxMessages, ReceiveMessageHandler handler
|
Optional<Duration> timeout,
|
||||||
|
Optional<Integer> maxMessages,
|
||||||
|
ReceiveMessageHandler handler
|
||||||
) throws IOException, AlreadyReceivingException {
|
) throws IOException, AlreadyReceivingException {
|
||||||
receiveMessages(timeout.orElse(Duration.ofMinutes(1)), timeout.isPresent(), maxMessages.orElse(null), handler);
|
receiveMessages(timeout.orElse(Duration.ofMinutes(1)), timeout.isPresent(), maxMessages.orElse(null), handler);
|
||||||
}
|
}
|
||||||
@ -1275,7 +1300,10 @@ public class ManagerImpl implements Manager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void receiveMessages(
|
private void receiveMessages(
|
||||||
Duration timeout, boolean returnOnTimeout, Integer maxMessages, ReceiveMessageHandler handler
|
Duration timeout,
|
||||||
|
boolean returnOnTimeout,
|
||||||
|
Integer maxMessages,
|
||||||
|
ReceiveMessageHandler handler
|
||||||
) throws IOException, AlreadyReceivingException {
|
) throws IOException, AlreadyReceivingException {
|
||||||
synchronized (messageHandlers) {
|
synchronized (messageHandlers) {
|
||||||
if (isReceiving()) {
|
if (isReceiving()) {
|
||||||
@ -1431,7 +1459,8 @@ public class ManagerImpl implements Manager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean trustIdentityVerified(
|
public boolean trustIdentityVerified(
|
||||||
RecipientIdentifier.Single recipient, IdentityVerificationCode verificationCode
|
RecipientIdentifier.Single recipient,
|
||||||
|
IdentityVerificationCode verificationCode
|
||||||
) throws UnregisteredRecipientException {
|
) throws UnregisteredRecipientException {
|
||||||
return switch (verificationCode) {
|
return switch (verificationCode) {
|
||||||
case IdentityVerificationCode.Fingerprint fingerprint -> trustIdentity(recipient,
|
case IdentityVerificationCode.Fingerprint fingerprint -> trustIdentity(recipient,
|
||||||
@ -1450,7 +1479,8 @@ public class ManagerImpl implements Manager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean trustIdentity(
|
private boolean trustIdentity(
|
||||||
RecipientIdentifier.Single recipient, Function<RecipientId, Boolean> trustMethod
|
RecipientIdentifier.Single recipient,
|
||||||
|
Function<RecipientId, Boolean> trustMethod
|
||||||
) throws UnregisteredRecipientException {
|
) throws UnregisteredRecipientException {
|
||||||
final var recipientId = context.getRecipientHelper().resolveRecipient(recipient);
|
final var recipientId = context.getRecipientHelper().resolveRecipient(recipient);
|
||||||
final var updated = trustMethod.apply(recipientId);
|
final var updated = trustMethod.apply(recipientId);
|
||||||
|
@ -105,7 +105,9 @@ public class RegistrationManagerImpl implements RegistrationManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void register(
|
public void register(
|
||||||
boolean voiceVerification, String captcha, final boolean forceRegister
|
boolean voiceVerification,
|
||||||
|
String captcha,
|
||||||
|
final boolean forceRegister
|
||||||
) throws IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, RateLimitException, VerificationMethodNotAvailableException {
|
) throws IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException, RateLimitException, VerificationMethodNotAvailableException {
|
||||||
if (account.isRegistered()
|
if (account.isRegistered()
|
||||||
&& account.getServiceEnvironment() != null
|
&& account.getServiceEnvironment() != null
|
||||||
@ -145,7 +147,8 @@ public class RegistrationManagerImpl implements RegistrationManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void verifyAccount(
|
public void verifyAccount(
|
||||||
String verificationCode, String pin
|
String verificationCode,
|
||||||
|
String pin
|
||||||
) throws IOException, PinLockedException, IncorrectPinException {
|
) throws IOException, PinLockedException, IncorrectPinException {
|
||||||
if (account.isRegistered()) {
|
if (account.isRegistered()) {
|
||||||
throw new IOException("Account is already registered");
|
throw new IOException("Account is already registered");
|
||||||
|
@ -611,7 +611,8 @@ public class AccountDatabase extends Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void createUuidMappingTable(
|
private static void createUuidMappingTable(
|
||||||
final Connection connection, final Statement statement
|
final Connection connection,
|
||||||
|
final Statement statement
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
statement.executeUpdate("""
|
statement.executeUpdate("""
|
||||||
CREATE TABLE tmp_mapping_table (
|
CREATE TABLE tmp_mapping_table (
|
||||||
|
@ -22,7 +22,8 @@ public class AttachmentStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void storeAttachmentPreview(
|
public void storeAttachmentPreview(
|
||||||
final SignalServiceAttachmentPointer pointer, final AttachmentStorer storer
|
final SignalServiceAttachmentPointer pointer,
|
||||||
|
final AttachmentStorer storer
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
storeAttachment(getAttachmentPreviewFile(pointer.getRemoteId(),
|
storeAttachment(getAttachmentPreviewFile(pointer.getRemoteId(),
|
||||||
pointer.getFileName(),
|
pointer.getFileName(),
|
||||||
@ -30,7 +31,8 @@ public class AttachmentStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void storeAttachment(
|
public void storeAttachment(
|
||||||
final SignalServiceAttachmentPointer pointer, final AttachmentStorer storer
|
final SignalServiceAttachmentPointer pointer,
|
||||||
|
final AttachmentStorer storer
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
storeAttachment(getAttachmentFile(pointer), storer);
|
storeAttachment(getAttachmentFile(pointer), storer);
|
||||||
}
|
}
|
||||||
@ -54,22 +56,24 @@ public class AttachmentStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private File getAttachmentPreviewFile(
|
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);
|
final var extension = getAttachmentExtension(filename, contentType);
|
||||||
return new File(attachmentsPath, attachmentId.toString() + extension + ".preview");
|
return new File(attachmentsPath, attachmentId.toString() + extension + ".preview");
|
||||||
}
|
}
|
||||||
|
|
||||||
private File getAttachmentFile(
|
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);
|
final var extension = getAttachmentExtension(filename, contentType);
|
||||||
return new File(attachmentsPath, attachmentId.toString() + extension);
|
return new File(attachmentsPath, attachmentId.toString() + extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getAttachmentExtension(
|
private static String getAttachmentExtension(final Optional<String> filename, final Optional<String> contentType) {
|
||||||
final Optional<String> filename, final Optional<String> contentType
|
|
||||||
) {
|
|
||||||
return filename.filter(f -> f.contains("."))
|
return filename.filter(f -> f.contains("."))
|
||||||
.map(f -> f.substring(f.lastIndexOf(".") + 1))
|
.map(f -> f.substring(f.lastIndexOf(".") + 1))
|
||||||
.or(() -> contentType.flatMap(MimeUtils::guessExtensionFromMimeType))
|
.or(() -> contentType.flatMap(MimeUtils::guessExtensionFromMimeType))
|
||||||
|
@ -24,7 +24,8 @@ public abstract class Database implements AutoCloseable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static <T extends Database> T initDatabase(
|
public static <T extends Database> T initDatabase(
|
||||||
File databaseFile, Function<HikariDataSource, T> newDatabase
|
File databaseFile,
|
||||||
|
Function<HikariDataSource, T> newDatabase
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
HikariDataSource dataSource = null;
|
HikariDataSource dataSource = null;
|
||||||
|
|
||||||
|
@ -189,7 +189,10 @@ public class SignalAccount implements Closeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static SignalAccount load(
|
public static SignalAccount load(
|
||||||
File dataPath, String accountPath, boolean waitForLock, final Settings settings
|
File dataPath,
|
||||||
|
String accountPath,
|
||||||
|
boolean waitForLock,
|
||||||
|
final Settings settings
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
logger.trace("Opening account file");
|
logger.trace("Opening account file");
|
||||||
final var fileName = getFileName(dataPath, accountPath);
|
final var fileName = getFileName(dataPath, accountPath);
|
||||||
@ -316,7 +319,9 @@ public class SignalAccount implements Closeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void finishLinking(
|
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.registered = true;
|
||||||
this.deviceId = deviceId;
|
this.deviceId = deviceId;
|
||||||
@ -375,7 +380,9 @@ public class SignalAccount implements Closeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void mergeRecipients(
|
private void mergeRecipients(
|
||||||
final Connection connection, RecipientId recipientId, RecipientId toBeMergedRecipientId
|
final Connection connection,
|
||||||
|
RecipientId recipientId,
|
||||||
|
RecipientId toBeMergedRecipientId
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
getMessageCache().mergeRecipients(recipientId, toBeMergedRecipientId);
|
getMessageCache().mergeRecipients(recipientId, toBeMergedRecipientId);
|
||||||
getGroupStore().mergeRecipients(connection, recipientId, toBeMergedRecipientId);
|
getGroupStore().mergeRecipients(connection, recipientId, toBeMergedRecipientId);
|
||||||
@ -438,9 +445,7 @@ public class SignalAccount implements Closeable {
|
|||||||
return f.exists() && !f.isDirectory() && f.length() > 0L;
|
return f.exists() && !f.isDirectory() && f.length() > 0L;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void load(
|
private void load(File dataPath, String accountPath, final Settings settings) throws IOException {
|
||||||
File dataPath, String accountPath, final Settings settings
|
|
||||||
) throws IOException {
|
|
||||||
logger.trace("Loading account file {}", accountPath);
|
logger.trace("Loading account file {}", accountPath);
|
||||||
this.dataPath = dataPath;
|
this.dataPath = dataPath;
|
||||||
this.accountPath = accountPath;
|
this.accountPath = accountPath;
|
||||||
@ -786,7 +791,8 @@ public class SignalAccount implements Closeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void loadLegacyStores(
|
private void loadLegacyStores(
|
||||||
final JsonNode rootNode, final LegacyJsonSignalProtocolStore legacySignalProtocolStore
|
final JsonNode rootNode,
|
||||||
|
final LegacyJsonSignalProtocolStore legacySignalProtocolStore
|
||||||
) {
|
) {
|
||||||
var legacyRecipientStoreNode = rootNode.get("recipientStore");
|
var legacyRecipientStoreNode = rootNode.get("recipientStore");
|
||||||
if (legacyRecipientStoreNode != null) {
|
if (legacyRecipientStoreNode != null) {
|
||||||
|
@ -41,9 +41,7 @@ public class UnknownStorageIdStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<StorageId> getUnknownStorageIds(
|
public List<StorageId> getUnknownStorageIds(Connection connection, Collection<Integer> types) throws SQLException {
|
||||||
Connection connection, Collection<Integer> types
|
|
||||||
) throws SQLException {
|
|
||||||
final var typesCommaSeparated = types.stream().map(String::valueOf).collect(Collectors.joining(","));
|
final var typesCommaSeparated = types.stream().map(String::valueOf).collect(Collectors.joining(","));
|
||||||
final var sql = (
|
final var sql = (
|
||||||
"""
|
"""
|
||||||
|
@ -72,7 +72,8 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T executeQuerySingleRow(
|
public static <T> T executeQuerySingleRow(
|
||||||
PreparedStatement statement, ResultSetMapper<T> mapper
|
PreparedStatement statement,
|
||||||
|
ResultSetMapper<T> mapper
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
final var resultSet = statement.executeQuery();
|
final var resultSet = statement.executeQuery();
|
||||||
if (!resultSet.next()) {
|
if (!resultSet.next()) {
|
||||||
@ -82,7 +83,8 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static <T> Optional<T> executeQueryForOptional(
|
public static <T> Optional<T> executeQueryForOptional(
|
||||||
PreparedStatement statement, ResultSetMapper<T> mapper
|
PreparedStatement statement,
|
||||||
|
ResultSetMapper<T> mapper
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
final var resultSet = statement.executeQuery();
|
final var resultSet = statement.executeQuery();
|
||||||
if (!resultSet.next()) {
|
if (!resultSet.next()) {
|
||||||
@ -92,7 +94,8 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static <T> Stream<T> executeQueryForStream(
|
public static <T> Stream<T> executeQueryForStream(
|
||||||
PreparedStatement statement, ResultSetMapper<T> mapper
|
PreparedStatement statement,
|
||||||
|
ResultSetMapper<T> mapper
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
final var resultSet = statement.executeQuery();
|
final var resultSet = statement.executeQuery();
|
||||||
|
|
||||||
|
@ -41,7 +41,9 @@ public class AccountsStore {
|
|||||||
private final AccountLoader accountLoader;
|
private final AccountLoader accountLoader;
|
||||||
|
|
||||||
public AccountsStore(
|
public AccountsStore(
|
||||||
final File dataPath, final ServiceEnvironment serviceEnvironment, final AccountLoader accountLoader
|
final File dataPath,
|
||||||
|
final ServiceEnvironment serviceEnvironment,
|
||||||
|
final AccountLoader accountLoader
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
this.dataPath = dataPath;
|
this.dataPath = dataPath;
|
||||||
this.serviceEnvironment = getServiceEnvironmentString(serviceEnvironment);
|
this.serviceEnvironment = getServiceEnvironmentString(serviceEnvironment);
|
||||||
@ -202,7 +204,9 @@ public class AccountsStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private AccountsStorage upgradeAccountsFile(
|
private AccountsStorage upgradeAccountsFile(
|
||||||
final FileChannel fileChannel, final AccountsStorage storage, final int accountsVersion
|
final FileChannel fileChannel,
|
||||||
|
final AccountsStorage storage,
|
||||||
|
final int accountsVersion
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
List<AccountsStorage.Account> newAccounts = storage.accounts();
|
List<AccountsStorage.Account> newAccounts = storage.accounts();
|
||||||
|
@ -59,7 +59,8 @@ public class ConfigurationStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setUnidentifiedDeliveryIndicators(
|
public void setUnidentifiedDeliveryIndicators(
|
||||||
final Connection connection, final boolean value
|
final Connection connection,
|
||||||
|
final boolean value
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
if (keyValueStore.storeEntry(connection, unidentifiedDeliveryIndicators, value)) {
|
if (keyValueStore.storeEntry(connection, unidentifiedDeliveryIndicators, value)) {
|
||||||
recipientStore.rotateSelfStorageId(connection);
|
recipientStore.rotateSelfStorageId(connection);
|
||||||
@ -125,7 +126,8 @@ public class ConfigurationStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setPhoneNumberSharingMode(
|
public void setPhoneNumberSharingMode(
|
||||||
final Connection connection, final PhoneNumberSharingMode value
|
final Connection connection,
|
||||||
|
final PhoneNumberSharingMode value
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
if (keyValueStore.storeEntry(connection, phoneNumberSharingMode, value)) {
|
if (keyValueStore.storeEntry(connection, phoneNumberSharingMode, value)) {
|
||||||
recipientStore.rotateSelfStorageId(connection);
|
recipientStore.rotateSelfStorageId(connection);
|
||||||
|
@ -31,7 +31,9 @@ public final class GroupInfoV2 extends GroupInfo {
|
|||||||
private final RecipientResolver recipientResolver;
|
private final RecipientResolver recipientResolver;
|
||||||
|
|
||||||
public GroupInfoV2(
|
public GroupInfoV2(
|
||||||
final GroupIdV2 groupId, final GroupMasterKey masterKey, final RecipientResolver recipientResolver
|
final GroupIdV2 groupId,
|
||||||
|
final GroupMasterKey masterKey,
|
||||||
|
final RecipientResolver recipientResolver
|
||||||
) {
|
) {
|
||||||
this.groupId = groupId;
|
this.groupId = groupId;
|
||||||
this.masterKey = masterKey;
|
this.masterKey = masterKey;
|
||||||
|
@ -121,7 +121,10 @@ public class GroupStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void storeStorageRecord(
|
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 {
|
) throws SQLException {
|
||||||
final var groupTable = groupId instanceof GroupIdV1 ? TABLE_GROUP_V1 : TABLE_GROUP_V2;
|
final var groupTable = groupId instanceof GroupIdV1 ? TABLE_GROUP_V1 : TABLE_GROUP_V2;
|
||||||
final var deleteSql = (
|
final var deleteSql = (
|
||||||
@ -250,7 +253,8 @@ public class GroupStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public GroupInfoV2 getGroupOrPartialMigrate(
|
public GroupInfoV2 getGroupOrPartialMigrate(
|
||||||
Connection connection, final GroupMasterKey groupMasterKey
|
Connection connection,
|
||||||
|
final GroupMasterKey groupMasterKey
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
final var groupSecretParams = GroupSecretParams.deriveFromMasterKey(groupMasterKey);
|
final var groupSecretParams = GroupSecretParams.deriveFromMasterKey(groupMasterKey);
|
||||||
final var groupId = GroupUtils.getGroupIdV2(groupSecretParams);
|
final var groupId = GroupUtils.getGroupIdV2(groupSecretParams);
|
||||||
@ -258,9 +262,7 @@ public class GroupStore {
|
|||||||
return getGroupOrPartialMigrate(connection, groupMasterKey, groupId);
|
return getGroupOrPartialMigrate(connection, groupMasterKey, groupId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GroupInfoV2 getGroupOrPartialMigrate(
|
public GroupInfoV2 getGroupOrPartialMigrate(final GroupMasterKey groupMasterKey, final GroupIdV2 groupId) {
|
||||||
final GroupMasterKey groupMasterKey, final GroupIdV2 groupId
|
|
||||||
) {
|
|
||||||
try (final var connection = database.getConnection()) {
|
try (final var connection = database.getConnection()) {
|
||||||
return getGroupOrPartialMigrate(connection, groupMasterKey, groupId);
|
return getGroupOrPartialMigrate(connection, groupMasterKey, groupId);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@ -269,7 +271,9 @@ public class GroupStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private GroupInfoV2 getGroupOrPartialMigrate(
|
private GroupInfoV2 getGroupOrPartialMigrate(
|
||||||
Connection connection, final GroupMasterKey groupMasterKey, final GroupIdV2 groupId
|
Connection connection,
|
||||||
|
final GroupMasterKey groupMasterKey,
|
||||||
|
final GroupIdV2 groupId
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
switch (getGroup(connection, (GroupId) groupId)) {
|
switch (getGroup(connection, (GroupId) groupId)) {
|
||||||
case GroupInfoV1 groupInfoV1 -> {
|
case GroupInfoV1 groupInfoV1 -> {
|
||||||
@ -325,7 +329,9 @@ public class GroupStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void mergeRecipients(
|
public void mergeRecipients(
|
||||||
final Connection connection, final RecipientId recipientId, final RecipientId toBeMergedRecipientId
|
final Connection connection,
|
||||||
|
final RecipientId recipientId,
|
||||||
|
final RecipientId toBeMergedRecipientId
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
final var sql = (
|
final var sql = (
|
||||||
"""
|
"""
|
||||||
@ -360,7 +366,9 @@ public class GroupStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateStorageIds(
|
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 {
|
) throws SQLException {
|
||||||
final var sql = (
|
final var sql = (
|
||||||
"""
|
"""
|
||||||
@ -385,9 +393,7 @@ public class GroupStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateStorageId(
|
public void updateStorageId(Connection connection, GroupId groupId, StorageId storageId) throws SQLException {
|
||||||
Connection connection, GroupId groupId, StorageId storageId
|
|
||||||
) throws SQLException {
|
|
||||||
final var sqlV1 = (
|
final var sqlV1 = (
|
||||||
"""
|
"""
|
||||||
UPDATE %s
|
UPDATE %s
|
||||||
@ -460,7 +466,9 @@ public class GroupStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void insertOrReplaceGroup(
|
private void insertOrReplaceGroup(
|
||||||
final Connection connection, Long internalId, final GroupInfo group
|
final Connection connection,
|
||||||
|
Long internalId,
|
||||||
|
final GroupInfo group
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
if (group instanceof GroupInfoV1 groupV1) {
|
if (group instanceof GroupInfoV1 groupV1) {
|
||||||
if (internalId != null) {
|
if (internalId != null) {
|
||||||
|
@ -151,7 +151,8 @@ public class LegacyGroupStore {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Member> deserialize(
|
public List<Member> deserialize(
|
||||||
JsonParser jsonParser, DeserializationContext deserializationContext
|
JsonParser jsonParser,
|
||||||
|
DeserializationContext deserializationContext
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
var addresses = new ArrayList<Member>();
|
var addresses = new ArrayList<Member>();
|
||||||
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
|
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
|
||||||
@ -184,7 +185,8 @@ public class LegacyGroupStore {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Object> deserialize(
|
public List<Object> deserialize(
|
||||||
JsonParser jsonParser, DeserializationContext deserializationContext
|
JsonParser jsonParser,
|
||||||
|
DeserializationContext deserializationContext
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
var groups = new ArrayList<>();
|
var groups = new ArrayList<>();
|
||||||
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
|
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
|
||||||
|
@ -11,9 +11,7 @@ public class IdentityInfo {
|
|||||||
private final TrustLevel trustLevel;
|
private final TrustLevel trustLevel;
|
||||||
private final long addedTimestamp;
|
private final long addedTimestamp;
|
||||||
|
|
||||||
IdentityInfo(
|
IdentityInfo(final String address, IdentityKey identityKey, TrustLevel trustLevel, long addedTimestamp) {
|
||||||
final String address, IdentityKey identityKey, TrustLevel trustLevel, long addedTimestamp
|
|
||||||
) {
|
|
||||||
this.address = address;
|
this.address = address;
|
||||||
this.identityKey = identityKey;
|
this.identityKey = identityKey;
|
||||||
this.trustLevel = trustLevel;
|
this.trustLevel = trustLevel;
|
||||||
|
@ -49,7 +49,9 @@ public class IdentityKeyStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public IdentityKeyStore(
|
public IdentityKeyStore(
|
||||||
final Database database, final TrustNewIdentity trustNewIdentity, RecipientStore recipientStore
|
final Database database,
|
||||||
|
final TrustNewIdentity trustNewIdentity,
|
||||||
|
RecipientStore recipientStore
|
||||||
) {
|
) {
|
||||||
this.database = database;
|
this.database = database;
|
||||||
this.trustNewIdentity = trustNewIdentity;
|
this.trustNewIdentity = trustNewIdentity;
|
||||||
@ -65,7 +67,9 @@ public class IdentityKeyStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean saveIdentity(
|
public boolean saveIdentity(
|
||||||
final Connection connection, final ServiceId serviceId, final IdentityKey identityKey
|
final Connection connection,
|
||||||
|
final ServiceId serviceId,
|
||||||
|
final IdentityKey identityKey
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
return saveIdentity(connection, serviceId.toString(), identityKey);
|
return saveIdentity(connection, serviceId.toString(), identityKey);
|
||||||
}
|
}
|
||||||
@ -82,7 +86,9 @@ public class IdentityKeyStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean saveIdentity(
|
private boolean saveIdentity(
|
||||||
final Connection connection, final String address, final IdentityKey identityKey
|
final Connection connection,
|
||||||
|
final String address,
|
||||||
|
final IdentityKey identityKey
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
final var identityInfo = loadIdentity(connection, address);
|
final var identityInfo = loadIdentity(connection, address);
|
||||||
if (identityInfo != null && identityInfo.getIdentityKey().equals(identityKey)) {
|
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);
|
logger.debug("Complete identities migration took {}ms", (System.nanoTime() - start) / 1000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IdentityInfo loadIdentity(
|
private IdentityInfo loadIdentity(final Connection connection, final String address) throws SQLException {
|
||||||
final Connection connection, final String address
|
|
||||||
) throws SQLException {
|
|
||||||
final var sql = (
|
final var sql = (
|
||||||
"""
|
"""
|
||||||
SELECT i.address, i.identity_key, i.added_timestamp, i.trust_level
|
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+)");
|
static final Pattern identityFileNamePattern = Pattern.compile("(\\d+)");
|
||||||
|
|
||||||
private static List<IdentityInfo> getIdentities(
|
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();
|
final var files = identitiesPath.listFiles();
|
||||||
if (files == null) {
|
if (files == null) {
|
||||||
@ -66,7 +68,9 @@ public class LegacyIdentityKeyStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static IdentityInfo loadIdentityLocked(
|
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);
|
final var file = getIdentityFile(recipientId, identitiesPath);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
|
@ -74,7 +74,9 @@ public class KeyValueStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public <T> boolean storeEntry(
|
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 {
|
) throws SQLException {
|
||||||
final var entry = getEntry(key);
|
final var entry = getEntry(key);
|
||||||
if (Objects.equals(entry, value)) {
|
if (Objects.equals(entry, value)) {
|
||||||
@ -98,7 +100,8 @@ public class KeyValueStore {
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private static <T> T readValueFromResultSet(
|
private static <T> T readValueFromResultSet(
|
||||||
final KeyValueEntry<T> key, final ResultSet resultSet
|
final KeyValueEntry<T> key,
|
||||||
|
final ResultSet resultSet
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
Object value;
|
Object value;
|
||||||
final var clazz = key.clazz();
|
final var clazz = key.clazz();
|
||||||
@ -134,7 +137,10 @@ public class KeyValueStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static <T> void setParameterValue(
|
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 {
|
) throws SQLException {
|
||||||
if (clazz == int.class || clazz == Integer.class) {
|
if (clazz == int.class || clazz == Integer.class) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
|
@ -34,7 +34,8 @@ public class LegacyProfileStore {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<LegacySignalProfileEntry> deserialize(
|
public List<LegacySignalProfileEntry> deserialize(
|
||||||
JsonParser jsonParser, DeserializationContext deserializationContext
|
JsonParser jsonParser,
|
||||||
|
DeserializationContext deserializationContext
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
|
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ public interface ProfileStore {
|
|||||||
void storeProfileKey(RecipientId recipientId, ProfileKey profileKey);
|
void storeProfileKey(RecipientId recipientId, ProfileKey profileKey);
|
||||||
|
|
||||||
void storeExpiringProfileKeyCredential(
|
void storeExpiringProfileKeyCredential(
|
||||||
RecipientId recipientId, ExpiringProfileKeyCredential expiringProfileKeyCredential
|
RecipientId recipientId,
|
||||||
|
ExpiringProfileKeyCredential expiringProfileKeyCredential
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,9 @@ public class LegacyJsonIdentityKeyStore {
|
|||||||
private final int localRegistrationId;
|
private final int localRegistrationId;
|
||||||
|
|
||||||
private LegacyJsonIdentityKeyStore(
|
private LegacyJsonIdentityKeyStore(
|
||||||
final List<LegacyIdentityInfo> identities, IdentityKeyPair identityKeyPair, int localRegistrationId
|
final List<LegacyIdentityInfo> identities,
|
||||||
|
IdentityKeyPair identityKeyPair,
|
||||||
|
int localRegistrationId
|
||||||
) {
|
) {
|
||||||
this.identities = identities;
|
this.identities = identities;
|
||||||
this.identityKeyPair = identityKeyPair;
|
this.identityKeyPair = identityKeyPair;
|
||||||
@ -77,7 +79,8 @@ public class LegacyJsonIdentityKeyStore {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LegacyJsonIdentityKeyStore deserialize(
|
public LegacyJsonIdentityKeyStore deserialize(
|
||||||
JsonParser jsonParser, DeserializationContext deserializationContext
|
JsonParser jsonParser,
|
||||||
|
DeserializationContext deserializationContext
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
|
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
|
||||||
|
|
||||||
|
@ -26,7 +26,8 @@ public class LegacyJsonPreKeyStore {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LegacyJsonPreKeyStore deserialize(
|
public LegacyJsonPreKeyStore deserialize(
|
||||||
JsonParser jsonParser, DeserializationContext deserializationContext
|
JsonParser jsonParser,
|
||||||
|
DeserializationContext deserializationContext
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
|
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
|
||||||
|
|
||||||
|
@ -31,7 +31,8 @@ public class LegacyJsonSessionStore {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LegacyJsonSessionStore deserialize(
|
public LegacyJsonSessionStore deserialize(
|
||||||
JsonParser jsonParser, DeserializationContext deserializationContext
|
JsonParser jsonParser,
|
||||||
|
DeserializationContext deserializationContext
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
|
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
|
||||||
|
|
||||||
|
@ -26,7 +26,8 @@ public class LegacyJsonSignedPreKeyStore {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LegacyJsonSignedPreKeyStore deserialize(
|
public LegacyJsonSignedPreKeyStore deserialize(
|
||||||
JsonParser jsonParser, DeserializationContext deserializationContext
|
JsonParser jsonParser,
|
||||||
|
DeserializationContext deserializationContext
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
|
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
|
||||||
|
|
||||||
|
@ -172,7 +172,9 @@ public class SignalProtocolStore implements SignalServiceAccountDataStore {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void storeSenderKey(
|
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);
|
senderKeyStore.storeSenderKey(sender, distributionId, record);
|
||||||
}
|
}
|
||||||
@ -189,7 +191,8 @@ public class SignalProtocolStore implements SignalServiceAccountDataStore {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void markSenderKeySharedWith(
|
public void markSenderKeySharedWith(
|
||||||
final DistributionId distributionId, final Collection<SignalProtocolAddress> addresses
|
final DistributionId distributionId,
|
||||||
|
final Collection<SignalProtocolAddress> addresses
|
||||||
) {
|
) {
|
||||||
senderKeyStore.markSenderKeySharedWith(distributionId, addresses);
|
senderKeyStore.markSenderKeySharedWith(distributionId, addresses);
|
||||||
}
|
}
|
||||||
|
@ -98,9 +98,7 @@ public class CdsiStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void removeNumbers(
|
private static void removeNumbers(final Connection connection, final Set<String> numbers) throws SQLException {
|
||||||
final Connection connection, final Set<String> numbers
|
|
||||||
) throws SQLException {
|
|
||||||
final var sql = (
|
final var sql = (
|
||||||
"""
|
"""
|
||||||
DELETE FROM %s
|
DELETE FROM %s
|
||||||
@ -116,7 +114,9 @@ public class CdsiStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void addNumbers(
|
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 {
|
) throws SQLException {
|
||||||
final var sql = (
|
final var sql = (
|
||||||
"""
|
"""
|
||||||
@ -135,7 +135,9 @@ public class CdsiStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void updateLastSeen(
|
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 {
|
) throws SQLException {
|
||||||
final var sql = (
|
final var sql = (
|
||||||
"""
|
"""
|
||||||
|
@ -27,7 +27,8 @@ public class LegacyRecipientStore {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<RecipientAddress> deserialize(
|
public List<RecipientAddress> deserialize(
|
||||||
JsonParser jsonParser, DeserializationContext deserializationContext
|
JsonParser jsonParser,
|
||||||
|
DeserializationContext deserializationContext
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
|
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
|
||||||
|
|
||||||
|
@ -15,7 +15,8 @@ public class MergeRecipientHelper {
|
|||||||
private static final Logger logger = LoggerFactory.getLogger(MergeRecipientHelper.class);
|
private static final Logger logger = LoggerFactory.getLogger(MergeRecipientHelper.class);
|
||||||
|
|
||||||
static Pair<RecipientId, List<RecipientId>> resolveRecipientTrustedLocked(
|
static Pair<RecipientId, List<RecipientId>> resolveRecipientTrustedLocked(
|
||||||
Store store, RecipientAddress address
|
Store store,
|
||||||
|
RecipientAddress address
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
// address has at least one of serviceId/pni and optionally number/username
|
// 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(
|
public RecipientId resolveRecipientByNumber(
|
||||||
final String number, Supplier<ServiceId> serviceIdSupplier
|
final String number,
|
||||||
|
Supplier<ServiceId> serviceIdSupplier
|
||||||
) throws UnregisteredRecipientException {
|
) throws UnregisteredRecipientException {
|
||||||
final Optional<RecipientWithAddress> byNumber;
|
final Optional<RecipientWithAddress> byNumber;
|
||||||
try (final var connection = database.getConnection()) {
|
try (final var connection = database.getConnection()) {
|
||||||
@ -238,7 +239,8 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
public RecipientId resolveRecipientByUsername(
|
public RecipientId resolveRecipientByUsername(
|
||||||
final String username, Supplier<ACI> aciSupplier
|
final String username,
|
||||||
|
Supplier<ACI> aciSupplier
|
||||||
) throws UnregisteredRecipientException {
|
) throws UnregisteredRecipientException {
|
||||||
final Optional<RecipientWithAddress> byUsername;
|
final Optional<RecipientWithAddress> byUsername;
|
||||||
try (final var connection = database.getConnection()) {
|
try (final var connection = database.getConnection()) {
|
||||||
@ -301,7 +303,9 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RecipientId resolveRecipientTrusted(
|
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()));
|
return resolveRecipientTrusted(new RecipientAddress(aci, pni, number, Optional.empty()));
|
||||||
}
|
}
|
||||||
@ -392,7 +396,10 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<Recipient> getRecipients(
|
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>();
|
final var sqlWhere = new ArrayList<String>();
|
||||||
if (onlyContacts) {
|
if (onlyContacts) {
|
||||||
@ -614,14 +621,17 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void storeProfileKey(
|
public void storeProfileKey(
|
||||||
Connection connection, RecipientId recipientId, final ProfileKey profileKey
|
Connection connection,
|
||||||
|
RecipientId recipientId,
|
||||||
|
final ProfileKey profileKey
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
storeProfileKey(connection, recipientId, profileKey, true);
|
storeProfileKey(connection, recipientId, profileKey, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void storeExpiringProfileKeyCredential(
|
public void storeExpiringProfileKeyCredential(
|
||||||
RecipientId recipientId, final ExpiringProfileKeyCredential profileKeyCredential
|
RecipientId recipientId,
|
||||||
|
final ExpiringProfileKeyCredential profileKeyCredential
|
||||||
) {
|
) {
|
||||||
try (final var connection = database.getConnection()) {
|
try (final var connection = database.getConnection()) {
|
||||||
storeExpiringProfileKeyCredential(connection, recipientId, profileKeyCredential);
|
storeExpiringProfileKeyCredential(connection, recipientId, profileKeyCredential);
|
||||||
@ -661,7 +671,9 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateStorageId(
|
public void updateStorageId(
|
||||||
Connection connection, RecipientId recipientId, StorageId storageId
|
Connection connection,
|
||||||
|
RecipientId recipientId,
|
||||||
|
StorageId storageId
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
final var sql = (
|
final var sql = (
|
||||||
"""
|
"""
|
||||||
@ -813,7 +825,9 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void storeContact(
|
public void storeContact(
|
||||||
final Connection connection, final RecipientId recipientId, final Contact contact
|
final Connection connection,
|
||||||
|
final RecipientId recipientId,
|
||||||
|
final Contact contact
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
final var sql = (
|
final var sql = (
|
||||||
"""
|
"""
|
||||||
@ -852,7 +866,8 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int removeStorageIdsFromLocalOnlyUnregisteredRecipients(
|
public int removeStorageIdsFromLocalOnlyUnregisteredRecipients(
|
||||||
final Connection connection, final List<StorageId> storageIds
|
final Connection connection,
|
||||||
|
final List<StorageId> storageIds
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
final var sql = (
|
final var sql = (
|
||||||
"""
|
"""
|
||||||
@ -965,7 +980,8 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void markUnregisteredAndSplitIfNecessary(
|
private void markUnregisteredAndSplitIfNecessary(
|
||||||
final Connection connection, final RecipientId recipientId
|
final Connection connection,
|
||||||
|
final RecipientId recipientId
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
markUnregistered(connection, recipientId);
|
markUnregistered(connection, recipientId);
|
||||||
final var address = resolveRecipientAddress(connection, recipientId);
|
final var address = resolveRecipientAddress(connection, recipientId);
|
||||||
@ -977,7 +993,9 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void markDiscoverable(
|
private void markDiscoverable(
|
||||||
final Connection connection, final RecipientId recipientId, final boolean discoverable
|
final Connection connection,
|
||||||
|
final RecipientId recipientId,
|
||||||
|
final boolean discoverable
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
final var sql = (
|
final var sql = (
|
||||||
"""
|
"""
|
||||||
@ -993,9 +1011,7 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void markRegistered(
|
private void markRegistered(final Connection connection, final RecipientId recipientId) throws SQLException {
|
||||||
final Connection connection, final RecipientId recipientId
|
|
||||||
) throws SQLException {
|
|
||||||
final var sql = (
|
final var sql = (
|
||||||
"""
|
"""
|
||||||
UPDATE %s
|
UPDATE %s
|
||||||
@ -1009,9 +1025,7 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void markUnregistered(
|
private void markUnregistered(final Connection connection, final RecipientId recipientId) throws SQLException {
|
||||||
final Connection connection, final RecipientId recipientId
|
|
||||||
) throws SQLException {
|
|
||||||
final var sql = (
|
final var sql = (
|
||||||
"""
|
"""
|
||||||
UPDATE %s
|
UPDATE %s
|
||||||
@ -1046,7 +1060,9 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void storeProfile(
|
public void storeProfile(
|
||||||
final Connection connection, final RecipientId recipientId, final Profile profile
|
final Connection connection,
|
||||||
|
final RecipientId recipientId,
|
||||||
|
final Profile profile
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
final var sql = (
|
final var sql = (
|
||||||
"""
|
"""
|
||||||
@ -1079,7 +1095,10 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void storeProfileKey(
|
private void storeProfileKey(
|
||||||
Connection connection, RecipientId recipientId, final ProfileKey profileKey, boolean resetProfile
|
Connection connection,
|
||||||
|
RecipientId recipientId,
|
||||||
|
final ProfileKey profileKey,
|
||||||
|
boolean resetProfile
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
if (profileKey != null) {
|
if (profileKey != null) {
|
||||||
final var recipientProfileKey = getProfileKey(connection, recipientId);
|
final var recipientProfileKey = getProfileKey(connection, recipientId);
|
||||||
@ -1111,7 +1130,8 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
private RecipientAddress resolveRecipientAddress(
|
private RecipientAddress resolveRecipientAddress(
|
||||||
final Connection connection, final RecipientId recipientId
|
final Connection connection,
|
||||||
|
final RecipientId recipientId
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
final var sql = (
|
final var sql = (
|
||||||
"""
|
"""
|
||||||
@ -1150,7 +1170,9 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Pair<RecipientId, List<RecipientId>> resolveRecipientTrustedLocked(
|
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 {
|
) throws SQLException {
|
||||||
if (address.hasSingleIdentifier() || (
|
if (address.hasSingleIdentifier() || (
|
||||||
!isSelf && selfAddressProvider.getSelfAddress().matches(address)
|
!isSelf && selfAddressProvider.getSelfAddress().matches(address)
|
||||||
@ -1168,7 +1190,9 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void mergeRecipients(
|
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 {
|
) throws SQLException {
|
||||||
for (final var toBeMergedRecipientId : toBeMergedRecipientIds) {
|
for (final var toBeMergedRecipientId : toBeMergedRecipientIds) {
|
||||||
recipientMergeHandler.mergeRecipients(connection, recipientId, toBeMergedRecipientId);
|
recipientMergeHandler.mergeRecipients(connection, recipientId, toBeMergedRecipientId);
|
||||||
@ -1177,9 +1201,7 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private RecipientId resolveRecipientLocked(
|
private RecipientId resolveRecipientLocked(Connection connection, RecipientAddress address) throws SQLException {
|
||||||
Connection connection, RecipientAddress address
|
|
||||||
) throws SQLException {
|
|
||||||
final var byAci = address.aci().isEmpty()
|
final var byAci = address.aci().isEmpty()
|
||||||
? Optional.<RecipientWithAddress>empty()
|
? Optional.<RecipientWithAddress>empty()
|
||||||
: findByServiceId(connection, address.aci().get());
|
: findByServiceId(connection, address.aci().get());
|
||||||
@ -1236,7 +1258,8 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
private RecipientId addNewRecipient(
|
private RecipientId addNewRecipient(
|
||||||
final Connection connection, final RecipientAddress address
|
final Connection connection,
|
||||||
|
final RecipientAddress address
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
final var sql = (
|
final var sql = (
|
||||||
"""
|
"""
|
||||||
@ -1277,7 +1300,9 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateRecipientAddress(
|
private void updateRecipientAddress(
|
||||||
Connection connection, RecipientId recipientId, final RecipientAddress address
|
Connection connection,
|
||||||
|
RecipientId recipientId,
|
||||||
|
final RecipientAddress address
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
recipientAddressCache.entrySet().removeIf(e -> e.getValue().id().equals(recipientId));
|
recipientAddressCache.entrySet().removeIf(e -> e.getValue().id().equals(recipientId));
|
||||||
final var sql = (
|
final var sql = (
|
||||||
@ -1312,7 +1337,9 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void mergeRecipientsLocked(
|
private void mergeRecipientsLocked(
|
||||||
Connection connection, RecipientId recipientId, RecipientId toBeMergedRecipientId
|
Connection connection,
|
||||||
|
RecipientId recipientId,
|
||||||
|
RecipientId toBeMergedRecipientId
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
final var contact = getContact(connection, recipientId);
|
final var contact = getContact(connection, recipientId);
|
||||||
if (contact == null) {
|
if (contact == null) {
|
||||||
@ -1343,7 +1370,8 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Optional<RecipientWithAddress> findByNumber(
|
private Optional<RecipientWithAddress> findByNumber(
|
||||||
final Connection connection, final String number
|
final Connection connection,
|
||||||
|
final String number
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
final var sql = """
|
final var sql = """
|
||||||
SELECT r._id, r.number, r.aci, r.pni, r.username
|
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(
|
private Optional<RecipientWithAddress> findByUsername(
|
||||||
final Connection connection, final String username
|
final Connection connection,
|
||||||
|
final String username
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
final var sql = """
|
final var sql = """
|
||||||
SELECT r._id, r.number, r.aci, r.pni, r.username
|
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(
|
private Optional<RecipientWithAddress> findByServiceId(
|
||||||
final Connection connection, final ServiceId serviceId
|
final Connection connection,
|
||||||
|
final ServiceId serviceId
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
var recipientWithAddress = Optional.ofNullable(recipientAddressCache.get(serviceId));
|
var recipientWithAddress = Optional.ofNullable(recipientAddressCache.get(serviceId));
|
||||||
if (recipientWithAddress.isPresent()) {
|
if (recipientWithAddress.isPresent()) {
|
||||||
@ -1394,7 +1424,8 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Set<RecipientWithAddress> findAllByAddress(
|
private Set<RecipientWithAddress> findAllByAddress(
|
||||||
final Connection connection, final RecipientAddress address
|
final Connection connection,
|
||||||
|
final RecipientAddress address
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
final var sql = """
|
final var sql = """
|
||||||
SELECT r._id, r.number, r.aci, r.pni, r.username
|
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(
|
private ExpiringProfileKeyCredential getExpiringProfileKeyCredential(
|
||||||
final Connection connection, final RecipientId recipientId
|
final Connection connection,
|
||||||
|
final RecipientId recipientId
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
final var sql = (
|
final var sql = (
|
||||||
"""
|
"""
|
||||||
@ -1593,7 +1625,9 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||||||
public interface RecipientMergeHandler {
|
public interface RecipientMergeHandler {
|
||||||
|
|
||||||
void mergeRecipients(
|
void mergeRecipients(
|
||||||
final Connection connection, RecipientId recipientId, RecipientId toBeMergedRecipientId
|
final Connection connection,
|
||||||
|
RecipientId recipientId,
|
||||||
|
RecipientId toBeMergedRecipientId
|
||||||
) throws SQLException;
|
) throws SQLException;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1617,7 +1651,8 @@ public class RecipientStore implements RecipientIdCreator, RecipientResolver, Re
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateRecipientAddress(
|
public void updateRecipientAddress(
|
||||||
final RecipientId recipientId, final RecipientAddress address
|
final RecipientId recipientId,
|
||||||
|
final RecipientAddress address
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
RecipientStore.this.updateRecipientAddress(connection, recipientId, address);
|
RecipientStore.this.updateRecipientAddress(connection, recipientId, address);
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,9 @@ public interface RecipientTrustedResolver {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RecipientId resolveRecipientTrusted(
|
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);
|
return recipientTrustedResolverSupplier.get().resolveRecipientTrusted(aci, pni, number);
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,10 @@ public class MessageSendLogStore implements AutoCloseable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<MessageSendLogEntry> findMessages(
|
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 = """
|
final var sql = """
|
||||||
SELECT group_id, content, content_hint, urgent
|
SELECT group_id, content, content_hint, urgent
|
||||||
@ -111,7 +114,10 @@ public class MessageSendLogStore implements AutoCloseable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public long insertIfPossible(
|
public long insertIfPossible(
|
||||||
long sentTimestamp, SendMessageResult sendMessageResult, ContentHint contentHint, boolean urgent
|
long sentTimestamp,
|
||||||
|
SendMessageResult sendMessageResult,
|
||||||
|
ContentHint contentHint,
|
||||||
|
boolean urgent
|
||||||
) {
|
) {
|
||||||
if (sendLogDisabled) {
|
if (sendLogDisabled) {
|
||||||
return -1;
|
return -1;
|
||||||
@ -129,7 +135,10 @@ public class MessageSendLogStore implements AutoCloseable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public long insertIfPossible(
|
public long insertIfPossible(
|
||||||
long sentTimestamp, List<SendMessageResult> sendMessageResults, ContentHint contentHint, boolean urgent
|
long sentTimestamp,
|
||||||
|
List<SendMessageResult> sendMessageResults,
|
||||||
|
ContentHint contentHint,
|
||||||
|
boolean urgent
|
||||||
) {
|
) {
|
||||||
if (sendLogDisabled) {
|
if (sendLogDisabled) {
|
||||||
return -1;
|
return -1;
|
||||||
@ -164,7 +173,8 @@ public class MessageSendLogStore implements AutoCloseable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addRecipientToExistingEntryIfPossible(
|
public void addRecipientToExistingEntryIfPossible(
|
||||||
final long contentId, final List<SendMessageResult> sendMessageResults
|
final long contentId,
|
||||||
|
final List<SendMessageResult> sendMessageResults
|
||||||
) {
|
) {
|
||||||
if (sendLogDisabled) {
|
if (sendLogDisabled) {
|
||||||
return;
|
return;
|
||||||
@ -322,7 +332,8 @@ public class MessageSendLogStore implements AutoCloseable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void insertRecipientsForExistingContent(
|
private void insertRecipientsForExistingContent(
|
||||||
final long contentId, final List<RecipientDevices> recipientDevices
|
final long contentId,
|
||||||
|
final List<RecipientDevices> recipientDevices
|
||||||
) {
|
) {
|
||||||
try (final var connection = database.getConnection()) {
|
try (final var connection = database.getConnection()) {
|
||||||
connection.setAutoCommit(false);
|
connection.setAutoCommit(false);
|
||||||
@ -334,7 +345,9 @@ public class MessageSendLogStore implements AutoCloseable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void insertRecipientsForExistingContent(
|
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 {
|
) throws SQLException {
|
||||||
final var sql = """
|
final var sql = """
|
||||||
INSERT INTO %s (address, device_id, content_id)
|
INSERT INTO %s (address, device_id, content_id)
|
||||||
|
@ -59,7 +59,9 @@ public class SenderKeyRecordStore implements SenderKeyStore {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void storeSenderKey(
|
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);
|
final var key = getKey(address, distributionId);
|
||||||
|
|
||||||
@ -165,7 +167,9 @@ public class SenderKeyRecordStore implements SenderKeyStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void storeSenderKey(
|
private void storeSenderKey(
|
||||||
final Connection connection, final Key key, final SenderKeyRecord senderKeyRecord
|
final Connection connection,
|
||||||
|
final Key key,
|
||||||
|
final SenderKeyRecord senderKeyRecord
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
final var sqlUpdate = """
|
final var sqlUpdate = """
|
||||||
UPDATE %s
|
UPDATE %s
|
||||||
|
@ -65,7 +65,8 @@ public class SenderKeySharedStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void markSenderKeySharedWith(
|
public void markSenderKeySharedWith(
|
||||||
final DistributionId distributionId, final Collection<SignalProtocolAddress> addresses
|
final DistributionId distributionId,
|
||||||
|
final Collection<SignalProtocolAddress> addresses
|
||||||
) {
|
) {
|
||||||
final var newEntries = addresses.stream()
|
final var newEntries = addresses.stream()
|
||||||
.map(a -> new SenderKeySharedEntry(a.getName(), a.getDeviceId()))
|
.map(a -> new SenderKeySharedEntry(a.getName(), a.getDeviceId()))
|
||||||
@ -138,9 +139,7 @@ public class SenderKeySharedStore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteSharedWith(
|
public void deleteSharedWith(final ServiceId serviceId, final int deviceId, final DistributionId distributionId) {
|
||||||
final ServiceId serviceId, final int deviceId, final DistributionId distributionId
|
|
||||||
) {
|
|
||||||
try (final var connection = database.getConnection()) {
|
try (final var connection = database.getConnection()) {
|
||||||
final var sql = (
|
final var sql = (
|
||||||
"""
|
"""
|
||||||
@ -192,7 +191,9 @@ public class SenderKeySharedStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void markSenderKeysSharedWith(
|
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 {
|
) throws SQLException {
|
||||||
final var sql = (
|
final var sql = (
|
||||||
"""
|
"""
|
||||||
|
@ -25,7 +25,9 @@ public class SenderKeyStore implements SignalServiceSenderKeyStore {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void storeSenderKey(
|
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);
|
senderKeyRecordStore.storeSenderKey(sender, distributionId, record);
|
||||||
}
|
}
|
||||||
@ -42,7 +44,8 @@ public class SenderKeyStore implements SignalServiceSenderKeyStore {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void markSenderKeySharedWith(
|
public void markSenderKeySharedWith(
|
||||||
final DistributionId distributionId, final Collection<SignalProtocolAddress> addresses
|
final DistributionId distributionId,
|
||||||
|
final Collection<SignalProtocolAddress> addresses
|
||||||
) {
|
) {
|
||||||
senderKeySharedStore.markSenderKeySharedWith(distributionId, addresses);
|
senderKeySharedStore.markSenderKeySharedWith(distributionId, addresses);
|
||||||
}
|
}
|
||||||
|
@ -342,7 +342,9 @@ public class SessionStore implements SignalServiceSessionStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void storeSession(
|
private void storeSession(
|
||||||
final Connection connection, final Key key, final SessionRecord session
|
final Connection connection,
|
||||||
|
final Key key,
|
||||||
|
final SessionRecord session
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
synchronized (cachedSessions) {
|
synchronized (cachedSessions) {
|
||||||
cachedSessions.put(key, session);
|
cachedSessions.put(key, session);
|
||||||
|
@ -35,7 +35,9 @@ public class LegacyJsonThreadStore {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(
|
public void serialize(
|
||||||
final Map<?, ?> value, final JsonGenerator jgen, final SerializerProvider provider
|
final Map<?, ?> value,
|
||||||
|
final JsonGenerator jgen,
|
||||||
|
final SerializerProvider provider
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
jgen.writeObject(value.values());
|
jgen.writeObject(value.values());
|
||||||
}
|
}
|
||||||
@ -45,7 +47,8 @@ public class LegacyJsonThreadStore {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, LegacyThreadInfo> deserialize(
|
public Map<String, LegacyThreadInfo> deserialize(
|
||||||
JsonParser jsonParser, DeserializationContext deserializationContext
|
JsonParser jsonParser,
|
||||||
|
DeserializationContext deserializationContext
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
var threads = new HashMap<String, LegacyThreadInfo>();
|
var threads = new HashMap<String, LegacyThreadInfo>();
|
||||||
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
|
JsonNode node = jsonParser.getCodec().readTree(jsonParser);
|
||||||
|
@ -33,7 +33,9 @@ public class AccountRecordProcessor extends DefaultStorageRecordProcessor<Signal
|
|||||||
private final JobExecutor jobExecutor;
|
private final JobExecutor jobExecutor;
|
||||||
|
|
||||||
public AccountRecordProcessor(
|
public AccountRecordProcessor(
|
||||||
SignalAccount account, Connection connection, final JobExecutor jobExecutor
|
SignalAccount account,
|
||||||
|
Connection connection,
|
||||||
|
final JobExecutor jobExecutor
|
||||||
) throws SQLException {
|
) throws SQLException {
|
||||||
this.account = account;
|
this.account = account;
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
|
@ -91,9 +91,7 @@ public class ContactRecordProcessor extends DefaultStorageRecordProcessor<Signal
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SignalContactRecord merge(
|
protected SignalContactRecord merge(SignalContactRecord remote, SignalContactRecord local) {
|
||||||
SignalContactRecord remote, SignalContactRecord local
|
|
||||||
) {
|
|
||||||
String profileGivenName;
|
String profileGivenName;
|
||||||
String profileFamilyName;
|
String profileFamilyName;
|
||||||
if (remote.getProfileGivenName().isPresent() || remote.getProfileFamilyName().isPresent()) {
|
if (remote.getProfileGivenName().isPresent() || remote.getProfileFamilyName().isPresent()) {
|
||||||
|
@ -80,7 +80,9 @@ public final class StorageSyncModels {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static SignalStorageRecord localToRemoteRecord(
|
public static SignalStorageRecord localToRemoteRecord(
|
||||||
Recipient recipient, IdentityInfo identity, byte[] rawStorageId
|
Recipient recipient,
|
||||||
|
IdentityInfo identity,
|
||||||
|
byte[] rawStorageId
|
||||||
) {
|
) {
|
||||||
final var address = recipient.getAddress();
|
final var address = recipient.getAddress();
|
||||||
final var builder = new SignalContactRecord.Builder(rawStorageId,
|
final var builder = new SignalContactRecord.Builder(rawStorageId,
|
||||||
@ -121,9 +123,7 @@ public final class StorageSyncModels {
|
|||||||
return SignalStorageRecord.forContact(builder.build());
|
return SignalStorageRecord.forContact(builder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SignalStorageRecord localToRemoteRecord(
|
public static SignalStorageRecord localToRemoteRecord(GroupInfoV1 group, byte[] rawStorageId) {
|
||||||
GroupInfoV1 group, byte[] rawStorageId
|
|
||||||
) {
|
|
||||||
final var builder = new SignalGroupV1Record.Builder(rawStorageId,
|
final var builder = new SignalGroupV1Record.Builder(rawStorageId,
|
||||||
group.getGroupId().serialize(),
|
group.getGroupId().serialize(),
|
||||||
group.getStorageRecord());
|
group.getStorageRecord());
|
||||||
@ -133,9 +133,7 @@ public final class StorageSyncModels {
|
|||||||
return SignalStorageRecord.forGroupV1(builder.build());
|
return SignalStorageRecord.forGroupV1(builder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SignalStorageRecord localToRemoteRecord(
|
public static SignalStorageRecord localToRemoteRecord(GroupInfoV2 group, byte[] rawStorageId) {
|
||||||
GroupInfoV2 group, byte[] rawStorageId
|
|
||||||
) {
|
|
||||||
final var builder = new SignalGroupV2Record.Builder(rawStorageId,
|
final var builder = new SignalGroupV2Record.Builder(rawStorageId,
|
||||||
group.getMasterKey(),
|
group.getMasterKey(),
|
||||||
group.getStorageRecord());
|
group.getStorageRecord());
|
||||||
|
@ -112,13 +112,17 @@ public final class StorageSyncValidations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void validateForcePush(
|
public static void validateForcePush(
|
||||||
SignalStorageManifest manifest, List<SignalStorageRecord> inserts, RecipientAddress self
|
SignalStorageManifest manifest,
|
||||||
|
List<SignalStorageRecord> inserts,
|
||||||
|
RecipientAddress self
|
||||||
) {
|
) {
|
||||||
validateManifestAndInserts(manifest, inserts, self);
|
validateManifestAndInserts(manifest, inserts, self);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void validateManifestAndInserts(
|
private static void validateManifestAndInserts(
|
||||||
SignalStorageManifest manifest, List<SignalStorageRecord> inserts, RecipientAddress self
|
SignalStorageManifest manifest,
|
||||||
|
List<SignalStorageRecord> inserts,
|
||||||
|
RecipientAddress self
|
||||||
) {
|
) {
|
||||||
int accountCount = 0;
|
int accountCount = 0;
|
||||||
for (StorageId id : manifest.getStorageIds()) {
|
for (StorageId id : manifest.getStorageIds()) {
|
||||||
|
@ -13,7 +13,8 @@ import java.util.UUID;
|
|||||||
public class AttachmentUtils {
|
public class AttachmentUtils {
|
||||||
|
|
||||||
public static SignalServiceAttachmentStream createAttachmentStream(
|
public static SignalServiceAttachmentStream createAttachmentStream(
|
||||||
String attachment, ResumableUploadSpec resumableUploadSpec
|
String attachment,
|
||||||
|
ResumableUploadSpec resumableUploadSpec
|
||||||
) throws AttachmentInvalidException {
|
) throws AttachmentInvalidException {
|
||||||
try {
|
try {
|
||||||
final var streamDetails = Utils.createStreamDetails(attachment);
|
final var streamDetails = Utils.createStreamDetails(attachment);
|
||||||
@ -25,7 +26,9 @@ public class AttachmentUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static SignalServiceAttachmentStream createAttachmentStream(
|
public static SignalServiceAttachmentStream createAttachmentStream(
|
||||||
StreamDetails streamDetails, Optional<String> name, ResumableUploadSpec resumableUploadSpec
|
StreamDetails streamDetails,
|
||||||
|
Optional<String> name,
|
||||||
|
ResumableUploadSpec resumableUploadSpec
|
||||||
) throws ResumeLocationInvalidException {
|
) throws ResumeLocationInvalidException {
|
||||||
// TODO maybe add a parameter to set the voiceNote, borderless, preview, width, height and caption option
|
// TODO maybe add a parameter to set the voiceNote, borderless, preview, width, height and caption option
|
||||||
final var uploadTimestamp = System.currentTimeMillis();
|
final var uploadTimestamp = System.currentTimeMillis();
|
||||||
|
@ -63,7 +63,8 @@ public class KeyUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static SignedPreKeyRecord generateSignedPreKeyRecord(
|
public static SignedPreKeyRecord generateSignedPreKeyRecord(
|
||||||
final int signedPreKeyId, final ECPrivateKey privateKey
|
final int signedPreKeyId,
|
||||||
|
final ECPrivateKey privateKey
|
||||||
) {
|
) {
|
||||||
var keyPair = Curve.generateKeyPair();
|
var keyPair = Curve.generateKeyPair();
|
||||||
byte[] signature;
|
byte[] signature;
|
||||||
@ -75,9 +76,7 @@ public class KeyUtils {
|
|||||||
return new SignedPreKeyRecord(signedPreKeyId, System.currentTimeMillis(), keyPair, signature);
|
return new SignedPreKeyRecord(signedPreKeyId, System.currentTimeMillis(), keyPair, signature);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<KyberPreKeyRecord> generateKyberPreKeyRecords(
|
public static List<KyberPreKeyRecord> generateKyberPreKeyRecords(final int offset, final ECPrivateKey privateKey) {
|
||||||
final int offset, final ECPrivateKey privateKey
|
|
||||||
) {
|
|
||||||
var records = new ArrayList<KyberPreKeyRecord>(PREKEY_BATCH_SIZE);
|
var records = new ArrayList<KyberPreKeyRecord>(PREKEY_BATCH_SIZE);
|
||||||
for (var i = 0; i < PREKEY_BATCH_SIZE; i++) {
|
for (var i = 0; i < PREKEY_BATCH_SIZE; i++) {
|
||||||
var preKeyId = (offset + i) % PREKEY_MAXIMUM_ID;
|
var preKeyId = (offset + i) % PREKEY_MAXIMUM_ID;
|
||||||
|
@ -88,7 +88,9 @@ public class NumberVerificationUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void requestVerificationCode(
|
public static void requestVerificationCode(
|
||||||
RegistrationApi registrationApi, String sessionId, boolean voiceVerification
|
RegistrationApi registrationApi,
|
||||||
|
String sessionId,
|
||||||
|
boolean voiceVerification
|
||||||
) throws IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException {
|
) throws IOException, CaptchaRequiredException, NonNormalizedPhoneNumberException {
|
||||||
final var locale = Utils.getDefaultLocale(Locale.US);
|
final var locale = Utils.getDefaultLocale(Locale.US);
|
||||||
final var response = registrationApi.requestSmsVerificationCode(sessionId,
|
final var response = registrationApi.requestSmsVerificationCode(sessionId,
|
||||||
@ -108,7 +110,11 @@ public class NumberVerificationUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Pair<VerifyAccountResponse, MasterKey> verifyNumber(
|
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 {
|
) throws IOException, PinLockedException, IncorrectPinException {
|
||||||
verificationCode = verificationCode.replace("-", "");
|
verificationCode = verificationCode.replace("-", "");
|
||||||
try {
|
try {
|
||||||
@ -138,7 +144,8 @@ public class NumberVerificationUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static RegistrationSessionMetadataResponse validateSession(
|
private static RegistrationSessionMetadataResponse validateSession(
|
||||||
final RegistrationApi registrationApi, final String sessionId
|
final RegistrationApi registrationApi,
|
||||||
|
final String sessionId
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
if (sessionId == null || sessionId.isEmpty()) {
|
if (sessionId == null || sessionId.isEmpty()) {
|
||||||
throw new NoSuchSessionException();
|
throw new NoSuchSessionException();
|
||||||
@ -153,7 +160,8 @@ public class NumberVerificationUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static RegistrationSessionMetadataResponse getValidSession(
|
private static RegistrationSessionMetadataResponse getValidSession(
|
||||||
final RegistrationApi registrationApi, final String sessionId
|
final RegistrationApi registrationApi,
|
||||||
|
final String sessionId
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
try {
|
try {
|
||||||
return validateSession(registrationApi, sessionId);
|
return validateSession(registrationApi, sessionId);
|
||||||
@ -164,7 +172,9 @@ public class NumberVerificationUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static RegistrationSessionMetadataResponse submitCaptcha(
|
private static RegistrationSessionMetadataResponse submitCaptcha(
|
||||||
RegistrationApi registrationApi, String sessionId, String captcha
|
RegistrationApi registrationApi,
|
||||||
|
String sessionId,
|
||||||
|
String captcha
|
||||||
) throws IOException, CaptchaRequiredException {
|
) throws IOException, CaptchaRequiredException {
|
||||||
captcha = captcha == null ? null : captcha.replace("signalcaptcha://", "");
|
captcha = captcha == null ? null : captcha.replace("signalcaptcha://", "");
|
||||||
try {
|
try {
|
||||||
@ -184,7 +194,9 @@ public class NumberVerificationUtils {
|
|||||||
public interface Verifier {
|
public interface Verifier {
|
||||||
|
|
||||||
VerifyAccountResponse verify(
|
VerifyAccountResponse verify(
|
||||||
String sessionId, String verificationCode, String registrationLock
|
String sessionId,
|
||||||
|
String verificationCode,
|
||||||
|
String registrationLock
|
||||||
) throws IOException;
|
) 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.
|
* 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(
|
public static PaymentAddress signPaymentsAddress(byte[] publicAddressBytes, ECPrivateKey privateKey) {
|
||||||
byte[] publicAddressBytes, ECPrivateKey privateKey
|
|
||||||
) {
|
|
||||||
byte[] signature = privateKey.calculateSignature(publicAddressBytes);
|
byte[] signature = privateKey.calculateSignature(publicAddressBytes);
|
||||||
|
|
||||||
return new PaymentAddress.Builder().mobileCoinAddress(new PaymentAddress.MobileCoinAddress.Builder().address(
|
return new PaymentAddress.Builder().mobileCoinAddress(new PaymentAddress.MobileCoinAddress.Builder().address(
|
||||||
@ -34,9 +32,7 @@ public class PaymentUtils {
|
|||||||
* <p>
|
* <p>
|
||||||
* Returns the validated bytes if so, otherwise returns null.
|
* Returns the validated bytes if so, otherwise returns null.
|
||||||
*/
|
*/
|
||||||
public static byte[] verifyPaymentsAddress(
|
public static byte[] verifyPaymentsAddress(PaymentAddress paymentAddress, ECPublicKey publicKey) {
|
||||||
PaymentAddress paymentAddress, ECPublicKey publicKey
|
|
||||||
) {
|
|
||||||
final var mobileCoinAddress = paymentAddress.mobileCoinAddress;
|
final var mobileCoinAddress = paymentAddress.mobileCoinAddress;
|
||||||
if (mobileCoinAddress == null || mobileCoinAddress.address == null || mobileCoinAddress.signature == null) {
|
if (mobileCoinAddress == null || mobileCoinAddress.address == null || mobileCoinAddress.signature == null) {
|
||||||
logger.debug("Got payment address without mobile coin address, ignoring.");
|
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);
|
private static final Logger logger = LoggerFactory.getLogger(ProfileUtils.class);
|
||||||
|
|
||||||
public static Profile decryptProfile(
|
public static Profile decryptProfile(final ProfileKey profileKey, final SignalServiceProfile encryptedProfile) {
|
||||||
final ProfileKey profileKey, final SignalServiceProfile encryptedProfile
|
|
||||||
) {
|
|
||||||
var profileCipher = new ProfileCipher(profileKey);
|
var profileCipher = new ProfileCipher(profileKey);
|
||||||
IdentityKey identityKey = null;
|
IdentityKey identityKey = null;
|
||||||
try {
|
try {
|
||||||
@ -64,7 +62,8 @@ public class ProfileUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Profile.UnidentifiedAccessMode getUnidentifiedAccessMode(
|
public static Profile.UnidentifiedAccessMode getUnidentifiedAccessMode(
|
||||||
final SignalServiceProfile encryptedProfile, final ProfileCipher profileCipher
|
final SignalServiceProfile encryptedProfile,
|
||||||
|
final ProfileCipher profileCipher
|
||||||
) {
|
) {
|
||||||
if (encryptedProfile.isUnrestrictedUnidentifiedAccess()) {
|
if (encryptedProfile.isUnrestrictedUnidentifiedAccess()) {
|
||||||
return Profile.UnidentifiedAccessMode.UNRESTRICTED;
|
return Profile.UnidentifiedAccessMode.UNRESTRICTED;
|
||||||
@ -90,7 +89,8 @@ public class ProfileUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String decryptString(
|
private static String decryptString(
|
||||||
final String encrypted, final ProfileCipher profileCipher
|
final String encrypted,
|
||||||
|
final ProfileCipher profileCipher
|
||||||
) throws InvalidCiphertextException {
|
) throws InvalidCiphertextException {
|
||||||
try {
|
try {
|
||||||
return encrypted == null ? null : profileCipher.decryptString(Base64.getDecoder().decode(encrypted));
|
return encrypted == null ? null : profileCipher.decryptString(Base64.getDecoder().decode(encrypted));
|
||||||
@ -100,7 +100,8 @@ public class ProfileUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Optional<Boolean> decryptBoolean(
|
private static Optional<Boolean> decryptBoolean(
|
||||||
final String encrypted, final ProfileCipher profileCipher
|
final String encrypted,
|
||||||
|
final ProfileCipher profileCipher
|
||||||
) throws InvalidCiphertextException {
|
) throws InvalidCiphertextException {
|
||||||
try {
|
try {
|
||||||
return encrypted == null
|
return encrypted == null
|
||||||
@ -112,7 +113,9 @@ public class ProfileUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static byte[] decryptAndVerifyMobileCoinAddress(
|
private static byte[] decryptAndVerifyMobileCoinAddress(
|
||||||
final byte[] encryptedPaymentAddress, final ProfileCipher profileCipher, final ECPublicKey publicKey
|
final byte[] encryptedPaymentAddress,
|
||||||
|
final ProfileCipher profileCipher,
|
||||||
|
final ECPublicKey publicKey
|
||||||
) throws InvalidCiphertextException {
|
) throws InvalidCiphertextException {
|
||||||
byte[] decrypted;
|
byte[] decrypted;
|
||||||
try {
|
try {
|
||||||
|
@ -100,7 +100,9 @@ public class StickerUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Pair<InputStream, Long> getInputStreamAndLength(
|
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 {
|
) throws IOException {
|
||||||
if (zip != null) {
|
if (zip != null) {
|
||||||
final var entry = zip.getEntry(subfile);
|
final var entry = zip.getEntry(subfile);
|
||||||
@ -112,7 +114,9 @@ public class StickerUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String getContentType(
|
private static String getContentType(
|
||||||
final String rootPath, final ZipFile zip, final String subfile
|
final String rootPath,
|
||||||
|
final ZipFile zip,
|
||||||
|
final String subfile
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
if (zip != null) {
|
if (zip != null) {
|
||||||
final var entry = zip.getEntry(subfile);
|
final var entry = zip.getEntry(subfile);
|
||||||
|
@ -59,7 +59,10 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Fingerprint computeSafetyNumberForNumber(
|
public static Fingerprint computeSafetyNumberForNumber(
|
||||||
String ownNumber, IdentityKey ownIdentityKey, String theirNumber, IdentityKey theirIdentityKey
|
String ownNumber,
|
||||||
|
IdentityKey ownIdentityKey,
|
||||||
|
String theirNumber,
|
||||||
|
IdentityKey theirIdentityKey
|
||||||
) {
|
) {
|
||||||
// Version 1: E164 user
|
// Version 1: E164 user
|
||||||
final var version = 1;
|
final var version = 1;
|
||||||
@ -70,7 +73,10 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Fingerprint computeSafetyNumberForUuid(
|
public static Fingerprint computeSafetyNumberForUuid(
|
||||||
ServiceId ownServiceId, IdentityKey ownIdentityKey, ServiceId theirServiceId, IdentityKey theirIdentityKey
|
ServiceId ownServiceId,
|
||||||
|
IdentityKey ownIdentityKey,
|
||||||
|
ServiceId theirServiceId,
|
||||||
|
IdentityKey theirIdentityKey
|
||||||
) {
|
) {
|
||||||
// Version 2: UUID user
|
// Version 2: UUID user
|
||||||
final var version = 2;
|
final var version = 2;
|
||||||
|
@ -217,9 +217,7 @@ class MergeRecipientHelperTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateRecipientAddress(
|
public void updateRecipientAddress(final RecipientId recipientId, final RecipientAddress address) {
|
||||||
final RecipientId recipientId, final RecipientAddress address
|
|
||||||
) {
|
|
||||||
recipients.removeIf(r -> r.id().equals(recipientId));
|
recipients.removeIf(r -> r.id().equals(recipientId));
|
||||||
recipients.add(new RecipientWithAddress(recipientId, address));
|
recipients.add(new RecipientWithAddress(recipientId, address));
|
||||||
}
|
}
|
||||||
|
@ -27,39 +27,44 @@ public interface Signal extends DBusInterface {
|
|||||||
void unsubscribeReceive();
|
void unsubscribeReceive();
|
||||||
|
|
||||||
long sendMessage(
|
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;
|
) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber, Error.UntrustedIdentity;
|
||||||
|
|
||||||
long sendMessage(
|
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;
|
) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber, Error.UntrustedIdentity;
|
||||||
|
|
||||||
void sendTyping(
|
void sendTyping(String recipient, boolean stop) throws Error.Failure, Error.UntrustedIdentity;
|
||||||
String recipient, boolean stop
|
|
||||||
) throws Error.Failure, Error.UntrustedIdentity;
|
|
||||||
|
|
||||||
void sendReadReceipt(
|
void sendReadReceipt(String recipient, List<Long> messageIds) throws Error.Failure, Error.UntrustedIdentity;
|
||||||
String recipient, List<Long> messageIds
|
|
||||||
) throws Error.Failure, Error.UntrustedIdentity;
|
|
||||||
|
|
||||||
void sendViewedReceipt(
|
void sendViewedReceipt(String recipient, List<Long> messageIds) throws Error.Failure, Error.UntrustedIdentity;
|
||||||
String recipient, List<Long> messageIds
|
|
||||||
) throws Error.Failure, Error.UntrustedIdentity;
|
long sendRemoteDeleteMessage(long targetSentTimestamp, String recipient) throws Error.Failure, Error.InvalidNumber;
|
||||||
|
|
||||||
long sendRemoteDeleteMessage(
|
long sendRemoteDeleteMessage(
|
||||||
long targetSentTimestamp, String recipient
|
long targetSentTimestamp,
|
||||||
) throws Error.Failure, Error.InvalidNumber;
|
List<String> recipients
|
||||||
|
|
||||||
long sendRemoteDeleteMessage(
|
|
||||||
long targetSentTimestamp, List<String> recipients
|
|
||||||
) throws Error.Failure, Error.InvalidNumber;
|
) throws Error.Failure, Error.InvalidNumber;
|
||||||
|
|
||||||
long sendMessageReaction(
|
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;
|
) throws Error.InvalidNumber, Error.Failure;
|
||||||
|
|
||||||
long sendMessageReaction(
|
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;
|
) throws Error.InvalidNumber, Error.Failure;
|
||||||
|
|
||||||
long sendPaymentNotification(byte[] receipt, String note, String recipient) throws 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;
|
void sendSyncRequest() throws Error.Failure;
|
||||||
|
|
||||||
long sendNoteToSelfMessage(
|
long sendNoteToSelfMessage(String message, List<String> attachments) throws Error.AttachmentInvalid, Error.Failure;
|
||||||
String message, List<String> attachments
|
|
||||||
) throws Error.AttachmentInvalid, Error.Failure;
|
|
||||||
|
|
||||||
void sendEndSessionMessage(List<String> recipients) throws Error.Failure, Error.InvalidNumber, Error.UntrustedIdentity;
|
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;
|
void deleteContact(final String recipient) throws Error.Failure;
|
||||||
|
|
||||||
long sendGroupMessage(
|
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;
|
) throws Error.GroupNotFound, Error.Failure, Error.AttachmentInvalid, Error.InvalidGroupId;
|
||||||
|
|
||||||
void sendGroupTyping(
|
void sendGroupTyping(
|
||||||
final byte[] groupId, final boolean stop
|
final byte[] groupId,
|
||||||
|
final boolean stop
|
||||||
) throws Error.Failure, Error.GroupNotFound, Error.UntrustedIdentity;
|
) throws Error.Failure, Error.GroupNotFound, Error.UntrustedIdentity;
|
||||||
|
|
||||||
long sendGroupRemoteDeleteMessage(
|
long sendGroupRemoteDeleteMessage(
|
||||||
long targetSentTimestamp, byte[] groupId
|
long targetSentTimestamp,
|
||||||
|
byte[] groupId
|
||||||
) throws Error.Failure, Error.GroupNotFound, Error.InvalidGroupId;
|
) throws Error.Failure, Error.GroupNotFound, Error.InvalidGroupId;
|
||||||
|
|
||||||
long sendGroupMessageReaction(
|
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;
|
) throws Error.GroupNotFound, Error.Failure, Error.InvalidNumber, Error.InvalidGroupId;
|
||||||
|
|
||||||
String getContactName(String number) throws Error.InvalidNumber;
|
String getContactName(String number) throws Error.InvalidNumber;
|
||||||
@ -119,12 +130,17 @@ public interface Signal extends DBusInterface {
|
|||||||
List<String> getGroupMembers(byte[] groupId) throws Error.InvalidGroupId;
|
List<String> getGroupMembers(byte[] groupId) throws Error.InvalidGroupId;
|
||||||
|
|
||||||
byte[] createGroup(
|
byte[] createGroup(
|
||||||
String name, List<String> members, String avatar
|
String name,
|
||||||
|
List<String> members,
|
||||||
|
String avatar
|
||||||
) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber;
|
) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber;
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
byte[] updateGroup(
|
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;
|
) throws Error.AttachmentInvalid, Error.Failure, Error.InvalidNumber, Error.GroupNotFound, Error.InvalidGroupId;
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@ -156,7 +172,11 @@ public interface Signal extends DBusInterface {
|
|||||||
) throws Error.Failure;
|
) throws Error.Failure;
|
||||||
|
|
||||||
void updateProfile(
|
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;
|
) throws Error.Failure;
|
||||||
|
|
||||||
void removePin();
|
void removePin();
|
||||||
|
@ -13,11 +13,14 @@ import java.util.List;
|
|||||||
public interface SignalControl extends DBusInterface {
|
public interface SignalControl extends DBusInterface {
|
||||||
|
|
||||||
void register(
|
void register(
|
||||||
String number, boolean voiceVerification
|
String number,
|
||||||
|
boolean voiceVerification
|
||||||
) throws Error.Failure, Error.InvalidNumber, Error.RequiresCaptcha;
|
) throws Error.Failure, Error.InvalidNumber, Error.RequiresCaptcha;
|
||||||
|
|
||||||
void registerWithCaptcha(
|
void registerWithCaptcha(
|
||||||
String number, boolean voiceVerification, String captcha
|
String number,
|
||||||
|
boolean voiceVerification,
|
||||||
|
String captcha
|
||||||
) throws Error.Failure, Error.InvalidNumber, Error.RequiresCaptcha;
|
) throws Error.Failure, Error.InvalidNumber, Error.RequiresCaptcha;
|
||||||
|
|
||||||
void verify(String number, String verificationCode) throws Error.Failure, Error.InvalidNumber;
|
void verify(String number, String verificationCode) throws Error.Failure, Error.InvalidNumber;
|
||||||
|
@ -292,7 +292,8 @@ public class App {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private RegistrationManager loadRegistrationManager(
|
private RegistrationManager loadRegistrationManager(
|
||||||
final String account, final SignalAccountFiles signalAccountFiles
|
final String account,
|
||||||
|
final SignalAccountFiles signalAccountFiles
|
||||||
) throws UnexpectedErrorException {
|
) throws UnexpectedErrorException {
|
||||||
try {
|
try {
|
||||||
return signalAccountFiles.initRegistrationManager(account);
|
return signalAccountFiles.initRegistrationManager(account);
|
||||||
@ -306,7 +307,8 @@ public class App {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Manager loadManager(
|
private Manager loadManager(
|
||||||
final String account, final SignalAccountFiles signalAccountFiles
|
final String account,
|
||||||
|
final SignalAccountFiles signalAccountFiles
|
||||||
) throws CommandException {
|
) throws CommandException {
|
||||||
logger.trace("Loading account file for {}", account);
|
logger.trace("Loading account file for {}", account);
|
||||||
try {
|
try {
|
||||||
|
@ -101,9 +101,7 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
|||||||
writer.println();
|
writer.println();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printDataMessage(
|
private void printDataMessage(PlainTextWriter writer, MessageEnvelope.Data message) {
|
||||||
PlainTextWriter writer, MessageEnvelope.Data message
|
|
||||||
) {
|
|
||||||
writer.println("Message timestamp: {}", DateUtils.formatTimestamp(message.timestamp()));
|
writer.println("Message timestamp: {}", DateUtils.formatTimestamp(message.timestamp()));
|
||||||
if (message.isViewOnce()) {
|
if (message.isViewOnce()) {
|
||||||
writer.println("=VIEW ONCE=");
|
writer.println("=VIEW ONCE=");
|
||||||
@ -197,16 +195,12 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printEditMessage(
|
private void printEditMessage(PlainTextWriter writer, MessageEnvelope.Edit message) {
|
||||||
PlainTextWriter writer, MessageEnvelope.Edit message
|
|
||||||
) {
|
|
||||||
writer.println("Edit: Target message timestamp: {}", DateUtils.formatTimestamp(message.targetSentTimestamp()));
|
writer.println("Edit: Target message timestamp: {}", DateUtils.formatTimestamp(message.targetSentTimestamp()));
|
||||||
printDataMessage(writer.indentedWriter(), message.dataMessage());
|
printDataMessage(writer.indentedWriter(), message.dataMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printStoryMessage(
|
private void printStoryMessage(PlainTextWriter writer, MessageEnvelope.Story message) {
|
||||||
PlainTextWriter writer, MessageEnvelope.Story message
|
|
||||||
) {
|
|
||||||
writer.println("Story: with replies: {}", message.allowsReplies());
|
writer.println("Story: with replies: {}", message.allowsReplies());
|
||||||
if (message.groupId().isPresent()) {
|
if (message.groupId().isPresent()) {
|
||||||
writer.println("Group info:");
|
writer.println("Group info:");
|
||||||
@ -226,9 +220,7 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printTypingMessage(
|
private void printTypingMessage(final PlainTextWriter writer, final MessageEnvelope.Typing typingMessage) {
|
||||||
final PlainTextWriter writer, final MessageEnvelope.Typing typingMessage
|
|
||||||
) {
|
|
||||||
writer.println("Action: {}", typingMessage.type());
|
writer.println("Action: {}", typingMessage.type());
|
||||||
writer.println("Timestamp: {}", DateUtils.formatTimestamp(typingMessage.timestamp()));
|
writer.println("Timestamp: {}", DateUtils.formatTimestamp(typingMessage.timestamp()));
|
||||||
if (typingMessage.groupId().isPresent()) {
|
if (typingMessage.groupId().isPresent()) {
|
||||||
@ -238,9 +230,7 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printReceiptMessage(
|
private void printReceiptMessage(final PlainTextWriter writer, final MessageEnvelope.Receipt receiptMessage) {
|
||||||
final PlainTextWriter writer, final MessageEnvelope.Receipt receiptMessage
|
|
||||||
) {
|
|
||||||
writer.println("When: {}", DateUtils.formatTimestamp(receiptMessage.when()));
|
writer.println("When: {}", DateUtils.formatTimestamp(receiptMessage.when()));
|
||||||
if (receiptMessage.type() == MessageEnvelope.Receipt.Type.DELIVERY) {
|
if (receiptMessage.type() == MessageEnvelope.Receipt.Type.DELIVERY) {
|
||||||
writer.println("Is delivery receipt");
|
writer.println("Is delivery receipt");
|
||||||
@ -257,9 +247,7 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printCallMessage(
|
private void printCallMessage(final PlainTextWriter writer, final MessageEnvelope.Call callMessage) {
|
||||||
final PlainTextWriter writer, final MessageEnvelope.Call callMessage
|
|
||||||
) {
|
|
||||||
if (callMessage.destinationDeviceId().isPresent()) {
|
if (callMessage.destinationDeviceId().isPresent()) {
|
||||||
final var deviceId = callMessage.destinationDeviceId().get();
|
final var deviceId = callMessage.destinationDeviceId().get();
|
||||||
writer.println("Destination device id: {}", deviceId);
|
writer.println("Destination device id: {}", deviceId);
|
||||||
@ -302,9 +290,7 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printSyncMessage(
|
private void printSyncMessage(final PlainTextWriter writer, final MessageEnvelope.Sync syncMessage) {
|
||||||
final PlainTextWriter writer, final MessageEnvelope.Sync syncMessage
|
|
||||||
) {
|
|
||||||
if (syncMessage.contacts().isPresent()) {
|
if (syncMessage.contacts().isPresent()) {
|
||||||
final var contactsMessage = syncMessage.contacts().get();
|
final var contactsMessage = syncMessage.contacts().get();
|
||||||
var type = contactsMessage.isComplete() ? "complete" : "partial";
|
var type = contactsMessage.isComplete() ? "complete" : "partial";
|
||||||
@ -392,9 +378,7 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printPreview(
|
private void printPreview(final PlainTextWriter writer, final MessageEnvelope.Data.Preview preview) {
|
||||||
final PlainTextWriter writer, final MessageEnvelope.Data.Preview preview
|
|
||||||
) {
|
|
||||||
writer.println("Title: {}", preview.title());
|
writer.println("Title: {}", preview.title());
|
||||||
writer.println("Description: {}", preview.description());
|
writer.println("Description: {}", preview.description());
|
||||||
writer.println("Date: {}", DateUtils.formatTimestamp(preview.date()));
|
writer.println("Date: {}", DateUtils.formatTimestamp(preview.date()));
|
||||||
@ -405,25 +389,19 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printSticker(
|
private void printSticker(final PlainTextWriter writer, final MessageEnvelope.Data.Sticker sticker) {
|
||||||
final PlainTextWriter writer, final MessageEnvelope.Data.Sticker sticker
|
|
||||||
) {
|
|
||||||
writer.println("Pack id: {}", Hex.toStringCondensed(sticker.packId().serialize()));
|
writer.println("Pack id: {}", Hex.toStringCondensed(sticker.packId().serialize()));
|
||||||
writer.println("Sticker id: {}", sticker.stickerId());
|
writer.println("Sticker id: {}", sticker.stickerId());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printReaction(
|
private void printReaction(final PlainTextWriter writer, final MessageEnvelope.Data.Reaction reaction) {
|
||||||
final PlainTextWriter writer, final MessageEnvelope.Data.Reaction reaction
|
|
||||||
) {
|
|
||||||
writer.println("Emoji: {}", reaction.emoji());
|
writer.println("Emoji: {}", reaction.emoji());
|
||||||
writer.println("Target author: {}", formatContact(reaction.targetAuthor()));
|
writer.println("Target author: {}", formatContact(reaction.targetAuthor()));
|
||||||
writer.println("Target timestamp: {}", DateUtils.formatTimestamp(reaction.targetSentTimestamp()));
|
writer.println("Target timestamp: {}", DateUtils.formatTimestamp(reaction.targetSentTimestamp()));
|
||||||
writer.println("Is remove: {}", reaction.isRemove());
|
writer.println("Is remove: {}", reaction.isRemove());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printQuote(
|
private void printQuote(final PlainTextWriter writer, final MessageEnvelope.Data.Quote quote) {
|
||||||
final PlainTextWriter writer, final MessageEnvelope.Data.Quote quote
|
|
||||||
) {
|
|
||||||
writer.println("Id: {}", quote.id());
|
writer.println("Id: {}", quote.id());
|
||||||
writer.println("Author: {}", formatContact(quote.author()));
|
writer.println("Author: {}", formatContact(quote.author()));
|
||||||
if (quote.text().isPresent()) {
|
if (quote.text().isPresent()) {
|
||||||
@ -541,17 +519,13 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printGroupContext(
|
private void printGroupContext(final PlainTextWriter writer, final MessageEnvelope.Data.GroupContext groupContext) {
|
||||||
final PlainTextWriter writer, final MessageEnvelope.Data.GroupContext groupContext
|
|
||||||
) {
|
|
||||||
printGroupInfo(writer, groupContext.groupId());
|
printGroupInfo(writer, groupContext.groupId());
|
||||||
writer.println("Revision: {}", groupContext.revision());
|
writer.println("Revision: {}", groupContext.revision());
|
||||||
writer.println("Type: {}", groupContext.isGroupUpdate() ? "UPDATE" : "DELIVER");
|
writer.println("Type: {}", groupContext.isGroupUpdate() ? "UPDATE" : "DELIVER");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printStoryContext(
|
private void printStoryContext(final PlainTextWriter writer, final MessageEnvelope.Data.StoryContext storyContext) {
|
||||||
final PlainTextWriter writer, final MessageEnvelope.Data.StoryContext storyContext
|
|
||||||
) {
|
|
||||||
writer.println("Sender: {}", formatContact(storyContext.author()));
|
writer.println("Sender: {}", formatContact(storyContext.author()));
|
||||||
writer.println("Sent timestamp: {}", storyContext.sentTimestamp());
|
writer.println("Sent timestamp: {}", storyContext.sentTimestamp());
|
||||||
}
|
}
|
||||||
@ -567,15 +541,11 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printMention(
|
private void printMention(PlainTextWriter writer, MessageEnvelope.Data.Mention mention) {
|
||||||
PlainTextWriter writer, MessageEnvelope.Data.Mention mention
|
|
||||||
) {
|
|
||||||
writer.println("- {}: {} (length: {})", formatContact(mention.recipient()), mention.start(), mention.length());
|
writer.println("- {}: {} (length: {})", formatContact(mention.recipient()), mention.start(), mention.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printTextStyle(
|
private void printTextStyle(PlainTextWriter writer, TextStyle textStyle) {
|
||||||
PlainTextWriter writer, TextStyle textStyle
|
|
||||||
) {
|
|
||||||
writer.println("- {}: {} (length: {})", textStyle.style().name(), textStyle.start(), textStyle.length());
|
writer.println("- {}: {} (length: {})", textStyle.style().name(), textStyle.start(), textStyle.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,9 @@ public class AddDeviceCommand implements JsonRpcLocalCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleCommand(
|
public void handleCommand(
|
||||||
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
final Namespace ns,
|
||||||
|
final Manager m,
|
||||||
|
final OutputWriter outputWriter
|
||||||
) throws CommandException {
|
) throws CommandException {
|
||||||
final URI linkUri;
|
final URI linkUri;
|
||||||
try {
|
try {
|
||||||
|
@ -36,7 +36,9 @@ public class AddStickerPackCommand implements JsonRpcLocalCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleCommand(
|
public void handleCommand(
|
||||||
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
final Namespace ns,
|
||||||
|
final Manager m,
|
||||||
|
final OutputWriter outputWriter
|
||||||
) throws CommandException {
|
) throws CommandException {
|
||||||
final var uris = ns.<String>getList("uri");
|
final var uris = ns.<String>getList("uri");
|
||||||
for (final var uri : uris) {
|
for (final var uri : uris) {
|
||||||
|
@ -35,7 +35,9 @@ public class BlockCommand implements JsonRpcLocalCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleCommand(
|
public void handleCommand(
|
||||||
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
final Namespace ns,
|
||||||
|
final Manager m,
|
||||||
|
final OutputWriter outputWriter
|
||||||
) throws CommandException {
|
) throws CommandException {
|
||||||
final var contacts = ns.<String>getList("recipient");
|
final var contacts = ns.<String>getList("recipient");
|
||||||
final var recipients = CommandUtil.getSingleRecipientIdentifiers(contacts, m.getSelfNumber());
|
final var recipients = CommandUtil.getSingleRecipientIdentifiers(contacts, m.getSelfNumber());
|
||||||
|
@ -20,13 +20,15 @@ public class CommandHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void handleProvisioningCommand(
|
public void handleProvisioningCommand(
|
||||||
final ProvisioningCommand command, final ProvisioningManager provisioningManager
|
final ProvisioningCommand command,
|
||||||
|
final ProvisioningManager provisioningManager
|
||||||
) throws CommandException {
|
) throws CommandException {
|
||||||
command.handleCommand(ns, provisioningManager, outputWriter);
|
command.handleCommand(ns, provisioningManager, outputWriter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleRegistrationCommand(
|
public void handleRegistrationCommand(
|
||||||
final RegistrationCommand command, final RegistrationManager registrationManager
|
final RegistrationCommand command,
|
||||||
|
final RegistrationManager registrationManager
|
||||||
) throws CommandException {
|
) throws CommandException {
|
||||||
command.handleCommand(ns, registrationManager);
|
command.handleCommand(ns, registrationManager);
|
||||||
}
|
}
|
||||||
@ -36,7 +38,8 @@ public class CommandHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void handleMultiLocalCommand(
|
public void handleMultiLocalCommand(
|
||||||
final MultiLocalCommand command, MultiAccountManager multiAccountManager
|
final MultiLocalCommand command,
|
||||||
|
MultiAccountManager multiAccountManager
|
||||||
) throws CommandException {
|
) throws CommandException {
|
||||||
command.handleCommand(ns, multiAccountManager, outputWriter);
|
command.handleCommand(ns, multiAccountManager, outputWriter);
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,9 @@ public class DaemonCommand implements MultiLocalCommand, LocalCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleCommand(
|
public void handleCommand(
|
||||||
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
final Namespace ns,
|
||||||
|
final Manager m,
|
||||||
|
final OutputWriter outputWriter
|
||||||
) throws CommandException {
|
) throws CommandException {
|
||||||
Shutdown.installHandler();
|
Shutdown.installHandler();
|
||||||
logger.info("Starting daemon in single-account mode for " + m.getSelfNumber());
|
logger.info("Starting daemon in single-account mode for " + m.getSelfNumber());
|
||||||
@ -117,7 +119,9 @@ public class DaemonCommand implements MultiLocalCommand, LocalCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleCommand(
|
public void handleCommand(
|
||||||
final Namespace ns, final MultiAccountManager c, final OutputWriter outputWriter
|
final Namespace ns,
|
||||||
|
final MultiAccountManager c,
|
||||||
|
final OutputWriter outputWriter
|
||||||
) throws CommandException {
|
) throws CommandException {
|
||||||
Shutdown.installHandler();
|
Shutdown.installHandler();
|
||||||
logger.info("Starting daemon in multi-account mode");
|
logger.info("Starting daemon in multi-account mode");
|
||||||
|
@ -60,7 +60,9 @@ public class DeleteLocalAccountDataCommand implements RegistrationCommand, JsonR
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleCommand(
|
public void handleCommand(
|
||||||
Map<String, Object> request, RegistrationManager m, JsonWriter jsonWriter
|
Map<String, Object> request,
|
||||||
|
RegistrationManager m,
|
||||||
|
JsonWriter jsonWriter
|
||||||
) throws CommandException {
|
) throws CommandException {
|
||||||
Namespace commandNamespace = new JsonRpcNamespace(request == null ? Map.of() : request);
|
Namespace commandNamespace = new JsonRpcNamespace(request == null ? Map.of() : request);
|
||||||
handleCommand(commandNamespace, m);
|
handleCommand(commandNamespace, m);
|
||||||
|
@ -33,7 +33,9 @@ public class FinishChangeNumberCommand implements JsonRpcLocalCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleCommand(
|
public void handleCommand(
|
||||||
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
final Namespace ns,
|
||||||
|
final Manager m,
|
||||||
|
final OutputWriter outputWriter
|
||||||
) throws CommandException {
|
) throws CommandException {
|
||||||
final var newNumber = ns.getString("number");
|
final var newNumber = ns.getString("number");
|
||||||
final var verificationCode = ns.getString("verification-code");
|
final var verificationCode = ns.getString("verification-code");
|
||||||
|
@ -32,7 +32,9 @@ public class FinishLinkCommand implements JsonRpcMultiCommand<FinishLinkCommand.
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleCommand(
|
public void handleCommand(
|
||||||
final FinishLinkParams request, final MultiAccountManager m, final JsonWriter jsonWriter
|
final FinishLinkParams request,
|
||||||
|
final MultiAccountManager m,
|
||||||
|
final JsonWriter jsonWriter
|
||||||
) throws CommandException {
|
) throws CommandException {
|
||||||
if (request.deviceLinkUri() == null) {
|
if (request.deviceLinkUri() == null) {
|
||||||
throw new UserErrorException("Missing deviceLinkUri.");
|
throw new UserErrorException("Missing deviceLinkUri.");
|
||||||
|
@ -35,7 +35,9 @@ public class GetAttachmentCommand implements JsonRpcLocalCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleCommand(
|
public void handleCommand(
|
||||||
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
final Namespace ns,
|
||||||
|
final Manager m,
|
||||||
|
final OutputWriter outputWriter
|
||||||
) throws CommandException {
|
) throws CommandException {
|
||||||
|
|
||||||
final var id = ns.getString("id");
|
final var id = ns.getString("id");
|
||||||
|
@ -37,7 +37,9 @@ public class GetAvatarCommand implements JsonRpcLocalCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleCommand(
|
public void handleCommand(
|
||||||
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
final Namespace ns,
|
||||||
|
final Manager m,
|
||||||
|
final OutputWriter outputWriter
|
||||||
) throws CommandException {
|
) throws CommandException {
|
||||||
final var contactRecipient = ns.getString("contact");
|
final var contactRecipient = ns.getString("contact");
|
||||||
final var profileRecipient = ns.getString("profile");
|
final var profileRecipient = ns.getString("profile");
|
||||||
|
@ -35,7 +35,9 @@ public class GetStickerCommand implements JsonRpcLocalCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleCommand(
|
public void handleCommand(
|
||||||
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
final Namespace ns,
|
||||||
|
final Manager m,
|
||||||
|
final OutputWriter outputWriter
|
||||||
) throws CommandException {
|
) throws CommandException {
|
||||||
|
|
||||||
final var packId = StickerPackId.deserialize(Hex.toByteArray(ns.getString("pack-id")));
|
final var packId = StickerPackId.deserialize(Hex.toByteArray(ns.getString("pack-id")));
|
||||||
|
@ -43,7 +43,9 @@ public class GetUserStatusCommand implements JsonRpcLocalCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleCommand(
|
public void handleCommand(
|
||||||
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
final Namespace ns,
|
||||||
|
final Manager m,
|
||||||
|
final OutputWriter outputWriter
|
||||||
) throws CommandException {
|
) throws CommandException {
|
||||||
// Get a map of registration statuses
|
// Get a map of registration statuses
|
||||||
Map<String, UserStatus> registered;
|
Map<String, UserStatus> registered;
|
||||||
|
@ -33,7 +33,9 @@ public class JoinGroupCommand implements JsonRpcLocalCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleCommand(
|
public void handleCommand(
|
||||||
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
final Namespace ns,
|
||||||
|
final Manager m,
|
||||||
|
final OutputWriter outputWriter
|
||||||
) throws CommandException {
|
) throws CommandException {
|
||||||
final GroupInviteLinkUrl linkUrl;
|
final GroupInviteLinkUrl linkUrl;
|
||||||
var uri = ns.getString("uri");
|
var uri = ns.getString("uri");
|
||||||
|
@ -59,7 +59,9 @@ public class JsonRpcDispatcherCommand implements LocalCommand, MultiLocalCommand
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleCommand(
|
public void handleCommand(
|
||||||
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
final Namespace ns,
|
||||||
|
final Manager m,
|
||||||
|
final OutputWriter outputWriter
|
||||||
) throws CommandException {
|
) throws CommandException {
|
||||||
Shutdown.installHandler();
|
Shutdown.installHandler();
|
||||||
final var receiveMode = ns.<ReceiveMode>get("receive-mode");
|
final var receiveMode = ns.<ReceiveMode>get("receive-mode");
|
||||||
@ -79,7 +81,9 @@ public class JsonRpcDispatcherCommand implements LocalCommand, MultiLocalCommand
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleCommand(
|
public void handleCommand(
|
||||||
final Namespace ns, final MultiAccountManager c, final OutputWriter outputWriter
|
final Namespace ns,
|
||||||
|
final MultiAccountManager c,
|
||||||
|
final OutputWriter outputWriter
|
||||||
) throws CommandException {
|
) throws CommandException {
|
||||||
Shutdown.installHandler();
|
Shutdown.installHandler();
|
||||||
final var receiveMode = ns.<ReceiveMode>get("receive-mode");
|
final var receiveMode = ns.<ReceiveMode>get("receive-mode");
|
||||||
|
@ -18,9 +18,7 @@ public interface JsonRpcLocalCommand extends JsonRpcSingleCommand<Map<String, Ob
|
|||||||
return new TypeReference<>() {};
|
return new TypeReference<>() {};
|
||||||
}
|
}
|
||||||
|
|
||||||
default void handleCommand(
|
default void handleCommand(Map<String, Object> request, Manager m, JsonWriter jsonWriter) throws CommandException {
|
||||||
Map<String, Object> request, Manager m, JsonWriter jsonWriter
|
|
||||||
) throws CommandException {
|
|
||||||
Namespace commandNamespace = new JsonRpcNamespace(request == null ? Map.of() : request);
|
Namespace commandNamespace = new JsonRpcNamespace(request == null ? Map.of() : request);
|
||||||
handleCommand(commandNamespace, m, jsonWriter);
|
handleCommand(commandNamespace, m, jsonWriter);
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,9 @@ public interface JsonRpcMultiLocalCommand extends JsonRpcMultiCommand<Map<String
|
|||||||
}
|
}
|
||||||
|
|
||||||
default void handleCommand(
|
default void handleCommand(
|
||||||
Map<String, Object> request, MultiAccountManager c, JsonWriter jsonWriter
|
Map<String, Object> request,
|
||||||
|
MultiAccountManager c,
|
||||||
|
JsonWriter jsonWriter
|
||||||
) throws CommandException {
|
) throws CommandException {
|
||||||
Namespace commandNamespace = new JsonRpcNamespace(request == null ? Map.of() : request);
|
Namespace commandNamespace = new JsonRpcNamespace(request == null ? Map.of() : request);
|
||||||
handleCommand(commandNamespace, c, jsonWriter);
|
handleCommand(commandNamespace, c, jsonWriter);
|
||||||
|
@ -33,7 +33,9 @@ public class LinkCommand implements ProvisioningCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleCommand(
|
public void handleCommand(
|
||||||
final Namespace ns, final ProvisioningManager m, final OutputWriter outputWriter
|
final Namespace ns,
|
||||||
|
final ProvisioningManager m,
|
||||||
|
final OutputWriter outputWriter
|
||||||
) throws CommandException {
|
) throws CommandException {
|
||||||
final var writer = (PlainTextWriter) outputWriter;
|
final var writer = (PlainTextWriter) outputWriter;
|
||||||
|
|
||||||
|
@ -23,7 +23,9 @@ public class ListAccountsCommand implements JsonRpcMultiLocalCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleCommand(
|
public void handleCommand(
|
||||||
final Namespace ns, final MultiAccountManager c, final OutputWriter outputWriter
|
final Namespace ns,
|
||||||
|
final MultiAccountManager c,
|
||||||
|
final OutputWriter outputWriter
|
||||||
) throws CommandException {
|
) throws CommandException {
|
||||||
final var accountNumbers = c.getAccountNumbers();
|
final var accountNumbers = c.getAccountNumbers();
|
||||||
switch (outputWriter) {
|
switch (outputWriter) {
|
||||||
|
@ -47,7 +47,9 @@ public class ListContactsCommand implements JsonRpcLocalCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleCommand(
|
public void handleCommand(
|
||||||
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
final Namespace ns,
|
||||||
|
final Manager m,
|
||||||
|
final OutputWriter outputWriter
|
||||||
) throws CommandException {
|
) throws CommandException {
|
||||||
final var allRecipients = Boolean.TRUE.equals(ns.getBoolean("all-recipients"));
|
final var allRecipients = Boolean.TRUE.equals(ns.getBoolean("all-recipients"));
|
||||||
final var blocked = ns.getBoolean("blocked");
|
final var blocked = ns.getBoolean("blocked");
|
||||||
|
@ -33,7 +33,9 @@ public class ListDevicesCommand implements JsonRpcLocalCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleCommand(
|
public void handleCommand(
|
||||||
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
final Namespace ns,
|
||||||
|
final Manager m,
|
||||||
|
final OutputWriter outputWriter
|
||||||
) throws CommandException {
|
) throws CommandException {
|
||||||
List<Device> devices;
|
List<Device> devices;
|
||||||
try {
|
try {
|
||||||
|
@ -48,9 +48,7 @@ public class ListGroupsCommand implements JsonRpcLocalCommand {
|
|||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void printGroupPlainText(
|
private static void printGroupPlainText(PlainTextWriter writer, Group group, boolean detailed) {
|
||||||
PlainTextWriter writer, Group group, boolean detailed
|
|
||||||
) {
|
|
||||||
if (detailed) {
|
if (detailed) {
|
||||||
final var groupInviteLink = group.groupInviteLinkUrl();
|
final var groupInviteLink = group.groupInviteLinkUrl();
|
||||||
|
|
||||||
@ -79,7 +77,9 @@ public class ListGroupsCommand implements JsonRpcLocalCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleCommand(
|
public void handleCommand(
|
||||||
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
final Namespace ns,
|
||||||
|
final Manager m,
|
||||||
|
final OutputWriter outputWriter
|
||||||
) throws CommandException {
|
) throws CommandException {
|
||||||
var groups = m.getGroups();
|
var groups = m.getGroups();
|
||||||
|
|
||||||
|
@ -46,7 +46,9 @@ public class ListIdentitiesCommand implements JsonRpcLocalCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleCommand(
|
public void handleCommand(
|
||||||
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
final Namespace ns,
|
||||||
|
final Manager m,
|
||||||
|
final OutputWriter outputWriter
|
||||||
) throws CommandException {
|
) throws CommandException {
|
||||||
var number = ns.getString("number");
|
var number = ns.getString("number");
|
||||||
|
|
||||||
|
@ -27,7 +27,9 @@ public class ListStickerPacksCommand implements JsonRpcLocalCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleCommand(
|
public void handleCommand(
|
||||||
final Namespace ns, final Manager c, final OutputWriter outputWriter
|
final Namespace ns,
|
||||||
|
final Manager c,
|
||||||
|
final OutputWriter outputWriter
|
||||||
) throws CommandException {
|
) throws CommandException {
|
||||||
final var stickerPacks = c.getStickerPacks();
|
final var stickerPacks = c.getStickerPacks();
|
||||||
switch (outputWriter) {
|
switch (outputWriter) {
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user