mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-22 20:31:19 +00:00
clippy
This commit is contained in:
parent
9da28935e0
commit
97cdbdce04
2 changed files with 12 additions and 12 deletions
|
@ -59,7 +59,7 @@ async fn convert_response(
|
||||||
removed_or_deleted = c.deleted || c.removed;
|
removed_or_deleted = c.deleted || c.removed;
|
||||||
res.comment = Some(CommentView::read(pool, c.id, user_id).await?)
|
res.comment = Some(CommentView::read(pool, c.id, user_id).await?)
|
||||||
}
|
}
|
||||||
PersonOrCommunity(p) => match p {
|
PersonOrCommunity(p) => match *p {
|
||||||
UserOrCommunity::User(u) => {
|
UserOrCommunity::User(u) => {
|
||||||
removed_or_deleted = u.deleted;
|
removed_or_deleted = u.deleted;
|
||||||
res.person = Some(PersonView::read(pool, u.id).await?)
|
res.person = Some(PersonView::read(pool, u.id).await?)
|
||||||
|
|
|
@ -29,12 +29,12 @@ pub(crate) async fn search_query_to_object_id(
|
||||||
}
|
}
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
// not an url, try to resolve via webfinger
|
// not an url, try to resolve via webfinger
|
||||||
if query.starts_with("!") || query.starts_with("@") {
|
if query.starts_with('!') || query.starts_with('@') {
|
||||||
query.remove(0);
|
query.remove(0);
|
||||||
}
|
}
|
||||||
SearchableObjects::PersonOrCommunity(
|
SearchableObjects::PersonOrCommunity(Box::new(
|
||||||
webfinger_resolve_actor::<LemmyContext, UserOrCommunity>(&query, context).await?,
|
webfinger_resolve_actor::<LemmyContext, UserOrCommunity>(&query, context).await?,
|
||||||
)
|
))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -56,15 +56,15 @@ pub(crate) async fn search_query_to_object_id_local(
|
||||||
pub(crate) enum SearchableObjects {
|
pub(crate) enum SearchableObjects {
|
||||||
Post(ApubPost),
|
Post(ApubPost),
|
||||||
Comment(ApubComment),
|
Comment(ApubComment),
|
||||||
PersonOrCommunity(UserOrCommunity),
|
PersonOrCommunity(Box<UserOrCommunity>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub(crate) enum SearchableKinds {
|
pub(crate) enum SearchableKinds {
|
||||||
Page(Page),
|
Page(Box<Page>),
|
||||||
Note(Note),
|
Note(Note),
|
||||||
PersonOrGroup(PersonOrGroup),
|
PersonOrGroup(Box<PersonOrGroup>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
|
@ -93,7 +93,7 @@ impl Object for SearchableObjects {
|
||||||
) -> Result<Option<Self>, LemmyError> {
|
) -> Result<Option<Self>, LemmyError> {
|
||||||
let uc = UserOrCommunity::read_from_id(object_id.clone(), context).await?;
|
let uc = UserOrCommunity::read_from_id(object_id.clone(), context).await?;
|
||||||
if let Some(uc) = uc {
|
if let Some(uc) = uc {
|
||||||
return Ok(Some(SearchableObjects::PersonOrCommunity(uc)));
|
return Ok(Some(SearchableObjects::PersonOrCommunity(Box::new(uc))));
|
||||||
}
|
}
|
||||||
let p = ApubPost::read_from_id(object_id.clone(), context).await?;
|
let p = ApubPost::read_from_id(object_id.clone(), context).await?;
|
||||||
if let Some(p) = p {
|
if let Some(p) = p {
|
||||||
|
@ -111,7 +111,7 @@ impl Object for SearchableObjects {
|
||||||
match self {
|
match self {
|
||||||
SearchableObjects::Post(p) => p.delete(data).await,
|
SearchableObjects::Post(p) => p.delete(data).await,
|
||||||
SearchableObjects::Comment(c) => c.delete(data).await,
|
SearchableObjects::Comment(c) => c.delete(data).await,
|
||||||
SearchableObjects::PersonOrCommunity(pc) => match pc {
|
SearchableObjects::PersonOrCommunity(pc) => match *pc {
|
||||||
UserOrCommunity::User(p) => p.delete(data).await,
|
UserOrCommunity::User(p) => p.delete(data).await,
|
||||||
UserOrCommunity::Community(c) => c.delete(data).await,
|
UserOrCommunity::Community(c) => c.delete(data).await,
|
||||||
},
|
},
|
||||||
|
@ -131,7 +131,7 @@ impl Object for SearchableObjects {
|
||||||
match apub {
|
match apub {
|
||||||
SearchableKinds::Page(a) => ApubPost::verify(a, expected_domain, data).await,
|
SearchableKinds::Page(a) => ApubPost::verify(a, expected_domain, data).await,
|
||||||
SearchableKinds::Note(a) => ApubComment::verify(a, expected_domain, data).await,
|
SearchableKinds::Note(a) => ApubComment::verify(a, expected_domain, data).await,
|
||||||
SearchableKinds::PersonOrGroup(pg) => match pg {
|
SearchableKinds::PersonOrGroup(pg) => match pg.as_ref() {
|
||||||
PersonOrGroup::Person(a) => ApubPerson::verify(a, expected_domain, data).await,
|
PersonOrGroup::Person(a) => ApubPerson::verify(a, expected_domain, data).await,
|
||||||
PersonOrGroup::Group(a) => ApubCommunity::verify(a, expected_domain, data).await,
|
PersonOrGroup::Group(a) => ApubCommunity::verify(a, expected_domain, data).await,
|
||||||
},
|
},
|
||||||
|
@ -143,10 +143,10 @@ impl Object for SearchableObjects {
|
||||||
use SearchableKinds as SAT;
|
use SearchableKinds as SAT;
|
||||||
use SearchableObjects as SO;
|
use SearchableObjects as SO;
|
||||||
Ok(match apub {
|
Ok(match apub {
|
||||||
SAT::Page(p) => SO::Post(ApubPost::from_json(p, context).await?),
|
SAT::Page(p) => SO::Post(ApubPost::from_json(*p, context).await?),
|
||||||
SAT::Note(n) => SO::Comment(ApubComment::from_json(n, context).await?),
|
SAT::Note(n) => SO::Comment(ApubComment::from_json(n, context).await?),
|
||||||
SAT::PersonOrGroup(pg) => {
|
SAT::PersonOrGroup(pg) => {
|
||||||
SO::PersonOrCommunity(UserOrCommunity::from_json(pg, context).await?)
|
SO::PersonOrCommunity(Box::new(UserOrCommunity::from_json(*pg, context).await?))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue