mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-22 14:45:10 +00:00
Clippy fixes.
This commit is contained in:
parent
3ad172e8ed
commit
4cf0da7b60
|
@ -41,7 +41,7 @@ impl ApubObject for ApubCommunityModerators {
|
||||||
CommunityModeratorView::for_community(conn, cid)
|
CommunityModeratorView::for_community(conn, cid)
|
||||||
})
|
})
|
||||||
.await??;
|
.await??;
|
||||||
Ok(Some(ApubCommunityModerators { 0: moderators }))
|
Ok(Some(ApubCommunityModerators(moderators)))
|
||||||
} else {
|
} else {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,7 @@ impl ApubObject for ApubCommunityModerators {
|
||||||
}
|
}
|
||||||
|
|
||||||
// This return value is unused, so just set an empty vec
|
// This return value is unused, so just set an empty vec
|
||||||
Ok(ApubCommunityModerators { 0: vec![] })
|
Ok(ApubCommunityModerators(Vec::new()))
|
||||||
}
|
}
|
||||||
|
|
||||||
type DbType = ();
|
type DbType = ();
|
||||||
|
|
|
@ -116,7 +116,7 @@ impl ApubObject for ApubCommunityOutbox {
|
||||||
}
|
}
|
||||||
|
|
||||||
// This return value is unused, so just set an empty vec
|
// This return value is unused, so just set an empty vec
|
||||||
Ok(ApubCommunityOutbox { 0: vec![] })
|
Ok(ApubCommunityOutbox(Vec::new()))
|
||||||
}
|
}
|
||||||
|
|
||||||
type DbType = ();
|
type DbType = ();
|
||||||
|
|
|
@ -73,8 +73,7 @@ where
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.map(|l| l.href.clone())
|
.filter_map(|l| l.href.clone())
|
||||||
.flatten()
|
|
||||||
.collect();
|
.collect();
|
||||||
for l in links {
|
for l in links {
|
||||||
let object = ObjectId::<Kind>::new(l)
|
let object = ObjectId::<Kind>::new(l)
|
||||||
|
|
|
@ -47,7 +47,7 @@ impl Deref for ApubComment {
|
||||||
|
|
||||||
impl From<Comment> for ApubComment {
|
impl From<Comment> for ApubComment {
|
||||||
fn from(c: Comment) -> Self {
|
fn from(c: Comment) -> Self {
|
||||||
ApubComment { 0: c }
|
ApubComment(c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ impl Deref for ApubCommunity {
|
||||||
|
|
||||||
impl From<Community> for ApubCommunity {
|
impl From<Community> for ApubCommunity {
|
||||||
fn from(c: Community) -> Self {
|
fn from(c: Community) -> Self {
|
||||||
ApubCommunity { 0: c }
|
ApubCommunity(c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ impl Deref for ApubSite {
|
||||||
|
|
||||||
impl From<Site> for ApubSite {
|
impl From<Site> for ApubSite {
|
||||||
fn from(s: Site) -> Self {
|
fn from(s: Site) -> Self {
|
||||||
ApubSite { 0: s }
|
ApubSite(s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ impl Deref for ApubPerson {
|
||||||
|
|
||||||
impl From<DbPerson> for ApubPerson {
|
impl From<DbPerson> for ApubPerson {
|
||||||
fn from(p: DbPerson) -> Self {
|
fn from(p: DbPerson) -> Self {
|
||||||
ApubPerson { 0: p }
|
ApubPerson(p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ impl Deref for ApubPost {
|
||||||
|
|
||||||
impl From<Post> for ApubPost {
|
impl From<Post> for ApubPost {
|
||||||
fn from(p: Post) -> Self {
|
fn from(p: Post) -> Self {
|
||||||
ApubPost { 0: p }
|
ApubPost(p)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ impl Deref for ApubPrivateMessage {
|
||||||
|
|
||||||
impl From<PrivateMessage> for ApubPrivateMessage {
|
impl From<PrivateMessage> for ApubPrivateMessage {
|
||||||
fn from(pm: PrivateMessage) -> Self {
|
fn from(pm: PrivateMessage) -> Self {
|
||||||
ApubPrivateMessage { 0: pm }
|
ApubPrivateMessage(pm)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,11 +65,11 @@ pub enum SearchType {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_opt_str_to_opt_enum<T: std::str::FromStr>(opt: &Option<String>) -> Option<T> {
|
pub fn from_opt_str_to_opt_enum<T: std::str::FromStr>(opt: &Option<String>) -> Option<T> {
|
||||||
opt.as_ref().map(|t| T::from_str(t).ok()).flatten()
|
opt.as_ref().and_then(|t| T::from_str(t).ok())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fuzzy_search(q: &str) -> String {
|
pub fn fuzzy_search(q: &str) -> String {
|
||||||
let replaced = q.replace("%", "\\%").replace("_", "\\_").replace(" ", "%");
|
let replaced = q.replace('%', "\\%").replace('_', "\\_").replace(' ', "%");
|
||||||
format!("%{}%", replaced)
|
format!("%{}%", replaced)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,11 +120,7 @@ impl CommentReportView {
|
||||||
))
|
))
|
||||||
.first::<CommentReportViewTuple>(conn)?;
|
.first::<CommentReportViewTuple>(conn)?;
|
||||||
|
|
||||||
let my_vote = if comment_like.is_none() {
|
let my_vote = comment_like;
|
||||||
None
|
|
||||||
} else {
|
|
||||||
comment_like
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
comment_report,
|
comment_report,
|
||||||
|
|
|
@ -111,7 +111,7 @@ impl PostReportView {
|
||||||
))
|
))
|
||||||
.first::<PostReportViewTuple>(conn)?;
|
.first::<PostReportViewTuple>(conn)?;
|
||||||
|
|
||||||
let my_vote = if post_like.is_none() { None } else { post_like };
|
let my_vote = post_like;
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
post_report,
|
post_report,
|
||||||
|
|
|
@ -373,7 +373,7 @@ fn build_item(
|
||||||
i.guid(guid);
|
i.guid(guid);
|
||||||
i.link(url.to_owned());
|
i.link(url.to_owned());
|
||||||
// TODO add images
|
// TODO add images
|
||||||
let html = markdown_to_html(&content.to_string());
|
let html = markdown_to_html(content);
|
||||||
i.description(html);
|
i.description(html);
|
||||||
Ok(i.build())
|
Ok(i.build())
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,8 +39,7 @@ async fn get_webfinger_response(
|
||||||
.settings()
|
.settings()
|
||||||
.webfinger_regex()
|
.webfinger_regex()
|
||||||
.captures(&info.resource)
|
.captures(&info.resource)
|
||||||
.map(|c| c.get(1))
|
.and_then(|c| c.get(1))
|
||||||
.flatten()
|
|
||||||
.context(location_info!())?
|
.context(location_info!())?
|
||||||
.as_str()
|
.as_str()
|
||||||
.to_string();
|
.to_string();
|
||||||
|
|
|
@ -138,8 +138,7 @@ fn html_to_site_metadata(html_bytes: &[u8]) -> Result<SiteMetadata, LemmyError>
|
||||||
.opengraph
|
.opengraph
|
||||||
.images
|
.images
|
||||||
.get(0)
|
.get(0)
|
||||||
.map(|ogo| Url::parse(&ogo.url).ok())
|
.and_then(|ogo| Url::parse(&ogo.url).ok());
|
||||||
.flatten();
|
|
||||||
|
|
||||||
let title = og_title.or(page_title);
|
let title = og_title.or(page_title);
|
||||||
let description = og_description.or(page_description);
|
let description = og_description.or(page_description);
|
||||||
|
|
|
@ -98,7 +98,7 @@ fn active_counts(conn: &PgConnection) {
|
||||||
fn update_banned_when_expired(conn: &PgConnection) {
|
fn update_banned_when_expired(conn: &PgConnection) {
|
||||||
info!("Updating banned column if it expires ...");
|
info!("Updating banned column if it expires ...");
|
||||||
let update_ban_expires_stmt =
|
let update_ban_expires_stmt =
|
||||||
format!("update person set banned = false where banned = true and ban_expires < now()");
|
"update person set banned = false where banned = true and ban_expires < now()";
|
||||||
sql_query(update_ban_expires_stmt)
|
sql_query(update_ban_expires_stmt)
|
||||||
.execute(conn)
|
.execute(conn)
|
||||||
.expect("update banned when expires");
|
.expect("update banned when expires");
|
||||||
|
|
Loading…
Reference in a new issue