|
|
|
@ -27,6 +27,7 @@ import (
|
|
|
|
|
"net/http"
|
|
|
|
|
"net/url"
|
|
|
|
|
"os"
|
|
|
|
|
"regexp"
|
|
|
|
|
"strings"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
@ -371,7 +372,7 @@ var boxofboxes = cache.New(cache.Options{Filler: func(ident string) (*Box, bool)
|
|
|
|
|
if err != nil {
|
|
|
|
|
dlog.Printf("need to get boxes for %s", ident)
|
|
|
|
|
var j junk.Junk
|
|
|
|
|
j, err = GetJunk(serverUID, ident)
|
|
|
|
|
j, err = GetJunk(readyLuserOne, ident)
|
|
|
|
|
if err != nil {
|
|
|
|
|
dlog.Printf("error getting boxes: %s", err)
|
|
|
|
|
return nil, false
|
|
|
|
@ -506,6 +507,39 @@ func firstofmany(obj junk.Junk, key string) string {
|
|
|
|
|
return ""
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var re_mast0link = regexp.MustCompile(`https://[[:alnum:].]+/users/[[:alnum:]]+/statuses/[[:digit:]]+`)
|
|
|
|
|
var re_masto1ink = regexp.MustCompile(`https://[[:alnum:].]+/@[[:alnum:]]+/[[:digit:]]+`)
|
|
|
|
|
var re_misslink = regexp.MustCompile(`https://[[:alnum:].]+/notes/[[:alnum:]]+`)
|
|
|
|
|
var re_honklink = regexp.MustCompile(`https://[[:alnum:].]+/u/[[:alnum:]]+/h/[[:alnum:]]+`)
|
|
|
|
|
var re_romalink = regexp.MustCompile(`https://[[:alnum:].]+/objects/[[:alnum:]-]+`)
|
|
|
|
|
var re_qtlinks = regexp.MustCompile(`>https://[^\s<]+<`)
|
|
|
|
|
|
|
|
|
|
func qutify(user *WhatAbout, content string) string {
|
|
|
|
|
// well this is gross
|
|
|
|
|
malcontent := strings.ReplaceAll(content, `</span><span class="ellipsis">`, "")
|
|
|
|
|
malcontent = strings.ReplaceAll(malcontent, `</span><span class="invisible">`, "")
|
|
|
|
|
mlinks := re_qtlinks.FindAllString(malcontent, -1)
|
|
|
|
|
for _, m := range mlinks {
|
|
|
|
|
m = m[1 : len(m)-1]
|
|
|
|
|
dlog.Printf("consider qt: %s", m)
|
|
|
|
|
if re_mast0link.MatchString(m) ||
|
|
|
|
|
re_masto1ink.MatchString(m) ||
|
|
|
|
|
re_misslink.MatchString(m) ||
|
|
|
|
|
re_honklink.MatchString(m) ||
|
|
|
|
|
re_romalink.MatchString(m) {
|
|
|
|
|
j, err := GetJunk(user.ID, m)
|
|
|
|
|
dlog.Printf("fetched %s: %s", m, err)
|
|
|
|
|
if err == nil {
|
|
|
|
|
q, ok := j.GetString("content")
|
|
|
|
|
if ok {
|
|
|
|
|
content = fmt.Sprintf("%s<blockquote>%s</blockquote>", content, q)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return content
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
|
|
|
|
|
depth := 0
|
|
|
|
|
maxdepth := 10
|
|
|
|
@ -541,6 +575,7 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
|
|
|
|
|
var xid, rid, url, convoy string
|
|
|
|
|
var replies []string
|
|
|
|
|
var obj junk.Junk
|
|
|
|
|
waspage := false
|
|
|
|
|
switch what {
|
|
|
|
|
case "Delete":
|
|
|
|
|
obj, ok = item.GetMap("object")
|
|
|
|
@ -649,7 +684,8 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
|
|
|
|
|
case "Move":
|
|
|
|
|
obj = item
|
|
|
|
|
what = "move"
|
|
|
|
|
case "GuessWord": // dealt with below
|
|
|
|
|
case "Page":
|
|
|
|
|
waspage = true
|
|
|
|
|
fallthrough
|
|
|
|
|
case "Audio":
|
|
|
|
|
fallthrough
|
|
|
|
@ -662,8 +698,6 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
|
|
|
|
|
case "Note":
|
|
|
|
|
fallthrough
|
|
|
|
|
case "Article":
|
|
|
|
|
fallthrough
|
|
|
|
|
case "Page":
|
|
|
|
|
obj = item
|
|
|
|
|
what = "honk"
|
|
|
|
|
case "Event":
|
|
|
|
@ -688,9 +722,11 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
if originate(xid) != origin {
|
|
|
|
|
ilog.Printf("original sin: %s not from %s", xid, origin)
|
|
|
|
|
item.Write(ilog.Writer())
|
|
|
|
|
return nil
|
|
|
|
|
if !develMode && origin != "" {
|
|
|
|
|
ilog.Printf("original sin: %s not from %s", xid, origin)
|
|
|
|
|
item.Write(ilog.Writer())
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var xonk Honk
|
|
|
|
@ -736,6 +772,13 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
|
|
|
|
|
if sens, _ := obj["sensitive"].(bool); sens && precis == "" {
|
|
|
|
|
precis = "unspecified horror"
|
|
|
|
|
}
|
|
|
|
|
if waspage {
|
|
|
|
|
content += fmt.Sprintf(`<p><a href="%s">%s</a>`, url, url)
|
|
|
|
|
url = xid
|
|
|
|
|
}
|
|
|
|
|
if user.Options.InlineQuotes {
|
|
|
|
|
content = qutify(user, content)
|
|
|
|
|
}
|
|
|
|
|
rid, ok = obj.GetString("inReplyTo")
|
|
|
|
|
if !ok {
|
|
|
|
|
if robj, ok := obj.GetMap("inReplyTo"); ok {
|
|
|
|
@ -775,12 +818,6 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
|
|
|
|
|
targ, _ := obj.GetString("target")
|
|
|
|
|
content += string(templates.Sprintf(`<p>Moved to <a href="%s">%s</a>`, targ, targ))
|
|
|
|
|
}
|
|
|
|
|
if ot == "GuessWord" {
|
|
|
|
|
what = "wonk"
|
|
|
|
|
content, _ = obj.GetString("content")
|
|
|
|
|
xonk.Wonkles, _ = obj.GetString("wordlist")
|
|
|
|
|
go savewonkles(xonk.Wonkles)
|
|
|
|
|
}
|
|
|
|
|
if what == "honk" && rid != "" {
|
|
|
|
|
what = "tonk"
|
|
|
|
|
}
|
|
|
|
@ -1136,8 +1173,6 @@ func jonkjonk(user *WhatAbout, h *Honk) (junk.Junk, junk.Junk) {
|
|
|
|
|
fallthrough
|
|
|
|
|
case "event":
|
|
|
|
|
fallthrough
|
|
|
|
|
case "wonk":
|
|
|
|
|
fallthrough
|
|
|
|
|
case "honk":
|
|
|
|
|
j["type"] = "Create"
|
|
|
|
|
jo = junk.New()
|
|
|
|
@ -1145,8 +1180,6 @@ func jonkjonk(user *WhatAbout, h *Honk) (junk.Junk, junk.Junk) {
|
|
|
|
|
jo["type"] = "Note"
|
|
|
|
|
if h.What == "event" {
|
|
|
|
|
jo["type"] = "Event"
|
|
|
|
|
} else if h.What == "wonk" {
|
|
|
|
|
jo["type"] = "GuessWord"
|
|
|
|
|
}
|
|
|
|
|
if h.What == "update" {
|
|
|
|
|
j["type"] = "Update"
|
|
|
|
@ -1253,9 +1286,6 @@ func jonkjonk(user *WhatAbout, h *Honk) (junk.Junk, junk.Junk) {
|
|
|
|
|
jo["duration"] = "PT" + strings.ToUpper(t.Duration.String())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if w := h.Wonkles; w != "" {
|
|
|
|
|
jo["wordlist"] = w
|
|
|
|
|
}
|
|
|
|
|
atts := activatedonks(h.Donks)
|
|
|
|
|
if len(atts) > 0 {
|
|
|
|
|
jo["attachment"] = atts
|
|
|
|
@ -1474,7 +1504,7 @@ func doesitmatter(what string) bool {
|
|
|
|
|
func collectiveaction(honk *Honk) {
|
|
|
|
|
user := getserveruser()
|
|
|
|
|
for _, ont := range honk.Onts {
|
|
|
|
|
dubs := getnameddubs(serverUID, ont)
|
|
|
|
|
dubs := getnameddubs(readyLuserOne, ont)
|
|
|
|
|
if len(dubs) == 0 {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
@ -1536,9 +1566,6 @@ func junkuser(user *WhatAbout) junk.Junk {
|
|
|
|
|
a["url"] = ava
|
|
|
|
|
} else {
|
|
|
|
|
u := fmt.Sprintf("https://%s/a?a=%s", serverName, url.QueryEscape(user.URL))
|
|
|
|
|
if user.Options.Avahex {
|
|
|
|
|
u += "&hex=1"
|
|
|
|
|
}
|
|
|
|
|
a["url"] = u
|
|
|
|
|
}
|
|
|
|
|
j["icon"] = a
|
|
|
|
@ -1591,7 +1618,7 @@ var handfull = cache.New(cache.Options{Filler: func(name string) (string, bool)
|
|
|
|
|
return href, true
|
|
|
|
|
}
|
|
|
|
|
dlog.Printf("fishing for %s", name)
|
|
|
|
|
j, err := GetJunkFast(serverUID, fmt.Sprintf("https://%s/.well-known/webfinger?resource=acct:%s", m[1], name))
|
|
|
|
|
j, err := GetJunkFast(readyLuserOne, fmt.Sprintf("https://%s/.well-known/webfinger?resource=acct:%s", m[1], name))
|
|
|
|
|
if err != nil {
|
|
|
|
|
ilog.Printf("failed to go fish %s: %s", name, err)
|
|
|
|
|
return "", true
|
|
|
|
@ -1636,7 +1663,7 @@ func investigate(name string) (*SomeThing, error) {
|
|
|
|
|
if name == "" {
|
|
|
|
|
return nil, fmt.Errorf("no name")
|
|
|
|
|
}
|
|
|
|
|
obj, err := GetJunkFast(serverUID, name)
|
|
|
|
|
obj, err := GetJunkFast(readyLuserOne, name)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
@ -1901,7 +1928,7 @@ func followyou2(user *WhatAbout, j junk.Junk) {
|
|
|
|
|
|
|
|
|
|
ilog.Printf("updating honker accept: %s", who)
|
|
|
|
|
db := opendatabase()
|
|
|
|
|
row := db.QueryRow("select name, folxid from honkers where userid = ? and xid = ? and flavor in ('presub')",
|
|
|
|
|
row := db.QueryRow("select name, folxid from honkers where userid = ? and xid = ? and flavor in ('presub', 'sub')",
|
|
|
|
|
user.ID, who)
|
|
|
|
|
var name, folxid string
|
|
|
|
|
err := row.Scan(&name, &folxid)
|
|
|
|
|