W3C: Set the feed Image title to the same as the Channel title

This commit is contained in:
pnwmatt 2025-02-26 19:04:55 -08:00
commit 9663b319dd
No known key found for this signature in database

View file

@ -84,15 +84,20 @@ func (p *Processor) GetRSSFeedForUsername(ctx context.Context, username string)
// Assemble author namestring once only. // Assemble author namestring once only.
author := "@" + account.Username + "@" + config.GetAccountDomain() author := "@" + account.Username + "@" + config.GetAccountDomain()
// We set this here and pass it to rssImageForAccount() because the W3C
// validator complains that the image title should have the same value
// as the channel title.
channelTitle := "Posts from " + author
// Derive image/thumbnail for this account (may be nil). // Derive image/thumbnail for this account (may be nil).
image, errWithCode := p.rssImageForAccount(ctx, account, author) image, errWithCode := p.rssImageForAccount(ctx, account, channelTitle)
if errWithCode != nil { if errWithCode != nil {
return "", errWithCode return "", errWithCode
} }
feed := &feeds.Feed{ feed := &feeds.Feed{
Title: "Posts from " + author, Title: channelTitle,
Description: "Posts from " + author, Description: channelTitle,
Link: &feeds.Link{Href: account.URL}, Link: &feeds.Link{Href: account.URL},
Image: image, Image: image,
} }
@ -137,7 +142,7 @@ func (p *Processor) GetRSSFeedForUsername(ctx context.Context, username string)
}, lastPostAt, nil }, lastPostAt, nil
} }
func (p *Processor) rssImageForAccount(ctx context.Context, account *gtsmodel.Account, author string) (*feeds.Image, gtserror.WithCode) { func (p *Processor) rssImageForAccount(ctx context.Context, account *gtsmodel.Account, channelTitle string) (*feeds.Image, gtserror.WithCode) {
if account.AvatarMediaAttachmentID == "" { if account.AvatarMediaAttachmentID == "" {
// No image, no problem! // No image, no problem!
return nil, nil return nil, nil
@ -159,9 +164,11 @@ func (p *Processor) rssImageForAccount(ctx context.Context, account *gtsmodel.Ac
} }
} }
// Note: W3C validator complains that the image title should have the same value
// as the channel title.
return &feeds.Image{ return &feeds.Image{
Url: account.AvatarMediaAttachment.Thumbnail.URL, Url: account.AvatarMediaAttachment.Thumbnail.URL,
Title: "Avatar for " + author, Title: channelTitle,
Link: account.URL, Link: account.URL,
}, nil }, nil
} }