@@ -236,7 +236,7 @@ pub enum Destination<R> {
236236 Group ( GroupData ) ,
237237 #[ serde( bound( serialize = "DistributionListItem<R>: serde::Serialize" ) ) ]
238238 DistributionList ( DistributionListItem < R > ) ,
239- Self_ ,
239+ Self_ ( SelfData ) ,
240240 ReleaseNotes ,
241241 CallLink ( CallLink ) ,
242242}
@@ -300,6 +300,8 @@ pub struct ContactData {
300300 pub system_given_name : String ,
301301 pub system_family_name : String ,
302302 pub system_nickname : String ,
303+ #[ serde( serialize_with = "serialize::optional_enum_as_string" ) ]
304+ pub avatar_color : Option < proto:: AvatarColor > ,
303305}
304306
305307#[ derive( Clone , Debug , serde:: Serialize ) ]
@@ -309,6 +311,13 @@ pub struct ContactName {
309311 pub family_name : String ,
310312}
311313
314+ #[ derive( Clone , Debug , serde:: Serialize ) ]
315+ #[ cfg_attr( test, derive( PartialEq ) ) ]
316+ pub struct SelfData {
317+ #[ serde( serialize_with = "serialize::optional_enum_as_string" ) ]
318+ pub avatar_color : Option < proto:: AvatarColor > ,
319+ }
320+
312321#[ derive( Clone , Debug , serde:: Serialize ) ]
313322#[ cfg_attr( test, derive( PartialEq ) ) ]
314323pub enum DistributionListItem < Recipient > {
@@ -378,7 +387,7 @@ impl<R> From<Destination<R>> for MinimalRecipientData {
378387 distribution_id, ..
379388 } ,
380389 ) => Self :: DistributionList { distribution_id } ,
381- Destination :: Self_ => Self :: Self_ ,
390+ Destination :: Self_ ( _ ) => Self :: Self_ ,
382391 Destination :: ReleaseNotes => Self :: ReleaseNotes ,
383392 Destination :: CallLink ( CallLink { root_key, .. } ) => Self :: CallLink { root_key } ,
384393 }
@@ -431,7 +440,7 @@ impl<R> AsRef<DestinationKind> for Destination<R> {
431440 Destination :: Contact ( _) => & DestinationKind :: Contact ,
432441 Destination :: Group ( _) => & DestinationKind :: Group ,
433442 Destination :: DistributionList ( _) => & DestinationKind :: DistributionList ,
434- Destination :: Self_ => & DestinationKind :: Self_ ,
443+ Destination :: Self_ ( _ ) => & DestinationKind :: Self_ ,
435444 Destination :: ReleaseNotes => & DestinationKind :: ReleaseNotes ,
436445 Destination :: CallLink ( _) => & DestinationKind :: CallLink ,
437446 }
@@ -459,7 +468,14 @@ impl<R: Clone, C: LookupPair<RecipientId, MinimalRecipientData, R> + ReportUnusu
459468 RecipientDestination :: DistributionList ( list) => {
460469 Destination :: DistributionList ( list. try_into_with ( context) ?)
461470 }
462- RecipientDestination :: Self_ ( proto:: Self_ { special_fields : _ } ) => Destination :: Self_ ,
471+ RecipientDestination :: Self_ ( proto:: Self_ {
472+ avatarColor,
473+ special_fields : _,
474+ } ) => {
475+ // The color is allowed to be unset.
476+ let avatar_color = avatarColor. map ( |v| v. enum_value_or_default ( ) ) ;
477+ Destination :: Self_ ( SelfData { avatar_color } )
478+ }
463479 RecipientDestination :: ReleaseNotes ( proto:: ReleaseNotes { special_fields : _ } ) => {
464480 Destination :: ReleaseNotes
465481 }
@@ -493,6 +509,7 @@ impl<C: ReportUnusualTimestamp> TryFromWith<proto::Contact, C> for ContactData {
493509 systemGivenName,
494510 systemFamilyName,
495511 systemNickname,
512+ avatarColor,
496513 special_fields : _,
497514 } = value;
498515
@@ -595,6 +612,9 @@ impl<C: ReportUnusualTimestamp> TryFromWith<proto::Contact, C> for ContactData {
595612 )
596613 . transpose ( ) ?;
597614
615+ // The color is allowed to be unset.
616+ let avatar_color = avatarColor. map ( |v| v. enum_value_or_default ( ) ) ;
617+
598618 Ok ( Self {
599619 aci,
600620 pni,
@@ -615,6 +635,7 @@ impl<C: ReportUnusualTimestamp> TryFromWith<proto::Contact, C> for ContactData {
615635 system_given_name : systemGivenName,
616636 system_family_name : systemFamilyName,
617637 system_nickname : systemNickname,
638+ avatar_color,
618639 } )
619640 }
620641}
@@ -859,6 +880,7 @@ mod test {
859880 system_family_name : "FamilySystemName" . to_owned ( ) ,
860881 system_nickname : "SystemNickName" . to_owned ( ) ,
861882 note : "nb" . into ( ) ,
883+ avatar_color : None ,
862884 }
863885 }
864886 }
@@ -882,7 +904,7 @@ mod test {
882904
883905 assert_eq ! (
884906 Destination :: try_from_with( recipient, & TestContext :: default ( ) ) ,
885- Ok ( Destination :: Self_ )
907+ Ok ( Destination :: Self_ ( SelfData { avatar_color : None } ) )
886908 )
887909 }
888910
0 commit comments