purifyForReceipt method
Purifies message data for use in ReceiptCommand.
Extracts and cleans up metadata from the original message envelope/content to form the "origin" field in receipt commands (removes sensitive/redundant fields). Returns null if the envelope is null (invalid original message).
@param envelope - Optional envelope of the original message for receipt
@param content - Optional content of the original message for receipt
@return Normalized map containing core receipt origin metadata (null if envelope is null)
Implementation
@override
Map? purifyForReceipt(Envelope? head, Content? body) {
if (head == null) {
return null;
}
Map origin = head.copyMap();
if (origin.containsKey('data')) {
origin.remove('data');
origin.remove('keys');
origin.remove('meta');
origin.remove('visa');
}
if (body != null) {
origin['sn'] = body.sn;
}
return origin;
}