X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/78474453d7de5fa50c32c460e18877485bc26f78..abb6ebc910d7d46ec3644d49d6bd456fcccfa1e0:/src/main/java/org/asamk/signal/manager/Manager.java diff --git a/src/main/java/org/asamk/signal/manager/Manager.java b/src/main/java/org/asamk/signal/manager/Manager.java index 575dde67..5a26ff56 100644 --- a/src/main/java/org/asamk/signal/manager/Manager.java +++ b/src/main/java/org/asamk/signal/manager/Manager.java @@ -54,6 +54,7 @@ import org.whispersystems.signalservice.api.push.exceptions.NetworkFailureExcept import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException; import org.whispersystems.signalservice.api.util.InvalidNumberException; import org.whispersystems.signalservice.api.util.SleepTimer; +import org.whispersystems.signalservice.api.util.StreamDetails; import org.whispersystems.signalservice.api.util.UptimeSleepTimer; import org.whispersystems.signalservice.internal.push.SignalServiceProtos; import org.whispersystems.signalservice.internal.push.UnsupportedDataMessageException; @@ -204,11 +205,22 @@ public class Manager implements Signal { accountManager.setAccountAttributes(account.getSignalingKey(), account.getSignalProtocolStore().getLocalRegistrationId(), true, account.getRegistrationLockPin(), getSelfUnidentifiedAccessKey(), false); } + public void setProfileName(String name) throws IOException { + accountManager.setProfileName(account.getProfileKey(), name); + } + + public void setProfileAvatar(File avatar) throws IOException { + accountManager.setProfileAvatar(account.getProfileKey(), Utils.createStreamDetailsFromFile(avatar)); + } + public void unregister() throws IOException { // When setting an empty GCM id, the Signal-Server also sets the fetchesMessages property to false. // If this is the master device, other users can't send messages to this number anymore. // If this is a linked device, other users can still send messages, but this device doesn't receive them anymore. accountManager.setGcmId(Optional.absent()); + + account.setRegistered(false); + account.save(); } public String getDeviceLinkUri() throws TimeoutException, IOException { @@ -512,8 +524,15 @@ public class Manager implements Signal { } } - return SignalServiceDataMessage.newBuilder() + SignalServiceDataMessage.Builder messageBuilder = SignalServiceDataMessage.newBuilder() .asGroupMessage(group.build()); + + ThreadInfo thread = account.getThreadStore().getThread(Base64.encodeBytes(g.groupId)); + if (thread != null) { + messageBuilder.withExpiration(thread.messageExpirationTime); + } + + return messageBuilder; } private void sendGroupInfoRequest(byte[] groupId, String recipient) throws IOException, EncapsulatedExceptions { @@ -527,6 +546,11 @@ public class Manager implements Signal { SignalServiceDataMessage.Builder messageBuilder = SignalServiceDataMessage.newBuilder() .asGroupMessage(group.build()); + ThreadInfo thread = account.getThreadStore().getThread(Base64.encodeBytes(groupId)); + if (thread != null) { + messageBuilder.withExpiration(thread.messageExpirationTime); + } + // Send group info request message to the recipient who sent us a message with this groupId final List membersSend = new ArrayList<>(); membersSend.add(recipient); @@ -549,6 +573,7 @@ public class Manager implements Signal { if (attachments != null) { messageBuilder.withAttachments(Utils.getSignalServiceAttachments(attachments)); } + messageBuilder.withProfileKey(account.getProfileKey()); sendMessageLegacy(messageBuilder, recipients); } @@ -764,7 +789,7 @@ public class Manager implements Signal { message = messageBuilder.build(); if (message.getGroupInfo().isPresent()) { try { - final boolean isRecipientUpdate = true; + final boolean isRecipientUpdate = false; List result = messageSender.sendMessage(new ArrayList<>(recipientsTS), getAccessFor(recipientsTS), isRecipientUpdate, message); for (SendMessageResult r : result) { if (r.getIdentityFailure() != null) {