all repos — honk @ caa15d152605dadcb21036f5d2251b69124ee7cc

my fork of honk

save mentions in honkmeta
Ted Unangst tedu@tedunangst.com
Wed, 27 Nov 2019 14:36:29 -0500
commit

caa15d152605dadcb21036f5d2251b69124ee7cc

parent

49dc0802d5e134c9dd377864879d958b597ea2a5

5 files changed, 34 insertions(+), 12 deletions(-)

jump to
M activity.goactivity.go

@@ -635,7 +635,7 @@ }

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 @@ p.Url, _ = tag.GetString("url")

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 @@ xonk.Noise = content

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 @@ prev.Donks = xonk.Donks

prev.Onts = xonk.Onts prev.Place = xonk.Place prev.Whofore = xonk.Whofore + prev.Mentions = xonk.Mentions updatehonk(prev) } }

@@ -1050,8 +1054,8 @@ var tags []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 {
M database.godatabase.go

@@ -413,6 +413,12 @@ log.Printf("error parsing time: %s", err)

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)

@@ -574,6 +580,16 @@ _, err = tx.Stmt(stmtSaveMeta).Exec(h.ID, "time", j)

} if err != nil { log.Printf("error saving time: %s", err) + 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 } }
M fun.gofun.go

@@ -277,11 +277,6 @@ }

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 @@ var mentions []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 }
M honk.gohonk.go

@@ -88,6 +88,12 @@ Donks []*Donk

Onts []string Place *Place Time *Time + Mentions []Mention +} + +type Mention struct { + Who string + Where string } type OldRevision struct {
M web.goweb.go

@@ -1435,6 +1435,7 @@

noise = strings.Replace(noise, "\r", "", -1) noise = quickrename(noise, userinfo.UserID) noise = hooterize(noise) + honk.Mentions = bunchofgrapes(noise) honk.Noise = noise translate(honk, false)