-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add UserPreferenceUpdate Message Compat (#1387)
* proto update * swap out consent updates * ok to fail * missing file * lint * update name * Less aggressive restarting
- Loading branch information
Showing
13 changed files
with
558 additions
and
837 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use serde::{Deserialize, Serialize}; | ||
use xmtp_id::associations::DeserializationError; | ||
use xmtp_proto::xmtp::mls::message_contents::UserPreferenceUpdate as UserPreferenceUpdateProto; | ||
|
||
use crate::storage::consent_record::StoredConsentRecord; | ||
|
||
#[derive(Serialize, Deserialize, Clone)] | ||
pub enum UserPreferenceUpdate { | ||
ConsentUpdate(StoredConsentRecord), | ||
HmacKeyUpdate { key: Vec<u8> }, | ||
} | ||
|
||
impl TryFrom<UserPreferenceUpdateProto> for UserPreferenceUpdate { | ||
type Error = DeserializationError; | ||
fn try_from(value: UserPreferenceUpdateProto) -> Result<Self, Self::Error> { | ||
let update = | ||
bincode::deserialize(&value.content).map_err(|_| DeserializationError::Bincode)?; | ||
|
||
Ok(update) | ||
} | ||
} | ||
|
||
impl TryInto<UserPreferenceUpdateProto> for UserPreferenceUpdate { | ||
type Error = bincode::Error; | ||
|
||
fn try_into(self) -> Result<UserPreferenceUpdateProto, Self::Error> { | ||
let content = bincode::serialize(&self)?; | ||
Ok(UserPreferenceUpdateProto { content }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.