Act as if there is an author in the feed when only checking the entry
This commit is contained in:
parent
2ef8d8c9df
commit
6b9d5be734
6
entry.go
6
entry.go
@ -34,14 +34,16 @@ 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 !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 {
|
||||
if err := a.Check(); err != nil {
|
||||
@ -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)
|
||||
}
|
||||
|
||||
|
2
feed.go
2
feed.go
@ -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)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user