save mentions in honkmeta
This commit is contained in:
parent
a144795b13
commit
0b89e1b06c
14
activity.go
14
activity.go
|
@ -635,7 +635,7 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
|
|||
xonk.Audience = append(xonk.Audience, xonk.Honker)
|
||||
xonk.Audience = oneofakind(xonk.Audience)
|
||||
|
||||
var mentions []string
|
||||
var mentions []Mention
|
||||
if obj != nil {
|
||||
ot, _ := obj.GetString("type")
|
||||
url, _ = obj.GetString("url")
|
||||
|
@ -773,7 +773,9 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
|
|||
xonk.Place = p
|
||||
}
|
||||
if tt == "Mention" {
|
||||
m, _ := tag.GetString("href")
|
||||
var m Mention
|
||||
m.Who, _ = tag.GetString("name")
|
||||
m.Where, _ = tag.GetString("href")
|
||||
mentions = append(mentions, m)
|
||||
}
|
||||
}
|
||||
|
@ -852,8 +854,9 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
|
|||
xonk.Precis = precis
|
||||
xonk.Format = "html"
|
||||
xonk.Convoy = convoy
|
||||
xonk.Mentions = mentions
|
||||
for _, m := range mentions {
|
||||
if m == user.URL {
|
||||
if m.Where == user.URL {
|
||||
xonk.Whofore = 1
|
||||
}
|
||||
}
|
||||
|
@ -873,6 +876,7 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
|
|||
prev.Onts = xonk.Onts
|
||||
prev.Place = xonk.Place
|
||||
prev.Whofore = xonk.Whofore
|
||||
prev.Mentions = xonk.Mentions
|
||||
updatehonk(prev)
|
||||
}
|
||||
}
|
||||
|
@ -1050,8 +1054,8 @@ func jonkjonk(user *WhatAbout, h *Honk) (junk.Junk, junk.Junk) {
|
|||
for _, m := range mentions {
|
||||
t := junk.New()
|
||||
t["type"] = "Mention"
|
||||
t["name"] = m.who
|
||||
t["href"] = m.where
|
||||
t["name"] = m.Who
|
||||
t["href"] = m.Where
|
||||
tags = append(tags, t)
|
||||
}
|
||||
for _, o := range h.Onts {
|
||||
|
|
16
database.go
16
database.go
|
@ -413,6 +413,12 @@ func donksforhonks(honks []*Honk) {
|
|||
continue
|
||||
}
|
||||
h.Time = t
|
||||
case "mentions":
|
||||
err = unjsonify(j, &h.Mentions)
|
||||
if err != nil {
|
||||
log.Printf("error parsing mentions: %s", err)
|
||||
continue
|
||||
}
|
||||
case "oldrev":
|
||||
default:
|
||||
log.Printf("unknown meta genus: %s", genus)
|
||||
|
@ -577,6 +583,16 @@ func saveextras(tx *sql.Tx, h *Honk) error {
|
|||
return err
|
||||
}
|
||||
}
|
||||
if m := h.Mentions; len(m) > 0 {
|
||||
j, err := jsonify(m)
|
||||
if err == nil {
|
||||
_, err = tx.Stmt(stmtSaveMeta).Exec(h.ID, "mentions", j)
|
||||
}
|
||||
if err != nil {
|
||||
log.Printf("error saving mentions: %s", err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
9
fun.go
9
fun.go
|
@ -277,11 +277,6 @@ func ontologies(s string) []string {
|
|||
return m[:j]
|
||||
}
|
||||
|
||||
type Mention struct {
|
||||
who string
|
||||
where string
|
||||
}
|
||||
|
||||
var re_mentions = regexp.MustCompile(`@[[:alnum:]._-]+@[[:alnum:].-]*[[:alnum:]]`)
|
||||
var re_urltions = regexp.MustCompile(`@https://\S+`)
|
||||
|
||||
|
@ -307,12 +302,12 @@ func bunchofgrapes(s string) []Mention {
|
|||
for i := range m {
|
||||
where := gofish(m[i])
|
||||
if where != "" {
|
||||
mentions = append(mentions, Mention{who: m[i], where: where})
|
||||
mentions = append(mentions, Mention{Who: m[i], Where: where})
|
||||
}
|
||||
}
|
||||
m = re_urltions.FindAllString(s, -1)
|
||||
for i := range m {
|
||||
mentions = append(mentions, Mention{who: m[i][1:], where: m[i][1:]})
|
||||
mentions = append(mentions, Mention{Who: m[i][1:], Where: m[i][1:]})
|
||||
}
|
||||
return mentions
|
||||
}
|
||||
|
|
6
honk.go
6
honk.go
|
@ -88,6 +88,12 @@ type Honk struct {
|
|||
Onts []string
|
||||
Place *Place
|
||||
Time *Time
|
||||
Mentions []Mention
|
||||
}
|
||||
|
||||
type Mention struct {
|
||||
Who string
|
||||
Where string
|
||||
}
|
||||
|
||||
type OldRevision struct {
|
||||
|
|
1
web.go
1
web.go
|
@ -1435,6 +1435,7 @@ func submithonk(w http.ResponseWriter, r *http.Request, isAPI bool) {
|
|||
noise = strings.Replace(noise, "\r", "", -1)
|
||||
noise = quickrename(noise, userinfo.UserID)
|
||||
noise = hooterize(noise)
|
||||
honk.Mentions = bunchofgrapes(noise)
|
||||
honk.Noise = noise
|
||||
translate(honk, false)
|
||||
|
||||
|
|
Loading…
Reference in New Issue