mirror of
https://github.com/aljazceru/signal-cli.git
synced 2025-12-21 08:04:24 +01:00
Refactor NoteToSelf to singleton class
This commit is contained in:
@@ -12,14 +12,9 @@ public abstract class RecipientIdentifier {
|
||||
|
||||
public static class NoteToSelf extends RecipientIdentifier {
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
return obj instanceof NoteToSelf;
|
||||
}
|
||||
public static NoteToSelf INSTANCE = new NoteToSelf();
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 5;
|
||||
private NoteToSelf() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -276,7 +276,7 @@ public class DbusSignalImpl implements Signal {
|
||||
) throws Error.AttachmentInvalid, Error.Failure, Error.UntrustedIdentity {
|
||||
try {
|
||||
final var results = m.sendMessage(new Message(message, attachments),
|
||||
Set.of(new RecipientIdentifier.NoteToSelf()));
|
||||
Set.of(RecipientIdentifier.NoteToSelf.INSTANCE));
|
||||
checkSendMessageResults(results.getTimestamp(), results.getResults());
|
||||
return results.getTimestamp();
|
||||
} catch (AttachmentInvalidException e) {
|
||||
|
||||
@@ -25,7 +25,7 @@ public class CommandUtil {
|
||||
) throws UserErrorException {
|
||||
final var recipientIdentifiers = new HashSet<RecipientIdentifier>();
|
||||
if (isNoteToSelf) {
|
||||
recipientIdentifiers.add(new RecipientIdentifier.NoteToSelf());
|
||||
recipientIdentifiers.add(RecipientIdentifier.NoteToSelf.INSTANCE);
|
||||
}
|
||||
if (recipientStrings != null) {
|
||||
final var localNumber = m.getUsername();
|
||||
|
||||
Reference in New Issue
Block a user