discardReceivedMessage

Discards message for good and acknowledges it to its sender (docs/message-discard.md).


Discards message id from sender for good: the application will never apply it (docs/message-discard.md). Only for permanent decisions; leave a message that failed for a temporary reason pending.

In one transaction the pending message, plaintext included, is removed and a discarded tombstone recorded with the discard time, a digest of its body and reason (DiscardStatus.DISCARDED). The plaintext is not kept anywhere; store it yourself first if you need it. Only after that commit, outside it, the encrypted acknowledgement is sent on the existing session, the same acknowledgement a commit sends: the sender learns only that the message was finalized, never that it was discarded or why. A failed acknowledgement never undoes the discard: DiscardResult.ackSent is false, and the sender's next retry is acknowledged. A later copy of the message is not delivered again (ReceiveResult.AlreadyDiscarded).

Idempotent: a message discarded before stays as it is, with its first reason (DiscardStatus.ALREADY_DISCARDED); a committed message stays committed (DiscardStatus.ALREADY_COMMITTED); both are acknowledged again. A message that is neither pending nor finalized throws SecureMessageClientException.ReceivedMessageNotPending and records nothing.