Differentiate between publish and update time
Check and lint using Cargo / Check and lint (push) Successful in 6m42s
Details
Check and lint using Cargo / Check and lint (push) Successful in 6m42s
Details
The `pubDate` field of an item in the feed is meant to be time the item was published. It should not be bumped if the item is updated in the backend. * Introduce a new `published_at` field on `Item` * Update the Mixcloud and YouTube backends to fill this field * Use the `published_at` field on `Item` for the `<pubData>` item subelement
This commit is contained in:
parent
9fc9990c27
commit
f7a5477804
|
@ -109,6 +109,9 @@ pub(crate) struct Item {
|
|||
/// The URL of the image of the item.
|
||||
pub(crate) image: Option<Url>,
|
||||
|
||||
/// The timestamp the item was published.
|
||||
pub(crate) published_at: DateTime<Utc>,
|
||||
|
||||
/// The timestamp the item was last updated.
|
||||
pub(crate) updated_at: DateTime<Utc>,
|
||||
}
|
||||
|
|
|
@ -157,7 +157,10 @@ pub(crate) struct Cloudcast {
|
|||
/// The tags of the cloudcast.
|
||||
pub(crate) tags: Vec<Tag>,
|
||||
|
||||
/// The time the feed was created/started.
|
||||
/// The time the feed was created.
|
||||
pub(crate) created_time: DateTime<Utc>,
|
||||
|
||||
/// The time the feed was updated.
|
||||
pub(crate) updated_time: DateTime<Utc>,
|
||||
|
||||
/// The original URL of the cloudcast.
|
||||
|
@ -227,6 +230,7 @@ impl From<Cloudcast> for Item {
|
|||
guid: cloudcast.slug,
|
||||
keywords,
|
||||
image: Some(cloudcast.pictures.large),
|
||||
published_at: cloudcast.created_time,
|
||||
updated_at: cloudcast.updated_time,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -224,7 +224,9 @@ impl From<YouTubeVideoWithStream> for Item {
|
|||
.date()
|
||||
.and_hms_opt(12, 0, 0)
|
||||
.expect("Invalid hour, minute and/or second");
|
||||
let updated_at = DateTime::from_utc(timestamp, Utc);
|
||||
let published_at = DateTime::from_utc(timestamp, Utc);
|
||||
// There is no updated at timestamp available, really.
|
||||
let updated_at = published_at;
|
||||
|
||||
Item {
|
||||
title: video.title().to_string(),
|
||||
|
@ -236,6 +238,7 @@ impl From<YouTubeVideoWithStream> for Item {
|
|||
guid: id,
|
||||
keywords,
|
||||
image,
|
||||
published_at,
|
||||
updated_at,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ fn construct_item(
|
|||
.categories(categories)
|
||||
.enclosure(Some(enclosure))
|
||||
.guid(Some(guid))
|
||||
.pub_date(Some(item.updated_at.to_rfc2822()))
|
||||
.pub_date(Some(item.published_at.to_rfc2822()))
|
||||
.itunes_ext(Some(itunes_ext))
|
||||
.build()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue