owl-blogs/webmention.go

44 lines
1.0 KiB
Go
Raw Normal View History

2022-08-27 21:01:14 +00:00
package owl
import (
2022-09-01 19:53:06 +00:00
"time"
2022-08-27 21:01:14 +00:00
)
2022-09-04 13:03:16 +00:00
type WebmentionIn struct {
2022-09-01 19:53:06 +00:00
Source string `yaml:"source"`
Title string `yaml:"title"`
ApprovalStatus string `yaml:"approval_status"`
RetrievedAt time.Time `yaml:"retrieved_at"`
2022-09-01 19:34:33 +00:00
}
2022-09-10 12:04:13 +00:00
func (webmention *WebmentionIn) UpdateWith(update WebmentionIn) {
if update.Title != "" {
webmention.Title = update.Title
}
if update.ApprovalStatus != "" {
webmention.ApprovalStatus = update.ApprovalStatus
}
if !update.RetrievedAt.IsZero() {
webmention.RetrievedAt = update.RetrievedAt
}
}
2022-09-04 13:03:16 +00:00
type WebmentionOut struct {
Target string `yaml:"target"`
Supported bool `yaml:"supported"`
ScannedAt time.Time `yaml:"scanned_at"`
LastSentAt time.Time `yaml:"last_sent_at"`
}
2022-09-10 12:04:13 +00:00
func (webmention *WebmentionOut) UpdateWith(update WebmentionOut) {
if update.Supported {
webmention.Supported = update.Supported
}
if !update.ScannedAt.IsZero() {
webmention.ScannedAt = update.ScannedAt
}
if !update.LastSentAt.IsZero() {
webmention.LastSentAt = update.LastSentAt
}
}