colour: char,
account: String,
nameline: String,
+ id: String,
}
impl UsernameHeader {
- pub fn from(account: &str, nameline: &str) -> Self {
+ pub fn from(account: &str, nameline: &str, id: &str) -> Self {
UsernameHeader{
header: "From".to_owned(),
colour: 'F',
account: account.to_owned(),
nameline: nameline.to_owned(),
+ id: id.to_owned(),
}
}
- pub fn via(account: &str, nameline: &str) -> Self {
+ pub fn via(account: &str, nameline: &str, id: &str) -> Self {
UsernameHeader{
header: "Via".to_owned(),
colour: 'f',
account: account.to_owned(),
nameline: nameline.to_owned(),
+ id: id.to_owned(),
}
}
}
#[test]
fn test_userheader() {
- assert_eq!(UsernameHeader::from("stoat@example.com", "Some Person")
+ assert_eq!(UsernameHeader::from("stoat@example.com", "Some Person", "123")
.render(80), vec! {
ColouredString::general(
"From: Some Person (stoat@example.com)",
" FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
)
});
- assert_eq!(UsernameHeader::via("stoat@example.com", "Some Person")
+ assert_eq!(UsernameHeader::via("stoat@example.com", "Some Person", "123")
.render(80), vec! {
ColouredString::general(
"Via: Some Person (stoat@example.com)",
pub struct NotificationLog {
timestamp: DateTime<Utc>,
account_desc: String,
+ account_id: String,
+ status_id: Option<String>,
para: Paragraph,
}
impl NotificationLog {
pub fn new(
timestamp: DateTime<Utc>, account: &str, nameline: &str,
- ntype: NotificationType, post: Option<&Paragraph>)
- -> Self {
-
+ account_id: &str, ntype: NotificationType, post: Option<&Paragraph>,
+ status_id: Option<&str>)
+ -> Self
+ {
let mut para = Paragraph::new();
let verb = match ntype {
para.delete_mention_words_from(currlen);
}
+ let status_id = match status_id {
+ None => None,
+ Some(s) => Some(s.to_owned()),
+ };
+
NotificationLog {
timestamp,
account_desc: format!("{} ({})", nameline, account),
+ account_id: account_id.to_owned(),
+ status_id,
para,
}
}
None => None,
Some(st) => Some(Html::new(&st.content).to_para()),
};
+ let status_id = match ¬.status {
+ None => None,
+ Some(st) => Some(&st.id as &str),
+ };
Self::new(
not.created_at,
&client.fq(¬.account.acct),
¬.account.display_name,
+ ¬.account.id,
not.ntype,
para.as_ref(),
+ status_id,
)
}
}
));
assert_eq!(NotificationLog::new(
- t, "foo@example.com", "Foo Bar",
+ t, "foo@example.com", "Foo Bar", "123", None,
NotificationType::Reblog, Some(&post)).render(80), vec! {
ColouredString::general("Fri Aug 3 04:05:06 2001 Foo Bar (foo@example.com) boosted: take a look at this",
" "),
});
assert_eq!(NotificationLog::new(
- t, "foo@example.com", "Foo Bar",
+ t, "foo@example.com", "Foo Bar", "123", None,
NotificationType::Favourite, Some(&post)).render(51), vec! {
ColouredString::general("Fri Aug 3 04:05:06 2001 Foo Bar (foo@example.com)",
" "),
});
assert_eq!(NotificationLog::new(
- t, "foo@example.com", "Foo Bar",
+ t, "foo@example.com", "Foo Bar", "123", None,
NotificationType::Follow, None).render(80), vec! {
ColouredString::general("Fri Aug 3 04:05:06 2001 Foo Bar (foo@example.com) followed you",
" "),
content: Html,
media: Vec<Media>,
blank: BlankLine,
+ id: String,
}
impl StatusDisplay {
st.reblogged == Some(true));
let from = UsernameHeader::from(
- &client.fq(&st.account.acct), &st.account.display_name);
+ &client.fq(&st.account.acct), &st.account.display_name,
+ &st.account.id);
let via = match via {
None => None,
Some(booster) => Some(UsernameHeader::via(
- &client.fq(&booster.acct), &booster.display_name)),
+ &client.fq(&booster.acct), &booster.display_name,
+ &booster.id)),
};
let irt = match &st.in_reply_to_id {
content,
media,
blank: BlankLine::new(),
+ id: st.id.clone(),
}
}
}
creation: Paragraph,
lastedit: Paragraph,
reply_to: Paragraph,
+ reply_to_id: Option<String>,
reply_to_user: Paragraph,
+ reply_to_user_id: Option<String>,
language: Paragraph,
visibility: Paragraph,
sensitive: Paragraph,
boosts: Paragraph,
favourites: Paragraph,
mentions_header: Option<Paragraph>,
- mentions: Vec<Paragraph>,
+ mentions: Vec<(Paragraph, String)>,
client_name: Paragraph,
client_url: Paragraph,
sep: SeparatorLine,
.add(&st.in_reply_to_id.as_ref().map_or_else(
|| ColouredString::uniform("none", '0'),
|s| ColouredString::plain(s)));
+ let reply_to_id = st.in_reply_to_id.clone();
let reply_to_user = Paragraph::new()
.add(&ColouredString::plain("Reply to account: "))
.add(&st.in_reply_to_account_id.as_ref().map_or_else(
|| ColouredString::uniform("none", '0'),
|s| ColouredString::plain(s)));
+ let reply_to_user_id = st.in_reply_to_account_id.clone();
let language = Paragraph::new()
.add(&ColouredString::plain("Language: "))
&format!("Favourites: {}", st.favourites_count)));
let mentions: Vec<_> = st.mentions.iter().map(|m| {
- Paragraph::new().set_indent(2, 2)
- .add(&ColouredString::uniform(&client.fq(&m.acct), 'f'))
+ let para = Paragraph::new().set_indent(2, 2)
+ .add(&ColouredString::uniform(&client.fq(&m.acct), 'f'));
+ (para, m.id.to_owned())
}).collect();
let mentions_header = if mentions.is_empty() {
None
creation,
lastedit,
reply_to,
+ reply_to_id,
reply_to_user,
+ reply_to_user_id,
language,
visibility,
sensitive,
if !self.mentions.is_empty() {
push_fragment(&mut lines, self.mentions_header.render(width));
- push_fragment(&mut lines, self.mentions.render(width));
+ for (para, _id) in &self.mentions {
+ let mut rendered = para.render(width);
+ push_fragment(&mut lines, rendered);
+ }
push_fragment(&mut lines, self.blank.render(width));
}