Compare commits

...

2 Commits

Author SHA1 Message Date
Niko Abeler ae29a0221c error for not scanning 2022-09-10 14:23:02 +02:00
Niko Abeler 9559d27bf6 did not scan error 2022-09-10 14:22:06 +02:00
2 changed files with 4 additions and 3 deletions

View File

@ -2,6 +2,7 @@ package owl
import ( import (
"bytes" "bytes"
"errors"
"io/ioutil" "io/ioutil"
"net/url" "net/url"
"os" "os"
@ -308,7 +309,7 @@ func (post *Post) SendWebmention(webmention WebmentionOut) error {
// if last scan is less than 7 days ago, don't send webmention // if last scan is less than 7 days ago, don't send webmention
if webmention.ScannedAt.After(time.Now().Add(-7*24*time.Hour)) && !webmention.Supported { if webmention.ScannedAt.After(time.Now().Add(-7*24*time.Hour)) && !webmention.Supported {
return nil return errors.New("did not scan. Last scan was less than 7 days ago")
} }
webmention.ScannedAt = time.Now() webmention.ScannedAt = time.Now()

View File

@ -392,8 +392,8 @@ func TestSendWebmentionOnlyScansOncePerWeek(t *testing.T) {
webmention = webmentions[0] webmention = webmentions[0]
err := post.SendWebmention(webmention) err := post.SendWebmention(webmention)
if err != nil { if err == nil {
t.Errorf("Error sending webmention: %v", err) t.Errorf("Expected error, got nil")
} }
webmentions = post.OutgoingWebmentions() webmentions = post.OutgoingWebmentions()