|
|
|
@ -1,7 +1,7 @@ |
|
|
|
|
use crate::entities::event::Event; |
|
|
|
|
use crate::entities::notification::{Notification, NotificationType}; |
|
|
|
|
use crate::entities::status::Status; |
|
|
|
|
use std::fmt::{Display, Formatter}; |
|
|
|
|
use crate::entities::event::Event; |
|
|
|
|
|
|
|
|
|
pub struct NotificationDisplay<'a>(pub &'a Notification); |
|
|
|
|
|
|
|
|
@ -10,32 +10,42 @@ impl<'a> Display for NotificationDisplay<'a> { |
|
|
|
|
let n = self.0; |
|
|
|
|
match &n.notification_type { |
|
|
|
|
NotificationType::Follow => { |
|
|
|
|
write!(f, "Follow {{ #{}, @{} }}", n.id, n.account.acct ) |
|
|
|
|
write!(f, "Follow {{ #{}, @{} }}", n.id, n.account.acct) |
|
|
|
|
} |
|
|
|
|
NotificationType::Favourite => { |
|
|
|
|
if let Some(ref s) = n.status { |
|
|
|
|
write!(f, "Favourite {{ #{}, acct: @{}, status: «{}» }}", n.id, n.account.acct, s.content ) |
|
|
|
|
write!( |
|
|
|
|
f, |
|
|
|
|
"Favourite {{ #{}, acct: @{}, status: «{}» }}", |
|
|
|
|
n.id, n.account.acct, s.content |
|
|
|
|
) |
|
|
|
|
} else { |
|
|
|
|
write!(f, "Favourite {{ #{}, acct: @{}, status: -- }}", n.id, n.account.acct ) |
|
|
|
|
write!(f, "Favourite {{ #{}, acct: @{}, status: -- }}", n.id, n.account.acct) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
NotificationType::Mention => { |
|
|
|
|
if let Some(ref s) = n.status { |
|
|
|
|
write!(f, "Mention {{ #{}, acct: @{}, status: «{}» }}", n.id, n.account.acct, s.content ) |
|
|
|
|
write!( |
|
|
|
|
f, |
|
|
|
|
"Mention {{ #{}, acct: @{}, status: «{}» }}", |
|
|
|
|
n.id, n.account.acct, s.content |
|
|
|
|
) |
|
|
|
|
} else { |
|
|
|
|
write!(f, "Mention {{ #{}, acct: @{}, status: -- }}", n.id, n.account.acct ) |
|
|
|
|
write!(f, "Mention {{ #{}, acct: @{}, status: -- }}", n.id, n.account.acct) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
NotificationType::Reblog => { |
|
|
|
|
if let Some(ref s) = n.status { |
|
|
|
|
write!(f, "Reblog {{ #{}, acct: @{}, status: «{}» }}", n.id, n.account.acct, s.content ) |
|
|
|
|
write!( |
|
|
|
|
f, |
|
|
|
|
"Reblog {{ #{}, acct: @{}, status: «{}» }}", |
|
|
|
|
n.id, n.account.acct, s.content |
|
|
|
|
) |
|
|
|
|
} else { |
|
|
|
|
write!(f, "Reblog {{ #{}, acct: @{}, status: -- }}", n.id, n.account.acct ) |
|
|
|
|
} |
|
|
|
|
write!(f, "Reblog {{ #{}, acct: @{}, status: -- }}", n.id, n.account.acct) |
|
|
|
|
} |
|
|
|
|
NotificationType::Other(other) => { |
|
|
|
|
f.write_str(&other) |
|
|
|
|
} |
|
|
|
|
NotificationType::Other(other) => f.write_str(&other), |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -46,9 +56,7 @@ impl<'a> Display for EventDisplay<'a> { |
|
|
|
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { |
|
|
|
|
let n = self.0; |
|
|
|
|
match n { |
|
|
|
|
Event::Notification(n) => { |
|
|
|
|
NotificationDisplay(n).fmt(f) |
|
|
|
|
} |
|
|
|
|
Event::Notification(n) => NotificationDisplay(n).fmt(f), |
|
|
|
|
Event::Delete(id) => { |
|
|
|
|
write!(f, "Delete {{ #{} }}", id) |
|
|
|
|
} |
|
|
|
@ -58,9 +66,7 @@ impl<'a> Display for EventDisplay<'a> { |
|
|
|
|
Event::Heartbeat => { |
|
|
|
|
write!(f, "Heartbeat") |
|
|
|
|
} |
|
|
|
|
Event::Update(s) => { |
|
|
|
|
StatusDisplay(s).fmt(f) |
|
|
|
|
} |
|
|
|
|
Event::Update(s) => StatusDisplay(s).fmt(f), |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -69,6 +75,10 @@ pub struct StatusDisplay<'a>(pub &'a Status); |
|
|
|
|
|
|
|
|
|
impl<'a> Display for StatusDisplay<'a> { |
|
|
|
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { |
|
|
|
|
write!(f, "Status {{ #{}, acct: @{}, status: «{}», vis: {:?} }}", self.0.id, self.0.account.acct, self.0.content, self.0.visibility ) |
|
|
|
|
write!( |
|
|
|
|
f, |
|
|
|
|
"Status {{ #{}, acct: @{}, status: «{}», vis: {:?} }}", |
|
|
|
|
self.0.id, self.0.account.acct, self.0.content, self.0.visibility |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|