Add updateProfile to Dbus (#522)

* Added updateProfile on Dbus

* added updateProfile on Dbus (fix)

Co-authored-by: Adimarantis <adimarantis@gmail.com>
This commit is contained in:
Adimarantis 2021-02-19 17:54:59 +01:00 committed by GitHub
parent 129a846cc1
commit d0ce3c1543
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View file

@ -51,6 +51,8 @@ public interface Signal extends DBusInterface {
boolean isRegistered();
void updateProfile(String name,String about,String aboutEmoji,String avatarPath,boolean removeAvatar) throws Error.Failure;
class MessageReceived extends DBusSignal {
private final long timestamp;

View file

@ -13,6 +13,8 @@ import org.whispersystems.libsignal.util.Pair;
import org.whispersystems.signalservice.api.messages.SendMessageResult;
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
import org.whispersystems.signalservice.api.util.InvalidNumberException;
import org.whispersystems.libsignal.util.guava.Optional;
import org.asamk.signal.manager.storage.contacts.ContactInfo;
import java.io.File;
import java.io.IOException;
@ -248,4 +250,20 @@ public class DbusSignalImpl implements Signal {
public boolean isRegistered() {
return true;
}
@Override
public void updateProfile(final String name,final String about,final String aboutEmoji, String avatarPath, final boolean removeAvatar) {
try {
if (avatarPath.isEmpty()) {
avatarPath = null;
}
Optional<File> avatarFile = removeAvatar
? Optional.absent()
: avatarPath == null ? null : Optional.of(new File(avatarPath));
m.setProfile(name, about, aboutEmoji, avatarFile);
} catch (IOException e) {
throw new Error.Failure(e.getMessage());
}
}
}