mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Reformat
This commit is contained in:
parent
1d2c7a479d
commit
631f10c916
2 changed files with 49 additions and 36 deletions
|
@ -1,30 +1,30 @@
|
||||||
package org.asamk.signal.dbus;
|
package org.asamk.signal.dbus;
|
||||||
|
|
||||||
import org.asamk.Signal;
|
import org.asamk.Signal;
|
||||||
|
import org.asamk.signal.BaseConfig;
|
||||||
import org.asamk.signal.manager.AttachmentInvalidException;
|
import org.asamk.signal.manager.AttachmentInvalidException;
|
||||||
import org.asamk.signal.manager.Manager;
|
import org.asamk.signal.manager.Manager;
|
||||||
import org.asamk.signal.manager.groups.GroupId;
|
import org.asamk.signal.manager.groups.GroupId;
|
||||||
|
import org.asamk.signal.manager.groups.GroupInviteLinkUrl;
|
||||||
import org.asamk.signal.manager.groups.GroupNotFoundException;
|
import org.asamk.signal.manager.groups.GroupNotFoundException;
|
||||||
import org.asamk.signal.manager.groups.NotAGroupMemberException;
|
import org.asamk.signal.manager.groups.NotAGroupMemberException;
|
||||||
import org.asamk.signal.manager.groups.GroupInviteLinkUrl;
|
|
||||||
import org.asamk.signal.manager.storage.protocol.IdentityInfo;
|
import org.asamk.signal.manager.storage.protocol.IdentityInfo;
|
||||||
import org.asamk.signal.util.ErrorUtils;
|
|
||||||
import org.asamk.signal.manager.util.Utils;
|
import org.asamk.signal.manager.util.Utils;
|
||||||
import org.asamk.signal.BaseConfig;
|
import org.asamk.signal.util.ErrorUtils;
|
||||||
import org.freedesktop.dbus.exceptions.DBusExecutionException;
|
import org.freedesktop.dbus.exceptions.DBusExecutionException;
|
||||||
import org.whispersystems.libsignal.util.guava.Optional;
|
import org.whispersystems.libsignal.util.guava.Optional;
|
||||||
|
import org.whispersystems.signalservice.api.groupsv2.GroupLinkNotActiveException;
|
||||||
import org.whispersystems.signalservice.api.messages.SendMessageResult;
|
import org.whispersystems.signalservice.api.messages.SendMessageResult;
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
import org.whispersystems.signalservice.api.util.InvalidNumberException;
|
import org.whispersystems.signalservice.api.util.InvalidNumberException;
|
||||||
import org.whispersystems.signalservice.api.groupsv2.GroupLinkNotActiveException;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Stream;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class DbusSignalImpl implements Signal {
|
public class DbusSignalImpl implements Signal {
|
||||||
|
|
||||||
|
@ -67,8 +67,9 @@ public class DbusSignalImpl implements Signal {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void checkSendMessageResults(long timestamp, List<SendMessageResult> results)
|
private static void checkSendMessageResults(
|
||||||
throws DBusExecutionException {
|
long timestamp, List<SendMessageResult> results
|
||||||
|
) throws DBusExecutionException {
|
||||||
if (results.size() == 1) {
|
if (results.size() == 1) {
|
||||||
checkSendMessageResult(timestamp, results.get(0));
|
checkSendMessageResult(timestamp, results.get(0));
|
||||||
return;
|
return;
|
||||||
|
@ -105,8 +106,9 @@ public class DbusSignalImpl implements Signal {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long sendNoteToSelfMessage(final String message, final List<String> attachments)
|
public long sendNoteToSelfMessage(
|
||||||
throws Error.AttachmentInvalid, Error.Failure, Error.UntrustedIdentity {
|
final String message, final List<String> attachments
|
||||||
|
) throws Error.AttachmentInvalid, Error.Failure, Error.UntrustedIdentity {
|
||||||
try {
|
try {
|
||||||
final var results = m.sendSelfMessage(message, attachments);
|
final var results = m.sendSelfMessage(message, attachments);
|
||||||
checkSendMessageResult(results.first(), results.second());
|
checkSendMessageResult(results.first(), results.second());
|
||||||
|
@ -211,8 +213,11 @@ public class DbusSignalImpl implements Signal {
|
||||||
if (group == null) {
|
if (group == null) {
|
||||||
return List.of();
|
return List.of();
|
||||||
} else {
|
} else {
|
||||||
return group.getMembers().stream().map(m::resolveSignalServiceAddress)
|
return group.getMembers()
|
||||||
.map(SignalServiceAddress::getLegacyIdentifier).collect(Collectors.toList());
|
.stream()
|
||||||
|
.map(m::resolveSignalServiceAddress)
|
||||||
|
.map(SignalServiceAddress::getLegacyIdentifier)
|
||||||
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,7 +236,9 @@ public class DbusSignalImpl implements Signal {
|
||||||
if (avatar.isEmpty()) {
|
if (avatar.isEmpty()) {
|
||||||
avatar = null;
|
avatar = null;
|
||||||
}
|
}
|
||||||
final var results = m.updateGroup(groupId == null ? null : GroupId.unknownVersion(groupId), name, members,
|
final var results = m.updateGroup(groupId == null ? null : GroupId.unknownVersion(groupId),
|
||||||
|
name,
|
||||||
|
members,
|
||||||
avatar == null ? null : new File(avatar));
|
avatar == null ? null : new File(avatar));
|
||||||
checkSendMessageResults(0, results.second());
|
checkSendMessageResults(0, results.second());
|
||||||
return results.first().serialize();
|
return results.first().serialize();
|
||||||
|
@ -252,13 +259,19 @@ public class DbusSignalImpl implements Signal {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateProfile(final String name, final String about, final String aboutEmoji, String avatarPath,
|
public void updateProfile(
|
||||||
final boolean removeAvatar) {
|
final String name,
|
||||||
|
final String about,
|
||||||
|
final String aboutEmoji,
|
||||||
|
String avatarPath,
|
||||||
|
final boolean removeAvatar
|
||||||
|
) {
|
||||||
try {
|
try {
|
||||||
if (avatarPath.isEmpty()) {
|
if (avatarPath.isEmpty()) {
|
||||||
avatarPath = null;
|
avatarPath = null;
|
||||||
}
|
}
|
||||||
Optional<File> avatarFile = removeAvatar ? Optional.absent()
|
Optional<File> avatarFile = removeAvatar
|
||||||
|
? Optional.absent()
|
||||||
: avatarPath == null ? null : Optional.of(new File(avatarPath));
|
: avatarPath == null ? null : Optional.of(new File(avatarPath));
|
||||||
m.setProfile(name, about, aboutEmoji, avatarFile);
|
m.setProfile(name, about, aboutEmoji, avatarFile);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue