@@ -714,14 +714,16 @@ impl MimeMessage {
714714 }
715715
716716 /// Parses avatar action headers.
717- fn parse_avatar_headers ( & mut self , context : & Context ) {
717+ fn parse_avatar_headers ( & mut self , context : & Context ) -> Result < ( ) > {
718718 if let Some ( header_value) = self . get_header ( HeaderDef :: ChatGroupAvatar ) {
719- self . group_avatar = self . avatar_action_from_header ( context, header_value. to_string ( ) ) ;
719+ self . group_avatar =
720+ self . avatar_action_from_header ( context, header_value. to_string ( ) ) ?;
720721 }
721722
722723 if let Some ( header_value) = self . get_header ( HeaderDef :: ChatUserAvatar ) {
723- self . user_avatar = self . avatar_action_from_header ( context, header_value. to_string ( ) ) ;
724+ self . user_avatar = self . avatar_action_from_header ( context, header_value. to_string ( ) ) ? ;
724725 }
726+ Ok ( ( ) )
725727 }
726728
727729 fn parse_videochat_headers ( & mut self ) {
@@ -828,7 +830,7 @@ impl MimeMessage {
828830
829831 async fn parse_headers ( & mut self , context : & Context ) -> Result < ( ) > {
830832 self . parse_system_message_headers ( context) ;
831- self . parse_avatar_headers ( context) ;
833+ self . parse_avatar_headers ( context) ? ;
832834 self . parse_videochat_headers ( ) ;
833835 if self . delivery_report . is_none ( ) {
834836 self . squash_attachment_parts ( ) ;
@@ -930,21 +932,18 @@ impl MimeMessage {
930932 & mut self ,
931933 context : & Context ,
932934 header_value : String ,
933- ) -> Option < AvatarAction > {
934- if header_value == "0" {
935+ ) -> Result < Option < AvatarAction > > {
936+ let res = if header_value == "0" {
935937 Some ( AvatarAction :: Delete )
936938 } else if let Some ( base64) = header_value
937939 . split_ascii_whitespace ( )
938940 . collect :: < String > ( )
939941 . strip_prefix ( "base64:" )
940942 {
941- match BlobObject :: store_from_base64 ( context, base64) {
942- Ok ( path) => Some ( AvatarAction :: Change ( path) ) ,
943- Err ( err) => {
944- warn ! (
945- context,
946- "Could not decode and save avatar to blob file: {:#}" , err,
947- ) ;
943+ match BlobObject :: store_from_base64 ( context, base64) ? {
944+ Some ( path) => Some ( AvatarAction :: Change ( path) ) ,
945+ None => {
946+ warn ! ( context, "Could not decode avatar base64" ) ;
948947 None
949948 }
950949 }
@@ -958,15 +957,16 @@ impl MimeMessage {
958957 if let Some ( blob) = part. param . get ( Param :: File ) {
959958 let res = Some ( AvatarAction :: Change ( blob. to_string ( ) ) ) ;
960959 self . parts . remove ( i) ;
961- return res;
960+ return Ok ( res) ;
962961 }
963962 break ;
964963 }
965964 }
966965 i += 1 ;
967966 }
968967 None
969- }
968+ } ;
969+ Ok ( res)
970970 }
971971
972972 /// Returns true if the message was encrypted as defined in
0 commit comments