CommunityModeratorView::for_community(conn, cid)
})
.await??;
- Ok(Some(ApubCommunityModerators { 0: moderators }))
+ Ok(Some(ApubCommunityModerators(moderators)))
} else {
Ok(None)
}
}
// This return value is unused, so just set an empty vec
- Ok(ApubCommunityModerators { 0: vec![] })
+ Ok(ApubCommunityModerators(Vec::new()))
}
type DbType = ();
}
// This return value is unused, so just set an empty vec
- Ok(ApubCommunityOutbox { 0: vec![] })
+ Ok(ApubCommunityOutbox(Vec::new()))
}
type DbType = ();
false
}
})
- .map(|l| l.href.clone())
- .flatten()
+ .filter_map(|l| l.href.clone())
.collect();
for l in links {
let object = ObjectId::<Kind>::new(l)
impl From<Comment> for ApubComment {
fn from(c: Comment) -> Self {
- ApubComment { 0: c }
+ ApubComment(c)
}
}
impl From<Community> for ApubCommunity {
fn from(c: Community) -> Self {
- ApubCommunity { 0: c }
+ ApubCommunity(c)
}
}
impl From<Site> for ApubSite {
fn from(s: Site) -> Self {
- ApubSite { 0: s }
+ ApubSite(s)
}
}
impl From<DbPerson> for ApubPerson {
fn from(p: DbPerson) -> Self {
- ApubPerson { 0: p }
+ ApubPerson(p)
}
}
impl From<Post> for ApubPost {
fn from(p: Post) -> Self {
- ApubPost { 0: p }
+ ApubPost(p)
}
}
impl From<PrivateMessage> for ApubPrivateMessage {
fn from(pm: PrivateMessage) -> Self {
- ApubPrivateMessage { 0: pm }
+ ApubPrivateMessage(pm)
}
}
}
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 {
- let replaced = q.replace("%", "\\%").replace("_", "\\_").replace(" ", "%");
+ let replaced = q.replace('%', "\\%").replace('_', "\\_").replace(' ', "%");
format!("%{}%", replaced)
}
))
.first::<CommentReportViewTuple>(conn)?;
- let my_vote = if comment_like.is_none() {
- None
- } else {
- comment_like
- };
+ let my_vote = comment_like;
Ok(Self {
comment_report,
))
.first::<PostReportViewTuple>(conn)?;
- let my_vote = if post_like.is_none() { None } else { post_like };
+ let my_vote = post_like;
Ok(Self {
post_report,
i.guid(guid);
i.link(url.to_owned());
// TODO add images
- let html = markdown_to_html(&content.to_string());
+ let html = markdown_to_html(content);
i.description(html);
Ok(i.build())
}
.settings()
.webfinger_regex()
.captures(&info.resource)
- .map(|c| c.get(1))
- .flatten()
+ .and_then(|c| c.get(1))
.context(location_info!())?
.as_str()
.to_string();
.opengraph
.images
.get(0)
- .map(|ogo| Url::parse(&ogo.url).ok())
- .flatten();
+ .and_then(|ogo| Url::parse(&ogo.url).ok());
let title = og_title.or(page_title);
let description = og_description.or(page_description);
fn update_banned_when_expired(conn: &PgConnection) {
info!("Updating banned column if it expires ...");
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)
.execute(conn)
.expect("update banned when expires");