mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
Merge pull request #778 from ENsu/add_icon_setting_360
Add icon setting 360
This commit is contained in:
@ -0,0 +1 @@
|
||||
ALTER TABLE user_table DROP COLUMN icon_url;
|
@ -0,0 +1 @@
|
||||
ALTER TABLE user_table ADD COLUMN icon_url TEXT NOT NULL DEFAULT '';
|
@ -88,6 +88,7 @@ table! {
|
||||
token -> Text,
|
||||
email -> Text,
|
||||
workspace -> Text,
|
||||
icon_url -> Text,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,13 @@
|
||||
// https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/
|
||||
mod user_email;
|
||||
mod user_icon;
|
||||
mod user_id;
|
||||
mod user_name;
|
||||
mod user_password;
|
||||
mod user_workspace;
|
||||
|
||||
pub use user_email::*;
|
||||
pub use user_icon::*;
|
||||
pub use user_id::*;
|
||||
pub use user_name::*;
|
||||
pub use user_password::*;
|
||||
|
@ -0,0 +1,16 @@
|
||||
use crate::errors::ErrorCode;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct UserIcon(pub String);
|
||||
|
||||
impl UserIcon {
|
||||
pub fn parse(s: String) -> Result<UserIcon, ErrorCode> {
|
||||
Ok(Self(s))
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<str> for UserIcon {
|
||||
fn as_ref(&self) -> &str {
|
||||
&self.0
|
||||
}
|
||||
}
|
@ -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_url: 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_url: Option<String>,
|
||||
}
|
||||
|
||||
impl UpdateUserProfilePayloadPB {
|
||||
@ -64,6 +70,11 @@ impl UpdateUserProfilePayloadPB {
|
||||
self.password = Some(password.to_owned());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn icon_url(mut self, icon_url: &str) -> Self {
|
||||
self.icon_url = Some(icon_url.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_url: Option<String>,
|
||||
}
|
||||
|
||||
impl UpdateUserProfileParams {
|
||||
@ -88,6 +102,7 @@ impl UpdateUserProfileParams {
|
||||
name: None,
|
||||
email: None,
|
||||
password: None,
|
||||
icon_url: None,
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,6 +120,11 @@ impl UpdateUserProfileParams {
|
||||
self.password = Some(password.to_owned());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn icon_url(mut self, icon_url: &str) -> Self {
|
||||
self.icon_url = Some(icon_url.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_url = match self.icon_url {
|
||||
None => None,
|
||||
Some(icon_url) => Some(UserIcon::parse(icon_url)?.0),
|
||||
};
|
||||
|
||||
Ok(UpdateUserProfileParams {
|
||||
id,
|
||||
name,
|
||||
email,
|
||||
password,
|
||||
icon_url,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -82,6 +82,7 @@ pub struct UserTable {
|
||||
pub(crate) token: String,
|
||||
pub(crate) email: String,
|
||||
pub(crate) workspace: String, // deprecated
|
||||
pub(crate) icon_url: String,
|
||||
}
|
||||
|
||||
impl UserTable {
|
||||
@ -91,6 +92,7 @@ impl UserTable {
|
||||
name,
|
||||
email,
|
||||
token,
|
||||
icon_url: "".to_owned(),
|
||||
workspace: "".to_owned(),
|
||||
}
|
||||
}
|
||||
@ -120,6 +122,7 @@ impl std::convert::From<UserTable> for UserProfilePB {
|
||||
email: table.email,
|
||||
name: table.name,
|
||||
token: table.token,
|
||||
icon_url: table.icon_url,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -131,6 +134,7 @@ pub struct UserTableChangeset {
|
||||
pub workspace: Option<String>, // deprecated
|
||||
pub name: Option<String>,
|
||||
pub email: Option<String>,
|
||||
pub icon_url: Option<String>,
|
||||
}
|
||||
|
||||
impl UserTableChangeset {
|
||||
@ -140,6 +144,7 @@ impl UserTableChangeset {
|
||||
workspace: None,
|
||||
name: params.name,
|
||||
email: params.email,
|
||||
icon_url: params.icon_url,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user