mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 02:20:39 +00:00
Use modern switch syntax
This commit is contained in:
parent
60ad582012
commit
f7f882e834
2 changed files with 13 additions and 24 deletions
|
@ -542,10 +542,8 @@ public final class IncomingMessageHandler {
|
||||||
}
|
}
|
||||||
if (syncMessage.getFetchType().isPresent()) {
|
if (syncMessage.getFetchType().isPresent()) {
|
||||||
switch (syncMessage.getFetchType().get()) {
|
switch (syncMessage.getFetchType().get()) {
|
||||||
case LOCAL_PROFILE:
|
case LOCAL_PROFILE -> actions.add(new RetrieveProfileAction(account.getSelfRecipientId()));
|
||||||
actions.add(new RetrieveProfileAction(account.getSelfRecipientId()));
|
case STORAGE_MANIFEST -> actions.add(RetrieveStorageDataAction.create());
|
||||||
case STORAGE_MANIFEST:
|
|
||||||
actions.add(RetrieveStorageDataAction.create());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (syncMessage.getKeys().isPresent()) {
|
if (syncMessage.getKeys().isPresent()) {
|
||||||
|
@ -709,7 +707,7 @@ public final class IncomingMessageHandler {
|
||||||
if (group == null || group instanceof GroupInfoV1) {
|
if (group == null || group instanceof GroupInfoV1) {
|
||||||
var groupV1 = (GroupInfoV1) group;
|
var groupV1 = (GroupInfoV1) group;
|
||||||
switch (groupInfo.getType()) {
|
switch (groupInfo.getType()) {
|
||||||
case UPDATE: {
|
case UPDATE -> {
|
||||||
if (groupV1 == null) {
|
if (groupV1 == null) {
|
||||||
groupV1 = new GroupInfoV1(groupId);
|
groupV1 = new GroupInfoV1(groupId);
|
||||||
}
|
}
|
||||||
|
@ -732,25 +730,23 @@ public final class IncomingMessageHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
account.getGroupStore().updateGroup(groupV1);
|
account.getGroupStore().updateGroup(groupV1);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case DELIVER:
|
case DELIVER -> {
|
||||||
if (groupV1 == null && !isSync) {
|
if (groupV1 == null && !isSync) {
|
||||||
actions.add(new SendGroupInfoRequestAction(source.recipientId(), groupId));
|
actions.add(new SendGroupInfoRequestAction(source.recipientId(), groupId));
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
case QUIT: {
|
case QUIT -> {
|
||||||
if (groupV1 != null) {
|
if (groupV1 != null) {
|
||||||
groupV1.removeMember(source.recipientId());
|
groupV1.removeMember(source.recipientId());
|
||||||
account.getGroupStore().updateGroup(groupV1);
|
account.getGroupStore().updateGroup(groupV1);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case REQUEST_INFO:
|
case REQUEST_INFO -> {
|
||||||
if (groupV1 != null && !isSync) {
|
if (groupV1 != null && !isSync) {
|
||||||
actions.add(new SendGroupInfoAction(source.recipientId(), groupV1.getGroupId()));
|
actions.add(new SendGroupInfoAction(source.recipientId(), groupV1.getGroupId()));
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Received a group v1 message for a v2 group
|
// Received a group v1 message for a v2 group
|
||||||
|
|
|
@ -166,18 +166,11 @@ public class UnidentifiedAccessHelper {
|
||||||
private static byte[] getTargetUnidentifiedAccessKey(
|
private static byte[] getTargetUnidentifiedAccessKey(
|
||||||
final Profile targetProfile, final ProfileKey theirProfileKey
|
final Profile targetProfile, final ProfileKey theirProfileKey
|
||||||
) {
|
) {
|
||||||
switch (targetProfile.getUnidentifiedAccessMode()) {
|
return switch (targetProfile.getUnidentifiedAccessMode()) {
|
||||||
case ENABLED:
|
case ENABLED -> theirProfileKey == null ? null : UnidentifiedAccess.deriveAccessKeyFrom(theirProfileKey);
|
||||||
if (theirProfileKey == null) {
|
case UNRESTRICTED -> createUnrestrictedUnidentifiedAccess();
|
||||||
return null;
|
default -> null;
|
||||||
}
|
};
|
||||||
|
|
||||||
return UnidentifiedAccess.deriveAccessKeyFrom(theirProfileKey);
|
|
||||||
case UNRESTRICTED:
|
|
||||||
return createUnrestrictedUnidentifiedAccess();
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static byte[] createUnrestrictedUnidentifiedAccess() {
|
private static byte[] createUnrestrictedUnidentifiedAccess() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue