mirror of https://github.com/jlelse/GoBlog
Webmentions: Remove type, fix content parsing
This commit is contained in:
parent
5754543d7a
commit
6dd99289ad
|
@ -32,7 +32,6 @@ type mention struct {
|
||||||
Title string
|
Title string
|
||||||
Content string
|
Content string
|
||||||
Author string
|
Author string
|
||||||
Type string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func initWebmention() {
|
func initWebmention() {
|
||||||
|
@ -174,7 +173,7 @@ func verifyNextWebmention() error {
|
||||||
// Approve if it's server-intern
|
// Approve if it's server-intern
|
||||||
newStatus = webmentionStatusApproved
|
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) {
|
if oldStatus == string(webmentionStatusNew) {
|
||||||
sendNotification(fmt.Sprintf("New webmention from %s to %s", m.Source, m.Target))
|
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 {
|
if config.asc {
|
||||||
order = "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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
m := &mention{}
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,22 +80,10 @@ func mfFillMention(m *mention, mf *microformats.Microformat) bool {
|
||||||
m.Title = title
|
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 contents, ok := mf.Properties["content"]; ok && len(contents) > 0 {
|
||||||
if content, ok := contents[0].(map[string]interface{}); ok {
|
if content, ok := contents[0].(map[string]string); ok {
|
||||||
if rawContentValue, ok := content["value"]; ok {
|
if contentValue, ok := content["value"]; ok {
|
||||||
if contentValue, ok := rawContentValue.(string); ok {
|
m.Content = contentValue
|
||||||
m.Content = contentValue
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue