// Returns Success public async Task <bool> CompressAsync(Letter letter) { if (letter.LetterMetadata.Encrypted) { return(false); } // Don't compress after encryption. if (!letter.LetterMetadata.Compressed) { letter.Body = await CompressionProvider.CompressAsync(letter.Body).ConfigureAwait(false); letter.LetterMetadata.Compressed = true; letter.LetterMetadata.CustomFields[Constants.HeaderForCompressed] = true; letter.LetterMetadata.CustomFields[Constants.HeaderForCompression] = CompressionProvider.Type; return(true); } return(true); }
// Returns Success public async Task <bool> CompressAsync(IMessage message) { var metadata = message.GetMetadata(); if (metadata.Encrypted) { return(false); } // Don't compress after encryption. if (!metadata.Compressed) { message.Body = (await CompressionProvider.CompressAsync(message.Body).ConfigureAwait(false)).ToArray(); metadata.Compressed = true; metadata.CustomFields[Constants.HeaderForCompressed] = true; metadata.CustomFields[Constants.HeaderForCompression] = CompressionProvider.Type; return(true); } return(true); }