]> Untitled Git - lemmy.git/commitdiff
GetSite fixes. Fixes #975 (#978)
authorDessalines <dessalines@users.noreply.github.com>
Wed, 15 Jul 2020 14:00:55 +0000 (10:00 -0400)
committerGitHub <noreply@github.com>
Wed, 15 Jul 2020 14:00:55 +0000 (10:00 -0400)
server/lemmy_db/src/user_view.rs
server/src/api/user.rs
ui/src/components/user-details.tsx
ui/src/components/user.tsx

index f2ac47422492ecc9ad0a2bf7d918a333d2ea855c..6de6d6b4382aad723f7d7fbcff797d11e94180e7 100644 (file)
@@ -157,7 +157,10 @@ impl UserView {
 
   pub fn admins(conn: &PgConnection) -> Result<Vec<Self>, Error> {
     use super::user_view::user_fast::dsl::*;
+    use diesel::sql_types::{Text, Nullable};
     user_fast
+      // The select is necessary here to not get back emails
+      .select((id, actor_id, name, avatar, "".into_sql::<Nullable<Text>>(), matrix_user_id, bio, local, admin, banned, show_avatars, send_notifications_to_email, published, number_of_posts, post_score, number_of_comments, comment_score))
       .filter(admin.eq(true))
       .order_by(published)
       .load::<Self>(conn)
@@ -165,6 +168,9 @@ impl UserView {
 
   pub fn banned(conn: &PgConnection) -> Result<Vec<Self>, Error> {
     use super::user_view::user_fast::dsl::*;
-    user_fast.filter(banned.eq(true)).load::<Self>(conn)
+    use diesel::sql_types::{Text, Nullable};
+    user_fast
+      .select((id, actor_id, name, avatar, "".into_sql::<Nullable<Text>>(), matrix_user_id, bio, local, admin, banned, show_avatars, send_notifications_to_email, published, number_of_posts, post_score, number_of_comments, comment_score))
+      .filter(banned.eq(true)).load::<Self>(conn)
   }
 }
index d547f64b229e4bc9350c157abfb54f8c690eea1f..fa1a97662a5a18cd347a23f7930b7bcb0b875c61 100644 (file)
@@ -639,12 +639,10 @@ impl Perform for Oper<GetUserDetails> {
     let creator_user = admins.remove(creator_index);
     admins.insert(0, creator_user);
 
-    // If its not the same user, remove the email
-    if let Some(user_id) = user_id {
-      if user_details_id != user_id {
-        user_view.email = None;
-      }
-    } else {
+    // If its not the same user, remove the email, and settings
+    // TODO an if let chain would be better here, but can't figure it out
+    // TODO separate out settings into its own thing
+    if user_id.is_none() || user_details_id != user_id.unwrap_or(0) {
       user_view.email = None;
     }
 
index e4b4b24a35a4a9e1a935dcc6fb23788d3e01461c..49b9589e73d3d759ca4ef3de966178c3620b49f0 100644 (file)
@@ -234,6 +234,7 @@ export class UserDetails extends Component<UserDetailsProps, UserDetailsState> {
   }
 
   parseMessage(msg: WebSocketJsonResponse) {
+    console.log(msg);
     const res = wsJsonToRes(msg);
 
     if (msg.error) {
index 945206c1de67202c3166516cd4541fd01d83f44d..5e5948cd696dd1d46cba377b5584a6979229d813 100644 (file)
@@ -1001,6 +1001,7 @@ export class User extends Component<any, UserState> {
   }
 
   parseMessage(msg: WebSocketJsonResponse) {
+    console.log(msg);
     const res = wsJsonToRes(msg);
     if (msg.error) {
       toast(i18n.t(msg.error), 'danger');