Add support for invalid pre key failure when sending message

This commit is contained in:
AsamK 2023-06-11 17:47:48 +02:00
parent da25b2a763
commit 0c5993c0ad
2 changed files with 9 additions and 23 deletions

View file

@ -2,7 +2,6 @@ package org.asamk.signal.manager.api;
import org.asamk.signal.manager.helper.RecipientAddressResolver;
import org.asamk.signal.manager.storage.recipients.RecipientResolver;
import org.signal.libsignal.protocol.IdentityKey;
public record SendMessageResult(
RecipientAddress address,
@ -11,29 +10,12 @@ public record SendMessageResult(
boolean isUnregisteredFailure,
boolean isIdentityFailure,
boolean isRateLimitFailure,
ProofRequiredException proofRequiredFailure
ProofRequiredException proofRequiredFailure,
boolean isInvalidPreKeyFailure
) {
public static SendMessageResult success(RecipientAddress address) {
return new SendMessageResult(address, true, false, false, false, false, null);
}
public static SendMessageResult networkFailure(RecipientAddress address) {
return new SendMessageResult(address, false, true, false, false, false, null);
}
public static SendMessageResult unregisteredFailure(RecipientAddress address) {
return new SendMessageResult(address, false, false, true, false, false, null);
}
public static SendMessageResult identityFailure(RecipientAddress address, IdentityKey identityKey) {
return new SendMessageResult(address, false, false, false, true, false, null);
}
public static SendMessageResult proofRequiredFailure(
RecipientAddress address, ProofRequiredException proofRequiredException
) {
return new SendMessageResult(address, false, true, false, false, false, proofRequiredException);
return new SendMessageResult(address, false, false, true, false, false, null, false);
}
public static SendMessageResult from(
@ -50,6 +32,7 @@ public record SendMessageResult(
sendMessageResult.getRateLimitFailure() != null || sendMessageResult.getProofRequiredFailure() != null,
sendMessageResult.getProofRequiredFailure() == null
? null
: new ProofRequiredException(sendMessageResult.getProofRequiredFailure()));
: new ProofRequiredException(sendMessageResult.getProofRequiredFailure()),
sendMessageResult.isInvalidPreKeyFailure());
}
}