Add missing <link rel="self"> element to Atom feeds
This commit is contained in:
parent
780b165a8b
commit
9fc87803e5
|
@ -14,6 +14,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
|
|
||||||
- Dropped support for `blockchain` configuration parameter.
|
- Dropped support for `blockchain` configuration parameter.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Added missing `<link rel="self">` element to Atom feeds.
|
||||||
|
|
||||||
## [1.11.0] - 2023-01-23
|
## [1.11.0] - 2023-01-23
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -42,15 +42,20 @@ fn make_entry(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_feed_url(instance_url: &str, username: &str) -> String {
|
||||||
|
format!("{}/feeds/{}", instance_url, username)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn make_feed(
|
pub fn make_feed(
|
||||||
instance: &Instance,
|
instance: &Instance,
|
||||||
profile: &DbActorProfile,
|
profile: &DbActorProfile,
|
||||||
posts: Vec<Post>,
|
posts: Vec<Post>,
|
||||||
) -> String {
|
) -> String {
|
||||||
let actor_url = local_actor_id(&instance.url(), &profile.username);
|
let actor_id = local_actor_id(&instance.url(), &profile.username);
|
||||||
let actor_name = profile.display_name.as_ref()
|
let actor_name = profile.display_name.as_ref()
|
||||||
.unwrap_or(&profile.username);
|
.unwrap_or(&profile.username);
|
||||||
let actor_address = profile.actor_address(&instance.hostname());
|
let actor_address = profile.actor_address(&instance.hostname());
|
||||||
|
let feed_url = get_feed_url(&instance.url(), &profile.username);
|
||||||
let feed_title = format!("{} (@{})", actor_name, actor_address);
|
let feed_title = format!("{} (@{})", actor_name, actor_address);
|
||||||
let mut entries = vec![];
|
let mut entries = vec![];
|
||||||
let mut feed_updated_at = get_min_datetime();
|
let mut feed_updated_at = get_min_datetime();
|
||||||
|
@ -64,12 +69,14 @@ pub fn make_feed(
|
||||||
format!(
|
format!(
|
||||||
r#"<?xml version="1.0" encoding="utf-8"?>
|
r#"<?xml version="1.0" encoding="utf-8"?>
|
||||||
<feed xmlns="http://www.w3.org/2005/Atom">
|
<feed xmlns="http://www.w3.org/2005/Atom">
|
||||||
<id>{url}</id>
|
<id>{id}</id>
|
||||||
|
<link rel="self" href="{url}"/>
|
||||||
<title>{title}</title>
|
<title>{title}</title>
|
||||||
<updated>{updated_at}</updated>
|
<updated>{updated_at}</updated>
|
||||||
{entries}
|
{entries}
|
||||||
</feed>"#,
|
</feed>"#,
|
||||||
url=actor_url,
|
id=actor_id,
|
||||||
|
url=feed_url,
|
||||||
title=feed_title,
|
title=feed_title,
|
||||||
updated_at=feed_updated_at.to_rfc3339(),
|
updated_at=feed_updated_at.to_rfc3339(),
|
||||||
entries=entries.join("\n"),
|
entries=entries.join("\n"),
|
||||||
|
|
Loading…
Reference in a new issue