mirror of
https://github.com/AsamK/signal-cli
synced 2025-09-07 14:30:38 +00:00
implement uploadStickerPack for Dbus; fix isRegistered error
Note: isRegistered (and related methods) for Dbus can throw an InvalidNumberException when the phone number is incorrectly formatted. Previously this led to uncaught exceptions. They are now handled. The problem is in SignalServiceAccountManager.java in the package org.whispersystems.signalservice.api, which ignores the first character of a proposed phone number and checks that the rest is a legitimate int64. updated documentation
This commit is contained in:
parent
663f6f6e73
commit
c39b5450ff
5 changed files with 111 additions and 26 deletions
|
@ -19,6 +19,7 @@ import org.asamk.signal.manager.AttachmentInvalidException;
|
|||
import org.asamk.signal.manager.AvatarStore;
|
||||
import org.asamk.signal.manager.Manager;
|
||||
import org.asamk.signal.manager.NotMasterDeviceException;
|
||||
import org.asamk.signal.manager.StickerPackInvalidException;
|
||||
import org.asamk.signal.manager.api.Device;
|
||||
import org.asamk.signal.manager.api.TypingAction;
|
||||
import org.asamk.signal.manager.groups.GroupId;
|
||||
|
@ -753,6 +754,9 @@ public class DbusSignalImpl implements Signal {
|
|||
|
||||
@Override
|
||||
public boolean isRegistered(String number) {
|
||||
if (number.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
Map<String, Boolean> registered;
|
||||
List<String> numbers = new ArrayList<String>();
|
||||
|
@ -761,14 +765,19 @@ public class DbusSignalImpl implements Signal {
|
|||
return registered.get(number);
|
||||
} catch (IOException e) {
|
||||
throw new Error.Failure(e.getMessage());
|
||||
} catch (InvalidNumberException e) {
|
||||
throw new Error.InvalidNumber(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Boolean> isRegistered(List<String> numbers) {
|
||||
List<Boolean> results = new ArrayList<Boolean> ();
|
||||
if (numbers.isEmpty()) {
|
||||
return results;
|
||||
}
|
||||
try {
|
||||
Map<String, Boolean> registered;
|
||||
List<Boolean> results = new ArrayList<Boolean> ();
|
||||
registered = m.areUsersRegistered(new HashSet<String>(numbers));
|
||||
for (String number : numbers) {
|
||||
results.add(registered.get(number));
|
||||
|
@ -776,6 +785,8 @@ public class DbusSignalImpl implements Signal {
|
|||
return results;
|
||||
} catch (IOException e) {
|
||||
throw new Error.Failure(e.getMessage());
|
||||
} catch (InvalidNumberException e) {
|
||||
throw new Error.InvalidNumber(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1014,4 +1025,17 @@ public class DbusSignalImpl implements Signal {
|
|||
return group.isMember(m.getSelfRecipientId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadStickerPack(String stickerPackPath) {
|
||||
File path = new File(stickerPackPath);
|
||||
|
||||
try {
|
||||
var url = m.uploadStickerPack(path);
|
||||
} catch (IOException e) {
|
||||
throw new Error.Failure("Upload error (maybe image size is too large):" + e.getMessage());
|
||||
} catch (StickerPackInvalidException e) {
|
||||
throw new Error.Failure("Invalid sticker pack: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue