Run 'cargo fmt' to format code (#489)
This commit is contained in:
committed by
Baptiste Gelez
parent
732f514da7
commit
b945d1f602
@@ -80,24 +80,40 @@ impl Notification {
|
||||
|
||||
pub fn get_url(&self, conn: &Connection) -> Option<String> {
|
||||
match self.kind.as_ref() {
|
||||
notification_kind::COMMENT => self.get_post(conn).and_then(|p| Some(format!("{}#comment-{}", p.url(conn).ok()?, self.object_id))),
|
||||
notification_kind::COMMENT => self
|
||||
.get_post(conn)
|
||||
.and_then(|p| Some(format!("{}#comment-{}", p.url(conn).ok()?, self.object_id))),
|
||||
notification_kind::FOLLOW => Some(format!("/@/{}/", self.get_actor(conn).ok()?.fqn)),
|
||||
notification_kind::MENTION => Mention::get(conn, self.object_id).and_then(|mention|
|
||||
mention.get_post(conn).and_then(|p| p.url(conn))
|
||||
.or_else(|_| {
|
||||
let comment = mention.get_comment(conn)?;
|
||||
Ok(format!("{}#comment-{}", comment.get_post(conn)?.url(conn)?, comment.id))
|
||||
})
|
||||
).ok(),
|
||||
notification_kind::MENTION => Mention::get(conn, self.object_id)
|
||||
.and_then(|mention| {
|
||||
mention
|
||||
.get_post(conn)
|
||||
.and_then(|p| p.url(conn))
|
||||
.or_else(|_| {
|
||||
let comment = mention.get_comment(conn)?;
|
||||
Ok(format!(
|
||||
"{}#comment-{}",
|
||||
comment.get_post(conn)?.url(conn)?,
|
||||
comment.id
|
||||
))
|
||||
})
|
||||
})
|
||||
.ok(),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_post(&self, conn: &Connection) -> Option<Post> {
|
||||
match self.kind.as_ref() {
|
||||
notification_kind::COMMENT => Comment::get(conn, self.object_id).and_then(|comment| comment.get_post(conn)).ok(),
|
||||
notification_kind::LIKE => Like::get(conn, self.object_id).and_then(|like| Post::get(conn, like.post_id)).ok(),
|
||||
notification_kind::RESHARE => Reshare::get(conn, self.object_id).and_then(|reshare| reshare.get_post(conn)).ok(),
|
||||
notification_kind::COMMENT => Comment::get(conn, self.object_id)
|
||||
.and_then(|comment| comment.get_post(conn))
|
||||
.ok(),
|
||||
notification_kind::LIKE => Like::get(conn, self.object_id)
|
||||
.and_then(|like| Post::get(conn, like.post_id))
|
||||
.ok(),
|
||||
notification_kind::RESHARE => Reshare::get(conn, self.object_id)
|
||||
.and_then(|reshare| reshare.get_post(conn))
|
||||
.ok(),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -105,7 +121,9 @@ impl Notification {
|
||||
pub fn get_actor(&self, conn: &Connection) -> Result<User> {
|
||||
Ok(match self.kind.as_ref() {
|
||||
notification_kind::COMMENT => Comment::get(conn, self.object_id)?.get_author(conn)?,
|
||||
notification_kind::FOLLOW => User::get(conn, Follow::get(conn, self.object_id)?.follower_id)?,
|
||||
notification_kind::FOLLOW => {
|
||||
User::get(conn, Follow::get(conn, self.object_id)?.follower_id)?
|
||||
}
|
||||
notification_kind::LIKE => User::get(conn, Like::get(conn, self.object_id)?.user_id)?,
|
||||
notification_kind::MENTION => Mention::get(conn, self.object_id)?.get_user(conn)?,
|
||||
notification_kind::RESHARE => Reshare::get(conn, self.object_id)?.get_user(conn)?,
|
||||
|
||||
Reference in New Issue
Block a user