mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Improve uuid/number handling
This commit is contained in:
parent
4f8da7819e
commit
3d5c440aa2
3 changed files with 19 additions and 17 deletions
|
@ -564,12 +564,12 @@ public interface Signal extends DBusInterface {
|
|||
String uuid;
|
||||
|
||||
@Position(2)
|
||||
String name;
|
||||
String number;
|
||||
|
||||
public StructIdentity(final DBusPath objectPath, final String uuid, final String name) {
|
||||
public StructIdentity(final DBusPath objectPath, final String uuid, final String number) {
|
||||
this.objectPath = objectPath;
|
||||
this.uuid = uuid;
|
||||
this.name = name;
|
||||
this.number = number;
|
||||
}
|
||||
|
||||
public DBusPath getObjectPath() {
|
||||
|
@ -580,8 +580,8 @@ public interface Signal extends DBusInterface {
|
|||
return uuid;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
public String getNumber() {
|
||||
return number;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1044,8 +1044,8 @@ public class DbusSignalImpl implements Signal {
|
|||
final var object = new DbusSignalIdentityImpl(i);
|
||||
exportObject(object);
|
||||
this.identities.add(new StructIdentity(new DBusPath(object.getObjectPath()),
|
||||
emptyIfNull(i.recipient().getIdentifier()),
|
||||
i.recipient().getLegacyIdentifier()));
|
||||
i.recipient().uuid().map(UUID::toString).orElse(""),
|
||||
i.recipient().number().orElse("")));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1063,11 +1063,12 @@ public class DbusSignalImpl implements Signal {
|
|||
|
||||
@Override
|
||||
public DBusPath getIdentity(String number) throws Error.Failure {
|
||||
|
||||
final var found = identities.stream().filter(identity -> identity.getName().equals(number)).findFirst();
|
||||
final var found = identities.stream()
|
||||
.filter(identity -> identity.getNumber().equals(number) || identity.getUuid().equals(number))
|
||||
.findFirst();
|
||||
|
||||
if (found.isEmpty()) {
|
||||
throw new Error.Failure("Identity for " + number + " unkown");
|
||||
throw new Error.Failure("Identity for " + number + " unknown");
|
||||
}
|
||||
return found.get().getObjectPath();
|
||||
}
|
||||
|
@ -1088,7 +1089,7 @@ public class DbusSignalImpl implements Signal {
|
|||
List.of(new DbusProperty<>("Number", () -> identity.recipient().number().orElse("")),
|
||||
new DbusProperty<>("Uuid",
|
||||
() -> identity.recipient().uuid().map(UUID::toString).orElse("")),
|
||||
new DbusProperty<>("Fingerprint", () -> identity.getFingerprint()),
|
||||
new DbusProperty<>("Fingerprint", identity::getFingerprint),
|
||||
new DbusProperty<>("SafetyNumber", identity::safetyNumber),
|
||||
new DbusProperty<>("ScannableSafetyNumber", identity::scannableSafetyNumber),
|
||||
new DbusProperty<>("TrustLevel", identity::trustLevel),
|
||||
|
@ -1181,8 +1182,7 @@ public class DbusSignalImpl implements Signal {
|
|||
|
||||
public class DbusSignalConfigurationImpl extends DbusProperties implements Signal.Configuration {
|
||||
|
||||
public DbusSignalConfigurationImpl(
|
||||
) {
|
||||
public DbusSignalConfigurationImpl() {
|
||||
super.addPropertiesHandler(new DbusInterfacePropertiesHandler("org.asamk.Signal.Configuration",
|
||||
List.of(new DbusProperty<>("ReadReceipts", this::getReadReceipts, this::setReadReceipts),
|
||||
new DbusProperty<>("UnidentifiedDeliveryIndicators",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue