Act as if there is an author in the feed when only checking the entry

This commit is contained in:
Jason Streifling 2024-10-17 05:05:14 +02:00
parent 2ef8d8c9df
commit 6b9d5be734
2 changed files with 10 additions and 8 deletions

View File

@ -34,13 +34,15 @@ type Entry struct {
// the atom:entry contains an atom:source element that contains an atom:author
// element or, in an Atom Feed Document, the atom:feed element contains an
// atom:author element itself.
func (e *Entry) checkAuthors() error {
func (e *Entry) checkAuthors(authorInFeed bool) error {
if e.Authors == nil {
if e.Source == nil {
return errors.New("no authors set in entry")
}
if e.Source.Authors == nil {
return errors.New("no authors set in entry")
if !authorInFeed {
if e.Source == nil {
return errors.New("no authors set in entry")
}
if e.Source.Authors == nil {
return errors.New("no authors set in entry")
}
}
} else {
for i, a := range e.Authors {
@ -138,7 +140,7 @@ func (e *Entry) Check() error {
}
}
if err := e.checkAuthors(); err != nil {
if err := e.checkAuthors(true); err != nil {
return fmt.Errorf("entry %v: %v", e.ID.URI, err)
}

View File

@ -128,7 +128,7 @@ func (f *Feed) Check() error {
// least one atom:author element.
if f.Authors == nil {
for _, e := range f.Entries {
if err := e.checkAuthors(); err != nil {
if err := e.checkAuthors(false); err != nil {
return fmt.Errorf("no authors set in feed %v: %v", f.ID.URI, err)
}
}