mirror of https://github.com/LemmyNet/lemmy.git
Support listing type for person (fixes #4146)
parent
328a48c9f5
commit
bb0a39c02e
|
@ -104,6 +104,7 @@ pub async fn search(
|
|||
users = PersonQuery {
|
||||
sort,
|
||||
search_term: (Some(q)),
|
||||
listing_type: (listing_type),
|
||||
page: (page),
|
||||
limit: (limit),
|
||||
}
|
||||
|
@ -174,6 +175,7 @@ pub async fn search(
|
|||
PersonQuery {
|
||||
sort,
|
||||
search_term: (Some(q)),
|
||||
listing_type: (listing_type),
|
||||
page: (page),
|
||||
limit: (limit),
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ use lemmy_db_schema::{
|
|||
Queries,
|
||||
ReadFn,
|
||||
},
|
||||
ListingType,
|
||||
SortType,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -115,6 +116,15 @@ fn queries<'a>(
|
|||
|
||||
let (limit, offset) = limit_and_offset(options.page, options.limit)?;
|
||||
query = query.limit(limit).offset(offset);
|
||||
|
||||
if let Some(listing_type) = options.listing_type {
|
||||
query = match listing_type {
|
||||
// return nothing as its not possible to follow users
|
||||
ListingType::Subscribed => query.limit(0),
|
||||
ListingType::Local => query.filter(person::local.eq(true)),
|
||||
_ => query,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
query.load::<PersonView>(&mut conn).await
|
||||
|
@ -141,6 +151,7 @@ impl PersonView {
|
|||
pub struct PersonQuery {
|
||||
pub sort: Option<SortType>,
|
||||
pub search_term: Option<String>,
|
||||
pub listing_type: Option<ListingType>,
|
||||
pub page: Option<i64>,
|
||||
pub limit: Option<i64>,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue