From: Dessalines Date: Wed, 15 Jul 2020 14:00:55 +0000 (-0400) Subject: GetSite fixes. Fixes #975 (#978) X-Git-Url: http://these/git/%22https:/image.com/%22%7B%7D/static/%7BmarkdownHelpUrl%7D?a=commitdiff_plain;h=9f36fd50b40f3836691cb3f20b03598e6517417a;p=lemmy.git GetSite fixes. Fixes #975 (#978) --- diff --git a/server/lemmy_db/src/user_view.rs b/server/lemmy_db/src/user_view.rs index f2ac4742..6de6d6b4 100644 --- a/server/lemmy_db/src/user_view.rs +++ b/server/lemmy_db/src/user_view.rs @@ -157,7 +157,10 @@ impl UserView { pub fn admins(conn: &PgConnection) -> Result, 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::>(), 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::(conn) @@ -165,6 +168,9 @@ impl UserView { pub fn banned(conn: &PgConnection) -> Result, Error> { use super::user_view::user_fast::dsl::*; - user_fast.filter(banned.eq(true)).load::(conn) + use diesel::sql_types::{Text, Nullable}; + user_fast + .select((id, actor_id, name, avatar, "".into_sql::>(), 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::(conn) } } diff --git a/server/src/api/user.rs b/server/src/api/user.rs index d547f64b..fa1a9766 100644 --- a/server/src/api/user.rs +++ b/server/src/api/user.rs @@ -639,12 +639,10 @@ impl Perform for Oper { 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; } diff --git a/ui/src/components/user-details.tsx b/ui/src/components/user-details.tsx index e4b4b24a..49b9589e 100644 --- a/ui/src/components/user-details.tsx +++ b/ui/src/components/user-details.tsx @@ -234,6 +234,7 @@ export class UserDetails extends Component { } parseMessage(msg: WebSocketJsonResponse) { + console.log(msg); const res = wsJsonToRes(msg); if (msg.error) { diff --git a/ui/src/components/user.tsx b/ui/src/components/user.tsx index 945206c1..5e5948cd 100644 --- a/ui/src/components/user.tsx +++ b/ui/src/components/user.tsx @@ -1001,6 +1001,7 @@ export class User extends Component { } parseMessage(msg: WebSocketJsonResponse) { + console.log(msg); const res = wsJsonToRes(msg); if (msg.error) { toast(i18n.t(msg.error), 'danger');