diff --git a/http.go b/http.go
index f42c1ab..0c2ac78 100644
--- a/http.go
+++ b/http.go
@@ -205,6 +205,7 @@ func buildStaticHandlersRouters() error {
r.Get(paginationPath, webmentionAdmin)
r.Post("/delete", webmentionAdminDelete)
r.Post("/approve", webmentionAdminApprove)
+ r.Post("/reverify", webmentionAdminReverify)
})
}
diff --git a/templates/strings/default.yaml b/templates/strings/default.yaml
index ba49371..0575c2d 100644
--- a/templates/strings/default.yaml
+++ b/templates/strings/default.yaml
@@ -34,6 +34,7 @@ posts: "Posts"
prev: "Previous"
publishedon: "Published on"
replyto: "Reply to"
+reverify: "Reverify"
scopes: "Scopes"
search: "Search"
send: "Send (to review)"
diff --git a/templates/webmentionadmin.gohtml b/templates/webmentionadmin.gohtml
index 41ee900..4a5e5ec 100644
--- a/templates/webmentionadmin.gohtml
+++ b/templates/webmentionadmin.gohtml
@@ -19,6 +19,7 @@
{{ end }}
+
{{ end }}
diff --git a/webmention.go b/webmention.go
index a9090a7..d471f49 100644
--- a/webmention.go
+++ b/webmention.go
@@ -112,9 +112,24 @@ func approveWebmention(id int) error {
return err
}
+func reverifyWebmention(id int) error {
+ m, err := getWebmentions(&webmentionsRequestConfig{
+ id: id,
+ limit: 1,
+ })
+ if err != nil {
+ return err
+ }
+ if len(m) > 0 {
+ queueMention(m[0])
+ }
+ return nil
+}
+
type webmentionsRequestConfig struct {
target string
status webmentionStatus
+ id int
asc bool
offset, limit int
}
@@ -132,6 +147,9 @@ func buildWebmentionsQuery(config *webmentionsRequestConfig) (query string, args
} else if config.status != "" {
filter = "where status = @status"
args = append(args, sql.Named("status", config.status))
+ } else if config.id != 0 {
+ filter = "where id = @id"
+ args = append(args, sql.Named("id", config.id))
}
}
order := "desc"
diff --git a/webmentionAdmin.go b/webmentionAdmin.go
index b8d734f..6302e38 100644
--- a/webmentionAdmin.go
+++ b/webmentionAdmin.go
@@ -124,3 +124,17 @@ func webmentionAdminApprove(w http.ResponseWriter, r *http.Request) {
purgeCache()
http.Redirect(w, r, ".", http.StatusFound)
}
+
+func webmentionAdminReverify(w http.ResponseWriter, r *http.Request) {
+ id, err := strconv.Atoi(r.FormValue("mentionid"))
+ if err != nil {
+ serveError(w, r, err.Error(), http.StatusBadRequest)
+ return
+ }
+ err = reverifyWebmention(id)
+ if err != nil {
+ serveError(w, r, err.Error(), http.StatusInternalServerError)
+ return
+ }
+ http.Redirect(w, r, ".", http.StatusFound)
+}
diff --git a/webmentionVerification.go b/webmentionVerification.go
index 5ef9eac..e834abe 100644
--- a/webmentionVerification.go
+++ b/webmentionVerification.go
@@ -155,29 +155,42 @@ func (m *mention) fillFromData(mf *microformats.Data) {
func (m *mention) fill(mf *microformats.Microformat) bool {
if mfHasType(mf, "h-entry") {
- if name, ok := mf.Properties["name"]; ok && len(name) > 0 {
- if title, ok := name[0].(string); ok {
- m.Title = title
- }
- }
- if contents, ok := mf.Properties["content"]; ok && len(contents) > 0 {
- if content, ok := contents[0].(map[string]string); ok {
- if contentValue, ok := content["value"]; ok {
- m.Content = contentValue
+ // Check URL
+ if url, ok := mf.Properties["url"]; ok && len(url) > 0 {
+ if url0, ok := url[0].(string); ok {
+ if url0 != m.Source {
+ // Not correct URL
+ return false
}
}
}
+ // Title
+ if name, ok := mf.Properties["name"]; ok && len(name) > 0 {
+ if title, ok := name[0].(string); ok {
+ m.Title = strings.TrimSpace(title)
+ }
+ }
+ // Content
+ if contents, ok := mf.Properties["content"]; ok && len(contents) > 0 {
+ if content, ok := contents[0].(map[string]string); ok {
+ if contentValue, ok := content["value"]; ok {
+ m.Content = strings.TrimSpace(contentValue)
+ }
+ }
+ }
+ // Author
if authors, ok := mf.Properties["author"]; ok && len(authors) > 0 {
if author, ok := authors[0].(*microformats.Microformat); ok {
if names, ok := author.Properties["name"]; ok && len(names) > 0 {
if name, ok := names[0].(string); ok {
- m.Author = name
+ m.Author = strings.TrimSpace(name)
}
}
}
}
return true
- } else if len(mf.Children) > 0 {
+ }
+ if len(mf.Children) > 0 {
for _, mfc := range mf.Children {
if m.fill(mfc) {
return true