mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 02:20:39 +00:00
Update libsignal-service-java
This commit is contained in:
parent
30e8e36635
commit
be9efb9a25
5 changed files with 37 additions and 36 deletions
|
@ -716,7 +716,6 @@ public record MessageEnvelope(
|
|||
Optional<Busy> busy,
|
||||
List<IceUpdate> iceUpdate,
|
||||
Optional<Opaque> opaque,
|
||||
boolean isMultiRing,
|
||||
boolean isUrgent
|
||||
) {
|
||||
|
||||
|
@ -732,17 +731,13 @@ public record MessageEnvelope(
|
|||
.map(m -> m.stream().map(IceUpdate::from).toList())
|
||||
.orElse(List.of()),
|
||||
callMessage.getOpaqueMessage().map(Opaque::from),
|
||||
callMessage.isMultiRing(),
|
||||
callMessage.isUrgent());
|
||||
}
|
||||
|
||||
public record Offer(long id, String sdp, Type type, byte[] opaque) {
|
||||
public record Offer(long id, Type type, byte[] opaque) {
|
||||
|
||||
static Offer from(OfferMessage offerMessage) {
|
||||
return new Offer(offerMessage.getId(),
|
||||
offerMessage.getSdp(),
|
||||
Type.from(offerMessage.getType()),
|
||||
offerMessage.getOpaque());
|
||||
return new Offer(offerMessage.getId(), Type.from(offerMessage.getType()), offerMessage.getOpaque());
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
|
@ -758,10 +753,10 @@ public record MessageEnvelope(
|
|||
}
|
||||
}
|
||||
|
||||
public record Answer(long id, String sdp, byte[] opaque) {
|
||||
public record Answer(long id, byte[] opaque) {
|
||||
|
||||
static Answer from(AnswerMessage answerMessage) {
|
||||
return new Answer(answerMessage.getId(), answerMessage.getSdp(), answerMessage.getOpaque());
|
||||
return new Answer(answerMessage.getId(), answerMessage.getOpaque());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -799,10 +794,10 @@ public record MessageEnvelope(
|
|||
}
|
||||
}
|
||||
|
||||
public record IceUpdate(long id, String sdp, byte[] opaque) {
|
||||
public record IceUpdate(long id, byte[] opaque) {
|
||||
|
||||
static IceUpdate from(IceUpdateMessage iceUpdateMessage) {
|
||||
return new IceUpdate(iceUpdateMessage.getId(), iceUpdateMessage.getSdp(), iceUpdateMessage.getOpaque());
|
||||
return new IceUpdate(iceUpdateMessage.getId(), iceUpdateMessage.getOpaque());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -320,7 +320,11 @@ public class AccountHelper {
|
|||
if (currentUsername != null) {
|
||||
final var currentNickname = currentUsername.substring(0, currentUsername.indexOf('.'));
|
||||
if (currentNickname.equals(nickname)) {
|
||||
refreshCurrentUsername();
|
||||
try {
|
||||
refreshCurrentUsername();
|
||||
} catch (IOException | BaseUsernameException e) {
|
||||
logger.warn("[reserveUsername] Failed to refresh current username, trying to claim new username");
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -341,11 +345,11 @@ public class AccountHelper {
|
|||
logger.debug("[reserveUsername] Successfully reserved username.");
|
||||
final var username = candidates.get(hashIndex);
|
||||
|
||||
dependencies.getAccountManager().confirmUsername(username.getUsername(), response);
|
||||
final var linkComponents = dependencies.getAccountManager().confirmUsernameAndCreateNewLink(username);
|
||||
account.setUsername(username.getUsername());
|
||||
account.setUsernameLink(linkComponents);
|
||||
account.getRecipientStore().resolveSelfRecipientTrusted(account.getSelfRecipientAddress());
|
||||
logger.debug("[confirmUsername] Successfully confirmed username.");
|
||||
tryToSetUsernameLink(username);
|
||||
}
|
||||
|
||||
public void refreshCurrentUsername() throws IOException, BaseUsernameException {
|
||||
|
@ -386,12 +390,20 @@ public class AccountHelper {
|
|||
}
|
||||
|
||||
private void tryReserveConfirmUsername(final Username username) throws IOException {
|
||||
final var response = dependencies.getAccountManager()
|
||||
.reserveUsername(List.of(Base64.encodeUrlSafeWithoutPadding(username.getHash())));
|
||||
logger.debug("[reserveUsername] Successfully reserved existing username.");
|
||||
dependencies.getAccountManager().confirmUsername(username.getUsername(), response);
|
||||
logger.debug("[confirmUsername] Successfully confirmed existing username.");
|
||||
tryToSetUsernameLink(username);
|
||||
final var usernameLink = account.getUsernameLink();
|
||||
|
||||
if (usernameLink == null) {
|
||||
dependencies.getAccountManager()
|
||||
.reserveUsername(List.of(Base64.encodeUrlSafeWithoutPadding(username.getHash())));
|
||||
logger.debug("[reserveUsername] Successfully reserved existing username.");
|
||||
final var linkComponents = dependencies.getAccountManager().confirmUsernameAndCreateNewLink(username);
|
||||
account.setUsernameLink(linkComponents);
|
||||
logger.debug("[confirmUsername] Successfully confirmed existing username.");
|
||||
} else {
|
||||
final var linkComponents = dependencies.getAccountManager().reclaimUsernameAndLink(username, usernameLink);
|
||||
account.setUsernameLink(linkComponents);
|
||||
logger.debug("[confirmUsername] Successfully reclaimed existing username and link.");
|
||||
}
|
||||
}
|
||||
|
||||
private void tryToSetUsernameLink(Username username) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue