Fixed created time nil

This commit is contained in:
Marcus Noble 2021-02-21 09:09:25 +00:00
parent 68e9418c12
commit 122bfd666a

View File

@ -59,6 +59,11 @@ func RefreshFeed(url string) Feed {
imageURL = f.Image.URL imageURL = f.Image.URL
} }
createdTime := item.PublishedParsed
if createdTime == nil {
createdTime = item.UpdatedParsed
}
feed.Items = append(feed.Items, Item{ feed.Items = append(feed.Items, Item{
ID: strings.ReplaceAll(base64.StdEncoding.EncodeToString([]byte(item.GUID)), "/", ""), ID: strings.ReplaceAll(base64.StdEncoding.EncodeToString([]byte(item.GUID)), "/", ""),
Title: item.Title, Title: item.Title,
@ -67,7 +72,7 @@ func RefreshFeed(url string) Feed {
URL: item.Link, URL: item.Link,
ImageURL: imageURL, ImageURL: imageURL,
LastUpdated: item.UpdatedParsed, LastUpdated: item.UpdatedParsed,
Created: item.PublishedParsed, Created: createdTime,
GUID: item.GUID, GUID: item.GUID,
FeedID: feed.ID, FeedID: feed.ID,
}) })