mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-06-02 21:49:22 +00:00
f858d8cbce
* Remove explicit auth params (ref #3725) Only take auth via header or cookie. This requires a new version of lemmy-js-client for api tests to pass. * rework api_crud * remove remaining auth params, move logic to session middleware * fmt, fix test * update js client * remove auth param from api tests * Pass auth as header * add ! * url vars, setHeader * cleanup * fmt * update * Updating for new lemmy-js-client. --------- Co-authored-by: Dessalines <tyhou13@gmx.com> Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
37 lines
1,003 B
Rust
37 lines
1,003 B
Rust
use actix_web::web::{Data, Json, Query};
|
|
use lemmy_api_common::{
|
|
context::LemmyContext,
|
|
person::{GetReplies, GetRepliesResponse},
|
|
};
|
|
use lemmy_db_views::structs::LocalUserView;
|
|
use lemmy_db_views_actor::comment_reply_view::CommentReplyQuery;
|
|
use lemmy_utils::error::LemmyError;
|
|
|
|
#[tracing::instrument(skip(context))]
|
|
pub async fn list_replies(
|
|
data: Query<GetReplies>,
|
|
context: Data<LemmyContext>,
|
|
local_user_view: LocalUserView,
|
|
) -> Result<Json<GetRepliesResponse>, LemmyError> {
|
|
let sort = data.sort;
|
|
let page = data.page;
|
|
let limit = data.limit;
|
|
let unread_only = data.unread_only.unwrap_or_default();
|
|
let person_id = Some(local_user_view.person.id);
|
|
let show_bot_accounts = local_user_view.local_user.show_bot_accounts;
|
|
|
|
let replies = CommentReplyQuery {
|
|
recipient_id: person_id,
|
|
my_person_id: person_id,
|
|
sort,
|
|
unread_only,
|
|
show_bot_accounts,
|
|
page,
|
|
limit,
|
|
}
|
|
.list(&mut context.pool())
|
|
.await?;
|
|
|
|
Ok(Json(GetRepliesResponse { replies }))
|
|
}
|