mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Improve handling of CDSI resource exhaustion
This commit is contained in:
parent
a675631965
commit
7cd24a74af
4 changed files with 25 additions and 4 deletions
|
@ -5,11 +5,14 @@ import net.sourceforge.argparse4j.inf.Subparser;
|
|||
|
||||
import org.asamk.signal.commands.exceptions.CommandException;
|
||||
import org.asamk.signal.commands.exceptions.IOErrorException;
|
||||
import org.asamk.signal.commands.exceptions.RateLimitErrorException;
|
||||
import org.asamk.signal.manager.Manager;
|
||||
import org.asamk.signal.manager.api.RateLimitException;
|
||||
import org.asamk.signal.manager.api.UserStatus;
|
||||
import org.asamk.signal.output.JsonWriter;
|
||||
import org.asamk.signal.output.OutputWriter;
|
||||
import org.asamk.signal.output.PlainTextWriter;
|
||||
import org.asamk.signal.util.CommandUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -40,6 +43,9 @@ public class GetUserStatusCommand implements JsonRpcLocalCommand {
|
|||
Map<String, UserStatus> registered;
|
||||
try {
|
||||
registered = m.getUserStatus(new HashSet<>(ns.getList("recipient")));
|
||||
} catch (RateLimitException e) {
|
||||
final var message = CommandUtil.getRateLimitMessage(e);
|
||||
throw new RateLimitErrorException(message, e);
|
||||
} catch (IOException e) {
|
||||
throw new IOErrorException("Unable to check if users are registered: "
|
||||
+ e.getMessage()
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.asamk.signal.manager.api.Message;
|
|||
import org.asamk.signal.manager.api.NotAGroupMemberException;
|
||||
import org.asamk.signal.manager.api.NotPrimaryDeviceException;
|
||||
import org.asamk.signal.manager.api.PendingAdminApprovalException;
|
||||
import org.asamk.signal.manager.api.RateLimitException;
|
||||
import org.asamk.signal.manager.api.RecipientAddress;
|
||||
import org.asamk.signal.manager.api.RecipientIdentifier;
|
||||
import org.asamk.signal.manager.api.SendMessageResult;
|
||||
|
@ -31,6 +32,7 @@ import org.asamk.signal.manager.api.UnregisteredRecipientException;
|
|||
import org.asamk.signal.manager.api.UpdateGroup;
|
||||
import org.asamk.signal.manager.api.UpdateProfile;
|
||||
import org.asamk.signal.manager.api.UserStatus;
|
||||
import org.asamk.signal.util.DateUtils;
|
||||
import org.asamk.signal.util.SendMessageResultUtils;
|
||||
import org.freedesktop.dbus.DBusPath;
|
||||
import org.freedesktop.dbus.connections.impl.DBusConnection;
|
||||
|
@ -681,6 +683,10 @@ public class DbusSignalImpl implements Signal {
|
|||
registered = m.getUserStatus(new HashSet<>(numbers));
|
||||
} catch (IOException e) {
|
||||
throw new Error.Failure(e.getMessage());
|
||||
} catch (RateLimitException e) {
|
||||
throw new Error.Failure(e.getMessage()
|
||||
+ ", retry at "
|
||||
+ DateUtils.formatTimestamp(e.getNextAttemptTimestamp()));
|
||||
}
|
||||
|
||||
return numbers.stream().map(number -> registered.get(number).uuid() != null).toList();
|
||||
|
@ -893,7 +899,7 @@ public class DbusSignalImpl implements Signal {
|
|||
}
|
||||
|
||||
var errors = SendMessageResultUtils.getErrorMessagesFromSendMessageResults(results);
|
||||
if (errors.size() == 0 || errors.size() < results.size()) {
|
||||
if (errors.isEmpty() || errors.size() < results.size()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue