ensureDecodedPayloadView method
void
ensureDecodedPayloadView({})
Unpacks PPT/E2EE payloads in place only when a caller actually touches the materialized payload getters. The original lazy bytes are retained so the message can still be forwarded without forcing a re-encode.
Implementation
void ensureDecodedPayloadView({
required String? pptScheme,
required String? pptSerializer,
required String? pptCipher,
required String? pptKeyId,
}) {
if (pptScheme == null || _pptPayloadDecoded) {
return;
}
final retainedPayload = toLazyPayload(anchor: this);
final rawArguments = _arguments ?? _decodeArgumentsBytes();
final rawArgumentsKeywords =
_argumentsKeywords ?? _decodeArgumentsKeywordsBytes();
if (!_payloadLooksPackedForPpt(
rawArguments,
rawArgumentsKeywords,
pptScheme: pptScheme,
pptSerializer: pptSerializer,
)) {
retainLazyPayload(retainedPayload);
_pptPayloadDecoded = true;
return;
}
final decoded = decodePayloadView(
rawArguments,
rawArgumentsKeywords,
pptScheme: pptScheme,
pptSerializer: pptSerializer,
pptCipher: pptCipher,
pptKeyId: pptKeyId,
e2eeProvider: e2eeProvider,
runtimeContext: e2eeRuntimeContext,
);
_arguments = decoded.arguments;
_argumentsKeywords = decoded.argumentsKeywords;
retainLazyPayload(retainedPayload);
_pptPayloadDecoded = true;
}