diff options
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/api/user.rs | 13 | ||||
-rw-r--r-- | server/src/apub/mod.rs | 2 | ||||
-rw-r--r-- | server/src/db/comment.rs | 1 | ||||
-rw-r--r-- | server/src/db/comment_view.rs | 7 | ||||
-rw-r--r-- | server/src/db/community.rs | 1 | ||||
-rw-r--r-- | server/src/db/community_view.rs | 8 | ||||
-rw-r--r-- | server/src/db/moderator.rs | 2 | ||||
-rw-r--r-- | server/src/db/password_reset_request.rs | 1 | ||||
-rw-r--r-- | server/src/db/post.rs | 1 | ||||
-rw-r--r-- | server/src/db/post_view.rs | 5 | ||||
-rw-r--r-- | server/src/db/site_view.rs | 2 | ||||
-rw-r--r-- | server/src/db/user.rs | 8 | ||||
-rw-r--r-- | server/src/db/user_mention.rs | 2 | ||||
-rw-r--r-- | server/src/db/user_mention_view.rs | 4 | ||||
-rw-r--r-- | server/src/db/user_view.rs | 2 | ||||
-rw-r--r-- | server/src/schema.rs | 2 |
16 files changed, 55 insertions, 6 deletions
diff --git a/server/src/api/user.rs b/server/src/api/user.rs index a04ba4b2..e8ad20aa 100644 --- a/server/src/api/user.rs +++ b/server/src/api/user.rs @@ -27,6 +27,7 @@ pub struct SaveUserSettings { default_sort_type: i16, default_listing_type: i16, lang: String, + avatar: Option<String>, auth: String, } @@ -220,6 +221,7 @@ impl Perform<LoginResponse> for Oper<Register> { name: data.username.to_owned(), fedi_name: Settings::get().hostname.to_owned(), email: data.email.to_owned(), + avatar: None, password_encrypted: data.password.to_owned(), preferred_username: None, updated: None, @@ -314,6 +316,7 @@ impl Perform<LoginResponse> for Oper<SaveUserSettings> { name: read_user.name, fedi_name: read_user.fedi_name, email: read_user.email, + avatar: data.avatar.to_owned(), password_encrypted: read_user.password_encrypted, preferred_username: read_user.preferred_username, updated: Some(naive_now()), @@ -372,7 +375,12 @@ impl Perform<GetUserDetailsResponse> for Oper<GetUserDetails> { data.username.to_owned().unwrap_or("admin".to_string()), ) { Ok(user) => user.id, - Err(_e) => return Err(APIError::err(&self.op, "couldnt_find_that_username_or_email"))? + Err(_e) => { + return Err(APIError::err( + &self.op, + "couldnt_find_that_username_or_email", + ))? + } } } }; @@ -449,6 +457,7 @@ impl Perform<AddAdminResponse> for Oper<AddAdmin> { name: read_user.name, fedi_name: read_user.fedi_name, email: read_user.email, + avatar: read_user.avatar, password_encrypted: read_user.password_encrypted, preferred_username: read_user.preferred_username, updated: Some(naive_now()), @@ -511,6 +520,7 @@ impl Perform<BanUserResponse> for Oper<BanUser> { name: read_user.name, fedi_name: read_user.fedi_name, email: read_user.email, + avatar: read_user.avatar, password_encrypted: read_user.password_encrypted, preferred_username: read_user.preferred_username, updated: Some(naive_now()), @@ -848,6 +858,7 @@ impl Perform<LoginResponse> for Oper<PasswordChange> { name: read_user.name, fedi_name: read_user.fedi_name, email: read_user.email, + avatar: read_user.avatar, password_encrypted: data.password.to_owned(), preferred_username: read_user.preferred_username, updated: Some(naive_now()), diff --git a/server/src/apub/mod.rs b/server/src/apub/mod.rs index 9b861f45..b1a01b6d 100644 --- a/server/src/apub/mod.rs +++ b/server/src/apub/mod.rs @@ -22,7 +22,7 @@ mod tests { preferred_username: None, password_encrypted: "here".into(), email: None, - icon: None, + avatar: None, published: naive_now(), admin: false, banned: false, diff --git a/server/src/db/comment.rs b/server/src/db/comment.rs index b7bd562d..64195356 100644 --- a/server/src/db/comment.rs +++ b/server/src/db/comment.rs @@ -174,6 +174,7 @@ mod tests { preferred_username: None, password_encrypted: "nope".into(), email: None, + avatar: None, admin: false, banned: false, updated: None, diff --git a/server/src/db/comment_view.rs b/server/src/db/comment_view.rs index 5c321e2e..c56da51d 100644 --- a/server/src/db/comment_view.rs +++ b/server/src/db/comment_view.rs @@ -18,6 +18,7 @@ table! { banned -> Bool, banned_from_community -> Bool, creator_name -> Varchar, + creator_avatar -> Nullable<Text>, score -> BigInt, upvotes -> BigInt, downvotes -> BigInt, @@ -46,6 +47,7 @@ pub struct CommentView { pub banned: bool, pub banned_from_community: bool, pub creator_name: String, + pub creator_avatar: Option<String>, pub score: i64, pub upvotes: i64, pub downvotes: i64, @@ -226,6 +228,7 @@ table! { banned -> Bool, banned_from_community -> Bool, creator_name -> Varchar, + creator_avatar -> Nullable<Text>, score -> BigInt, upvotes -> BigInt, downvotes -> BigInt, @@ -255,6 +258,7 @@ pub struct ReplyView { pub banned: bool, pub banned_from_community: bool, pub creator_name: String, + pub creator_avatar: Option<String>, pub score: i64, pub upvotes: i64, pub downvotes: i64, @@ -368,6 +372,7 @@ mod tests { preferred_username: None, password_encrypted: "nope".into(), email: None, + avatar: None, admin: false, banned: false, updated: None, @@ -447,6 +452,7 @@ mod tests { published: inserted_comment.published, updated: None, creator_name: inserted_user.name.to_owned(), + creator_avatar: None, score: 1, downvotes: 0, upvotes: 1, @@ -470,6 +476,7 @@ mod tests { published: inserted_comment.published, updated: None, creator_name: inserted_user.name.to_owned(), + creator_avatar: None, score: 1, downvotes: 0, upvotes: 1, diff --git a/server/src/db/community.rs b/server/src/db/community.rs index e8bf5bbc..b5d05384 100644 --- a/server/src/db/community.rs +++ b/server/src/db/community.rs @@ -220,6 +220,7 @@ mod tests { preferred_username: None, password_encrypted: "nope".into(), email: None, + avatar: None, admin: false, banned: false, updated: None, diff --git a/server/src/db/community_view.rs b/server/src/db/community_view.rs index 157c4d91..e57fd759 100644 --- a/server/src/db/community_view.rs +++ b/server/src/db/community_view.rs @@ -16,6 +16,7 @@ table! { deleted -> Bool, nsfw -> Bool, creator_name -> Varchar, + creator_avatar -> Nullable<Text>, category_name -> Varchar, number_of_subscribers -> BigInt, number_of_posts -> BigInt, @@ -33,6 +34,7 @@ table! { user_id -> Int4, published -> Timestamp, user_name -> Varchar, + avatar -> Nullable<Text>, community_name -> Varchar, } } @@ -44,6 +46,7 @@ table! { user_id -> Int4, published -> Timestamp, user_name -> Varchar, + avatar -> Nullable<Text>, community_name -> Varchar, } } @@ -55,6 +58,7 @@ table! { user_id -> Int4, published -> Timestamp, user_name -> Varchar, + avatar -> Nullable<Text>, community_name -> Varchar, } } @@ -76,6 +80,7 @@ pub struct CommunityView { pub deleted: bool, pub nsfw: bool, pub creator_name: String, + pub creator_avatar: Option<String>, pub category_name: String, pub number_of_subscribers: i64, pub number_of_posts: i64, @@ -224,6 +229,7 @@ pub struct CommunityModeratorView { pub user_id: i32, pub published: chrono::NaiveDateTime, pub user_name: String, + pub avatar: Option<String>, pub community_name: String, } @@ -253,6 +259,7 @@ pub struct CommunityFollowerView { pub user_id: i32, pub published: chrono::NaiveDateTime, pub user_name: String, + pub avatar: Option<String>, pub community_name: String, } @@ -282,6 +289,7 @@ pub struct CommunityUserBanView { pub user_id: i32, pub published: chrono::NaiveDateTime, pub user_name: String, + pub avatar: Option<String>, pub community_name: String, } diff --git a/server/src/db/moderator.rs b/server/src/db/moderator.rs index 22547ca4..7f1c3499 100644 --- a/server/src/db/moderator.rs +++ b/server/src/db/moderator.rs @@ -442,6 +442,7 @@ mod tests { preferred_username: None, password_encrypted: "nope".into(), email: None, + avatar: None, admin: false, banned: false, updated: None, @@ -460,6 +461,7 @@ mod tests { preferred_username: None, password_encrypted: "nope".into(), email: None, + avatar: None, admin: false, banned: false, updated: None, diff --git a/server/src/db/password_reset_request.rs b/server/src/db/password_reset_request.rs index 91e27c57..b7983f53 100644 --- a/server/src/db/password_reset_request.rs +++ b/server/src/db/password_reset_request.rs @@ -92,6 +92,7 @@ mod tests { preferred_username: None, password_encrypted: "nope".into(), email: None, + avatar: None, admin: false, banned: false, updated: None, diff --git a/server/src/db/post.rs b/server/src/db/post.rs index 96ae31db..da669ea1 100644 --- a/server/src/db/post.rs +++ b/server/src/db/post.rs @@ -187,6 +187,7 @@ mod tests { preferred_username: None, password_encrypted: "nope".into(), email: None, + avatar: None, admin: false, banned: false, updated: None, diff --git a/server/src/db/post_view.rs b/server/src/db/post_view.rs index 615b9b0d..d05eecca 100644 --- a/server/src/db/post_view.rs +++ b/server/src/db/post_view.rs @@ -21,6 +21,7 @@ table! { banned_from_community -> Bool, stickied -> Bool, creator_name -> Varchar, + creator_avatar -> Nullable<Text>, community_name -> Varchar, community_removed -> Bool, community_deleted -> Bool, @@ -59,6 +60,7 @@ pub struct PostView { pub banned_from_community: bool, pub stickied: bool, pub creator_name: String, + pub creator_avatar: Option<String>, pub community_name: String, pub community_removed: bool, pub community_deleted: bool, @@ -303,6 +305,7 @@ mod tests { preferred_username: None, password_encrypted: "nope".into(), email: None, + avatar: None, updated: None, admin: false, banned: false, @@ -377,6 +380,7 @@ mod tests { body: None, creator_id: inserted_user.id, creator_name: user_name.to_owned(), + creator_avatar: None, banned: false, banned_from_community: false, community_id: inserted_community.id, @@ -414,6 +418,7 @@ mod tests { stickied: false, creator_id: inserted_user.id, creator_name: user_name.to_owned(), + creator_avatar: None, banned: false, banned_from_community: false, community_id: inserted_community.id, diff --git a/server/src/db/site_view.rs b/server/src/db/site_view.rs index 40b1265f..674a7a6e 100644 --- a/server/src/db/site_view.rs +++ b/server/src/db/site_view.rs @@ -12,6 +12,7 @@ table! { open_registration -> Bool, enable_nsfw -> Bool, creator_name -> Varchar, + creator_avatar -> Nullable<Text>, number_of_users -> BigInt, number_of_posts -> BigInt, number_of_comments -> BigInt, @@ -34,6 +35,7 @@ pub struct SiteView { pub open_registration: bool, pub enable_nsfw: bool, pub creator_name: String, + pub creator_avatar: Option<String>, pub number_of_users: i64, pub number_of_posts: i64, pub number_of_comments: i64, diff --git a/server/src/db/user.rs b/server/src/db/user.rs index c636f4e6..db4aa453 100644 --- a/server/src/db/user.rs +++ b/server/src/db/user.rs @@ -14,7 +14,7 @@ pub struct User_ { pub preferred_username: Option<String>, pub password_encrypted: String, pub email: Option<String>, - pub icon: Option<Vec<u8>>, + pub avatar: Option<String>, pub admin: bool, pub banned: bool, pub published: chrono::NaiveDateTime, @@ -36,6 +36,7 @@ pub struct UserForm { pub admin: bool, pub banned: bool, pub email: Option<String>, + pub avatar: Option<String>, pub updated: Option<chrono::NaiveDateTime>, pub show_nsfw: bool, pub theme: String, @@ -99,6 +100,7 @@ pub struct Claims { pub default_sort_type: i16, pub default_listing_type: i16, pub lang: String, + pub avatar: Option<String>, } impl Claims { @@ -123,6 +125,7 @@ impl User_ { default_sort_type: self.default_sort_type, default_listing_type: self.default_listing_type, lang: self.lang.to_owned(), + avatar: self.avatar.to_owned(), }; encode( &Header::default(), @@ -176,6 +179,7 @@ mod tests { preferred_username: None, password_encrypted: "nope".into(), email: None, + avatar: None, admin: false, banned: false, updated: None, @@ -195,7 +199,7 @@ mod tests { preferred_username: None, password_encrypted: "nope".into(), email: None, - icon: None, + avatar: None, admin: false, banned: false, published: inserted_user.published, diff --git a/server/src/db/user_mention.rs b/server/src/db/user_mention.rs index 7eb4d486..5392c87a 100644 --- a/server/src/db/user_mention.rs +++ b/server/src/db/user_mention.rs @@ -68,6 +68,7 @@ mod tests { preferred_username: None, password_encrypted: "nope".into(), email: None, + avatar: None, admin: false, banned: false, updated: None, @@ -86,6 +87,7 @@ mod tests { preferred_username: None, password_encrypted: "nope".into(), email: None, + avatar: None, admin: false, banned: false, updated: None, diff --git a/server/src/db/user_mention_view.rs b/server/src/db/user_mention_view.rs index 45541861..7a45d222 100644 --- a/server/src/db/user_mention_view.rs +++ b/server/src/db/user_mention_view.rs @@ -20,6 +20,7 @@ table! { banned -> Bool, banned_from_community -> Bool, creator_name -> Varchar, + creator_avatar -> Nullable<Text>, score -> BigInt, upvotes -> BigInt, downvotes -> BigInt, @@ -50,6 +51,7 @@ pub struct UserMentionView { pub banned: bool, pub banned_from_community: bool, pub creator_name: String, + pub creator_avatar: Option<String>, pub score: i64, pub upvotes: i64, pub downvotes: i64, @@ -78,7 +80,7 @@ impl<'a> UserMentionQueryBuilder<'a> { UserMentionQueryBuilder { conn, query, - for_user_id: for_user_id, + for_user_id, sort: &SortType::New, unread_only: false, page: None, diff --git a/server/src/db/user_view.rs b/server/src/db/user_view.rs index 0ed95eef..616159de 100644 --- a/server/src/db/user_view.rs +++ b/server/src/db/user_view.rs @@ -6,6 +6,7 @@ table! { user_view (id) { id -> Int4, name -> Varchar, + avatar -> Nullable<Text>, fedi_name -> Varchar, admin -> Bool, banned -> Bool, @@ -24,6 +25,7 @@ table! { pub struct UserView { pub id: i32, pub name: String, + pub avatar: Option<String>, pub fedi_name: String, pub admin: bool, pub banned: bool, diff --git a/server/src/schema.rs b/server/src/schema.rs index 118f5f4a..86834072 100644 --- a/server/src/schema.rs +++ b/server/src/schema.rs @@ -260,7 +260,7 @@ table! { preferred_username -> Nullable<Varchar>, password_encrypted -> Text, email -> Nullable<Text>, - icon -> Nullable<Bytea>, + avatar -> Nullable<Text>, admin -> Bool, banned -> Bool, published -> Timestamp, |