From 6dd99289ad4e4af76ec33d58893c961c2ee9de15 Mon Sep 17 00:00:00 2001 From: Jan-Lukas Else Date: Mon, 16 Nov 2020 15:46:16 +0100 Subject: [PATCH] Webmentions: Remove type, fix content parsing --- webmentions.go | 7 +++---- webmentionsVerify.go | 18 +++--------------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/webmentions.go b/webmentions.go index 34a2822..03af080 100644 --- a/webmentions.go +++ b/webmentions.go @@ -32,7 +32,6 @@ type mention struct { Title string Content string Author string - Type string } func initWebmention() { @@ -174,7 +173,7 @@ func verifyNextWebmention() error { // Approve if it's server-intern newStatus = webmentionStatusApproved } - _, err = appDbExec("update webmentions set status = ?, title = ?, type = ?, content = ?, author = ? where id = ?", newStatus, m.Title, m.Type, m.Content, m.Author, m.ID) + _, err = appDbExec("update webmentions set status = ?, title = ?, content = ?, author = ? where id = ?", newStatus, m.Title, m.Content, m.Author, m.ID) if oldStatus == string(webmentionStatusNew) { sendNotification(fmt.Sprintf("New webmention from %s to %s", m.Source, m.Target)) } @@ -228,13 +227,13 @@ func getWebmentions(config *webmentionsRequestConfig) ([]*mention, error) { if config.asc { order = "asc" } - rows, err = appDbQuery("select id, source, target, created, title, content, author, type from webmentions "+filter+" order by created "+order, args...) + rows, err = appDbQuery("select id, source, target, created, title, content, author from webmentions "+filter+" order by created "+order, args...) if err != nil { return nil, err } for rows.Next() { m := &mention{} - err = rows.Scan(&m.ID, &m.Source, &m.Target, &m.Created, &m.Title, &m.Content, &m.Author, &m.Type) + err = rows.Scan(&m.ID, &m.Source, &m.Target, &m.Created, &m.Title, &m.Content, &m.Author) if err != nil { return nil, err } diff --git a/webmentionsVerify.go b/webmentionsVerify.go index cd4cfae..70a79d7 100644 --- a/webmentionsVerify.go +++ b/webmentionsVerify.go @@ -80,22 +80,10 @@ func mfFillMention(m *mention, mf *microformats.Microformat) bool { m.Title = title } } - if reply, ok := mf.Properties["in-reply-to"]; ok && len(reply) > 0 { - if replyLink, ok := reply[0].(string); ok && replyLink == m.Target { - m.Type = "comment" - } - } - if like, ok := mf.Properties["like-of"]; ok && len(like) > 0 { - if likeLink, ok := like[0].(string); ok && likeLink == m.Target { - m.Type = "like" - } - } if contents, ok := mf.Properties["content"]; ok && len(contents) > 0 { - if content, ok := contents[0].(map[string]interface{}); ok { - if rawContentValue, ok := content["value"]; ok { - if contentValue, ok := rawContentValue.(string); ok { - m.Content = contentValue - } + if content, ok := contents[0].(map[string]string); ok { + if contentValue, ok := content["value"]; ok { + m.Content = contentValue } } }