Skip to content

Commit

Permalink
Add author field. (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
niksilver committed Jul 28, 2023
1 parent 3c686c3 commit 847e384
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ async fn show_feed(Query(params): Query<ShowFeed>, Host(host): Host) -> Result<R
let mut body = String::new();
body.push_str(
r#"<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
<title>Mastodon Bookmarks</title>
<description></description>
Expand Down Expand Up @@ -201,6 +201,11 @@ async fn show_feed(Query(params): Query<ShowFeed>, Host(host): Host) -> Result<R
body.push_str(&bookmark.url);
body.push_str("]]></title>");
}
if let Some(ref account) = bookmark.account {
body.push_str("<dc:creator><![CDATA[@");
body.push_str(&escape_for_cdata(&account.username));
body.push_str("]]></dc:creator>");
}

body.push_str("<content:encoded><![CDATA[");
body.push_str(&escape_for_cdata(&bookmark.content));
Expand Down Expand Up @@ -234,11 +239,18 @@ struct ShowFeed {
struct UpstreamBookmark {
#[serde(default)]
card: Option<UpstreamCard>,
account: Option<UpstreamAccount>,
url: String,
created_at: String,
content: String,
}

#[derive(Deserialize)]
struct UpstreamAccount {
#[serde(default)]
username: String,
}

#[derive(Deserialize)]
struct UpstreamCard {
#[serde(default)]
Expand Down

0 comments on commit 847e384

Please sign in to comment.