// Returns Success public async Task <bool> DecompressAsync(Letter letter) { if (letter.LetterMetadata.Encrypted) { return(false); } // Don't decompress before decryption. if (letter.LetterMetadata.Compressed) { try { letter.Body = await CompressionProvider.DecompressAsync(letter.Body).ConfigureAwait(false); letter.LetterMetadata.Compressed = false; letter.LetterMetadata.CustomFields[Constants.HeaderForCompressed] = false; if (letter.LetterMetadata.CustomFields.ContainsKey(Constants.HeaderForCompression)) { letter.LetterMetadata.CustomFields.Remove(Constants.HeaderForCompression); } } catch { return(false); } } return(true); }
// Returns Success public async Task <bool> DecompressAsync(IMessage message) { var metadata = message.GetMetadata(); if (metadata.Encrypted) { return(false); } // Don't decompress before decryption. if (metadata.Compressed) { try { message.Body = (await CompressionProvider.DecompressAsync(message.Body).ConfigureAwait(false)).ToArray(); metadata.Compressed = false; metadata.CustomFields[Constants.HeaderForCompressed] = false; if (metadata.CustomFields.ContainsKey(Constants.HeaderForCompression)) { metadata.CustomFields.Remove(Constants.HeaderForCompression); } } catch { return(false); } } return(true); }