|
@@ -2,7 +2,7 @@ use flowy_derive::ProtoBuf;
|
|
|
use std::convert::TryInto;
|
|
|
|
|
|
use crate::{
|
|
|
- entities::parser::{UserEmail, UserId, UserName, UserPassword},
|
|
|
+ entities::parser::{UserEmail, UserIcon, UserId, UserName, UserPassword},
|
|
|
errors::ErrorCode,
|
|
|
};
|
|
|
|
|
@@ -25,6 +25,9 @@ pub struct UserProfilePB {
|
|
|
|
|
|
#[pb(index = 4)]
|
|
|
pub token: String,
|
|
|
+
|
|
|
+ #[pb(index = 5)]
|
|
|
+ pub icon: String,
|
|
|
}
|
|
|
|
|
|
#[derive(ProtoBuf, Default)]
|
|
@@ -40,6 +43,9 @@ pub struct UpdateUserProfilePayloadPB {
|
|
|
|
|
|
#[pb(index = 4, one_of)]
|
|
|
pub password: Option<String>,
|
|
|
+
|
|
|
+ #[pb(index = 5, one_of)]
|
|
|
+ pub icon: Option<String>,
|
|
|
}
|
|
|
|
|
|
impl UpdateUserProfilePayloadPB {
|
|
@@ -64,6 +70,11 @@ impl UpdateUserProfilePayloadPB {
|
|
|
self.password = Some(password.to_owned());
|
|
|
self
|
|
|
}
|
|
|
+
|
|
|
+ pub fn icon(mut self, icon: &str) -> Self {
|
|
|
+ self.icon = Some(icon.to_owned());
|
|
|
+ self
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
#[derive(ProtoBuf, Default, Clone, Debug)]
|
|
@@ -79,6 +90,9 @@ pub struct UpdateUserProfileParams {
|
|
|
|
|
|
#[pb(index = 4, one_of)]
|
|
|
pub password: Option<String>,
|
|
|
+
|
|
|
+ #[pb(index = 5, one_of)]
|
|
|
+ pub icon: Option<String>,
|
|
|
}
|
|
|
|
|
|
impl UpdateUserProfileParams {
|
|
@@ -88,6 +102,7 @@ impl UpdateUserProfileParams {
|
|
|
name: None,
|
|
|
email: None,
|
|
|
password: None,
|
|
|
+ icon: None,
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -105,6 +120,11 @@ impl UpdateUserProfileParams {
|
|
|
self.password = Some(password.to_owned());
|
|
|
self
|
|
|
}
|
|
|
+
|
|
|
+ pub fn icon(mut self, icon: &str) -> Self {
|
|
|
+ self.icon = Some(icon.to_owned());
|
|
|
+ self
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
impl TryInto<UpdateUserProfileParams> for UpdateUserProfilePayloadPB {
|
|
@@ -128,11 +148,17 @@ impl TryInto<UpdateUserProfileParams> for UpdateUserProfilePayloadPB {
|
|
|
Some(password) => Some(UserPassword::parse(password)?.0),
|
|
|
};
|
|
|
|
|
|
+ let icon = match self.icon {
|
|
|
+ None => None,
|
|
|
+ Some(icon) => Some(UserIcon::parse(icon)?.0),
|
|
|
+ };
|
|
|
+
|
|
|
Ok(UpdateUserProfileParams {
|
|
|
id,
|
|
|
name,
|
|
|
email,
|
|
|
password,
|
|
|
+ icon,
|
|
|
})
|
|
|
}
|
|
|
}
|