mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-15 00:43:59 +00:00
Merge branch 'feature/add-user-secure' of https://github.com/eiknat/lemmy into eiknat-feature/add-user-secure
This commit is contained in:
commit
52ac4f70e1
2 changed files with 30 additions and 1 deletions
|
@ -223,4 +223,33 @@ impl UserView {
|
||||||
.filter(banned.eq(true))
|
.filter(banned.eq(true))
|
||||||
.load::<Self>(conn)
|
.load::<Self>(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_user_secure(conn: &PgConnection, user_id: i32) -> Result<Self, Error> {
|
||||||
|
use super::user_view::user_fast::dsl::*;
|
||||||
|
use diesel::sql_types::{Nullable, Text};
|
||||||
|
user_fast
|
||||||
|
.select((
|
||||||
|
id,
|
||||||
|
actor_id,
|
||||||
|
name,
|
||||||
|
preferred_username,
|
||||||
|
avatar,
|
||||||
|
banner,
|
||||||
|
"".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,
|
||||||
|
))
|
||||||
|
.find(user_id)
|
||||||
|
.first::<Self>(conn)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -857,7 +857,7 @@ impl Perform for Oper<BanUser> {
|
||||||
blocking(pool, move |conn| ModBan::create(conn, &form)).await??;
|
blocking(pool, move |conn| ModBan::create(conn, &form)).await??;
|
||||||
|
|
||||||
let user_id = data.user_id;
|
let user_id = data.user_id;
|
||||||
let user_view = blocking(pool, move |conn| UserView::read(conn, user_id)).await??;
|
let user_view = blocking(pool, move |conn| UserView::get_user_secure(conn, user_id)).await??;
|
||||||
|
|
||||||
let res = BanUserResponse {
|
let res = BanUserResponse {
|
||||||
user: user_view,
|
user: user_view,
|
||||||
|
|
Loading…
Reference in a new issue