From b68d449c021263e521525ceb48c758ff223d5291 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Mon, 26 Dec 2022 13:20:48 -0500 Subject: [PATCH 01/26] delete hex avatars --- activity.go | 3 --- avatar.go | 23 +---------------------- honk.go | 1 - views/account.html | 2 -- web.go | 8 +------- 5 files changed, 2 insertions(+), 35 deletions(-) diff --git a/activity.go b/activity.go index 2e3e536..8f37ca0 100644 --- a/activity.go +++ b/activity.go @@ -1536,9 +1536,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 diff --git a/avatar.go b/avatar.go index 7c7d615..dac92d4 100644 --- a/avatar.go +++ b/avatar.go @@ -65,7 +65,7 @@ func loadAvatarColors() { } } -func genAvatar(name string, hex bool) []byte { +func genAvatar(name string) []byte { h := sha512.New() h.Write([]byte(name)) s := h.Sum(nil) @@ -73,27 +73,6 @@ func genAvatar(name string, hex bool) []byte { for i := 0; i < 64; i++ { for j := 0; j < 64; j++ { p := i*img.Stride + j*4 - if hex { - tan := 0.577 - if i < 32 { - if j < 17-int(float64(i)*tan) || j > 46+int(float64(i)*tan) { - img.Pix[p+0] = 0 - img.Pix[p+1] = 0 - img.Pix[p+2] = 0 - img.Pix[p+3] = 255 - continue - } - } else { - if j < 17-int(float64(64-i)*tan) || j > 46+int(float64(64-i)*tan) { - img.Pix[p+0] = 0 - img.Pix[p+1] = 0 - img.Pix[p+2] = 0 - img.Pix[p+3] = 255 - continue - - } - } - } xx := i/16*16 + j/16 x := s[xx] if x < 64 { diff --git a/honk.go b/honk.go index e000e21..062b767 100644 --- a/honk.go +++ b/honk.go @@ -53,7 +53,6 @@ type WhatAbout struct { type UserOptions struct { SkinnyCSS bool `json:",omitempty"` OmitImages bool `json:",omitempty"` - Avahex bool `json:",omitempty"` MentionAll bool `json:",omitempty"` Avatar string `json:",omitempty"` Banner string `json:",omitempty"` diff --git a/views/account.html b/views/account.html index 523edca..9aa53ce 100644 --- a/views/account.html +++ b/views/account.html @@ -10,8 +10,6 @@

-

-

diff --git a/web.go b/web.go index fee81bf..a3fdbbe 100644 --- a/web.go +++ b/web.go @@ -1111,11 +1111,6 @@ func saveuser(w http.ResponseWriter, r *http.Request) { } else { options.SkinnyCSS = false } - if r.FormValue("avahex") == "avahex" { - options.Avahex = true - } else { - options.Avahex = false - } if r.FormValue("omitimages") == "omitimages" { options.OmitImages = true } else { @@ -2108,8 +2103,7 @@ func avatate(w http.ResponseWriter, r *http.Request) { loadAvatarColors() } n := r.FormValue("a") - hex := r.FormValue("hex") == "1" - a := genAvatar(n, hex) + a := genAvatar(n) if !develMode { w.Header().Set("Cache-Control", "max-age="+somedays()) } From ccbff8b7db44b6eae46f746b31c885f7084e65ba Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Mon, 26 Dec 2022 13:27:39 -0500 Subject: [PATCH 02/26] switch to using user 1 key for gets because elephants are dumb --- activity.go | 8 ++++---- fun.go | 2 +- honk.go | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/activity.go b/activity.go index 8f37ca0..c6396e8 100644 --- a/activity.go +++ b/activity.go @@ -371,7 +371,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 @@ -1474,7 +1474,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 } @@ -1588,7 +1588,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 @@ -1633,7 +1633,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 } diff --git a/fun.go b/fun.go index 2f6fc8e..4f89d6a 100644 --- a/fun.go +++ b/fun.go @@ -643,7 +643,7 @@ var zaggies = cache.New(cache.Options{Filler: func(keyname string) (httpsig.Publ data := getxonker(keyname, "pubkey") if data == "" { dlog.Printf("hitting the webs for missing pubkey: %s", keyname) - j, err := GetJunk(serverUID, keyname) + j, err := GetJunk(readyLuserOne, keyname) if err != nil { ilog.Printf("error getting %s pubkey: %s", keyname, err) when := time.Now().UTC().Format(dbtimeformat) diff --git a/honk.go b/honk.go index 062b767..5807fba 100644 --- a/honk.go +++ b/honk.go @@ -68,6 +68,7 @@ type KeyInfo struct { } const serverUID int64 = -2 +const readyLuserOne int64 = 1 type Honk struct { ID int64 From 5d6f1e984bedc42d3ba43e2793ce6a3b2605cdab Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Wed, 4 Jan 2023 10:32:39 -0500 Subject: [PATCH 03/26] go 1.16 required, noticed by cimm --- docs/honk.8 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/honk.8 b/docs/honk.8 index 1023e18..1b045df 100644 --- a/docs/honk.8 +++ b/docs/honk.8 @@ -41,7 +41,7 @@ proxy_set_header Host $http_host; .Ss Build Building .Nm -requires a go compiler 1.13 and libsqlite. +requires a go compiler 1.16 and libsqlite. On .Ox this is the go and sqlite3 packages. From c6020c0931c8743a574c9c6b751dc213f5053e54 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Wed, 4 Jan 2023 10:34:00 -0500 Subject: [PATCH 04/26] close tag, from coelacanth --- views/honkers.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/honkers.html b/views/honkers.html index 54fcca2..4125044 100644 --- a/views/honkers.html +++ b/views/honkers.html @@ -35,7 +35,7 @@ function expandstuff() {

avatar -

{{ .Name }} +

{{ .Name }}

From 2cca5a2be8c6b962030be97bb30a8b8227970bbb Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Wed, 4 Jan 2023 11:29:40 -0500 Subject: [PATCH 05/26] try to fix up page content for lemmy --- activity.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/activity.go b/activity.go index c6396e8..96ba1cc 100644 --- a/activity.go +++ b/activity.go @@ -541,6 +541,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") @@ -664,6 +665,7 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk { case "Article": fallthrough case "Page": + waspage = true obj = item what = "honk" case "Event": @@ -736,6 +738,10 @@ 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(`

%s`, url, url) + url = xid + } rid, ok = obj.GetString("inReplyTo") if !ok { if robj, ok := obj.GetMap("inReplyTo"); ok { From 682e41fa3aa9db08ec26a26231b1c2ecf639a758 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Wed, 4 Jan 2023 11:33:42 -0500 Subject: [PATCH 06/26] mind the fallthrough... --- activity.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/activity.go b/activity.go index 96ba1cc..fc69b4d 100644 --- a/activity.go +++ b/activity.go @@ -650,6 +650,9 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk { case "Move": obj = item what = "move" + case "Page": + waspage = true + fallthrough case "GuessWord": // dealt with below fallthrough case "Audio": @@ -663,9 +666,6 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk { case "Note": fallthrough case "Article": - fallthrough - case "Page": - waspage = true obj = item what = "honk" case "Event": From 077f37d46cb6fc20790b8fcc07f2d112519a073e Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Wed, 4 Jan 2023 11:51:40 -0500 Subject: [PATCH 07/26] reset userinfo when loading atme to read correct count --- web.go | 1 + 1 file changed, 1 insertion(+) diff --git a/web.go b/web.go index a3fdbbe..2e5e912 100644 --- a/web.go +++ b/web.go @@ -118,6 +118,7 @@ func homepage(w http.ResponseWriter, r *http.Request) { honks = gethonksforme(userid, 0) honks = osmosis(honks, userid, false) menewnone(userid) + templinfo["UserInfo"], _ = butwhatabout(u.Username) case "/longago": templinfo["ServerMessage"] = "long ago and far away!" templinfo["PageName"] = "longago" From c92ad40a10616109efdd9ddccb3358c1aefcefac Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Wed, 4 Jan 2023 13:51:07 -0500 Subject: [PATCH 08/26] encodeURIComponent is how we spell escape in this century from thinegen --- views/honkpage.js | 2 +- views/wonk.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/views/honkpage.js b/views/honkpage.js index 9d2bc66..fcd88a4 100644 --- a/views/honkpage.js +++ b/views/honkpage.js @@ -2,7 +2,7 @@ function encode(hash) { var s = [] for (var key in hash) { var val = hash[key] - s.push(escape(key) + "=" + escape(val)) + s.push(encodeURIComponent(key) + "=" + encodeURIComponent(val)) } return s.join("&") } diff --git a/views/wonk.js b/views/wonk.js index 2a242b2..135dd3b 100644 --- a/views/wonk.js +++ b/views/wonk.js @@ -6,7 +6,7 @@ export function addguesscontrols(elem, word, wordlist, xid) { host.guesses = [] host.xid = xid var xhr = new XMLHttpRequest() - xhr.open("GET", "/bloat/wonkles?w=" + escape(wordlist)) + xhr.open("GET", "/bloat/wonkles?w=" + encodeURIComponent(wordlist)) xhr.responseType = "json" xhr.onload = function() { var wordlist = xhr.response.wordlist From be858a970a9f14ab9d82b77a59100bf2e5a9f0f1 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Mon, 23 Jan 2023 12:52:27 -0500 Subject: [PATCH 09/26] fix http sigs for gets and adjacent mentions --- docs/changelog.txt | 4 ++++ go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index 6ca76dd..1898aa6 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -2,6 +2,10 @@ changelog === next ++ Fix http signatures for GET requests. + ++ Fix adjacent mentions. + + Fix argv for chpass. + Avoid self mention in reply all. diff --git a/go.mod b/go.mod index d866adc..0a68829 100644 --- a/go.mod +++ b/go.mod @@ -9,5 +9,5 @@ require ( golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 humungus.tedunangst.com/r/go-sqlite3 v1.1.3 - humungus.tedunangst.com/r/webs v0.6.59 + humungus.tedunangst.com/r/webs v0.6.60 ) diff --git a/go.sum b/go.sum index 1d7a565..20e6043 100644 --- a/go.sum +++ b/go.sum @@ -25,5 +25,5 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= humungus.tedunangst.com/r/go-sqlite3 v1.1.3 h1:G2N4wzDS0NbuvrZtQJhh4F+3X+s7BF8b9ga8k38geUI= humungus.tedunangst.com/r/go-sqlite3 v1.1.3/go.mod h1:FtEEmQM7U2Ey1TuEEOyY1BmphTZnmiEjPsNLEAkpf/M= -humungus.tedunangst.com/r/webs v0.6.59 h1:zOlBGZqrRo22QND1CN8HbhEv3JwoiZkspi7TgVuJS0s= -humungus.tedunangst.com/r/webs v0.6.59/go.mod h1:03R0N9BcT49HB4TDd1YmarpbiPvPzVDm74Mk4h1hYPc= +humungus.tedunangst.com/r/webs v0.6.60 h1:2PjVTVH3js4PXv8lrEw7nxtRmwwt1COl7t7tZMPxBPs= +humungus.tedunangst.com/r/webs v0.6.60/go.mod h1:03R0N9BcT49HB4TDd1YmarpbiPvPzVDm74Mk4h1hYPc= From 32ed63814772e6edb1616ba941a4e0ab5cb0db64 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Tue, 24 Jan 2023 14:46:55 -0500 Subject: [PATCH 10/26] some basic qt support --- activity.go | 40 +++++++++++++++++++++++++++++++++++++--- docs/changelog.txt | 2 ++ 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/activity.go b/activity.go index fc69b4d..dee32f9 100644 --- a/activity.go +++ b/activity.go @@ -27,6 +27,7 @@ import ( "net/http" "net/url" "os" + "regexp" "strings" "time" @@ -506,6 +507,36 @@ 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:].]+/users/[[:alnum:]]+/statuses/[[: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 { + mlinks := re_qtlinks.FindAllString(content, -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

%s
", content, q) + } + } + } + } + return content +} + func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk { depth := 0 maxdepth := 10 @@ -690,9 +721,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 @@ -742,6 +775,7 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk { content += fmt.Sprintf(`

%s`, url, url) url = xid } + content = qutify(user, content) rid, ok = obj.GetString("inReplyTo") if !ok { if robj, ok := obj.GetMap("inReplyTo"); ok { diff --git a/docs/changelog.txt b/docs/changelog.txt index 1898aa6..be7076b 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -2,6 +2,8 @@ changelog === next ++ Start collecting quties. + + Fix http signatures for GET requests. + Fix adjacent mentions. From ebf1000f1c0f210f2e6789d12ed2484be81ae04e Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Tue, 24 Jan 2023 17:13:49 -0500 Subject: [PATCH 11/26] the mastodon made me do it; i am blameless --- activity.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/activity.go b/activity.go index dee32f9..8cd8772 100644 --- a/activity.go +++ b/activity.go @@ -515,6 +515,8 @@ 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 + content = strings.ReplaceAll(content, ``, "") mlinks := re_qtlinks.FindAllString(content, -1) for _, m := range mlinks { m = m[1 : len(m)-1] From 953957567875e0321be62ffdc26bcf49738155d2 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Tue, 24 Jan 2023 17:19:25 -0500 Subject: [PATCH 12/26] more masto stompage --- activity.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/activity.go b/activity.go index 8cd8772..f02f43c 100644 --- a/activity.go +++ b/activity.go @@ -508,7 +508,7 @@ func firstofmany(obj junk.Junk, key string) string { } var re_mast0link = regexp.MustCompile(`https://[[:alnum:].]+/users/[[:alnum:]]+/statuses/[[:digit:]]+`) -var re_masto1ink = 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:]-]+`) @@ -516,8 +516,9 @@ var re_qtlinks = regexp.MustCompile(`>https://[^\s<]+<`) func qutify(user *WhatAbout, content string) string { // well this is gross - content = strings.ReplaceAll(content, ``, "") - mlinks := re_qtlinks.FindAllString(content, -1) + malcontent := strings.ReplaceAll(content, ``, "") + malcontent = strings.ReplaceAll(malcontent, `

{{ .AboutMsg }}

- +
-
version:{{ .HonkVersion }} -
memory:{{ printf "%.02f" .Sensors.Memory }}MB -
uptime:{{ printf "%.02f" .Sensors.Uptime }}s -
cputime:{{ printf "%.02f" .Sensors.CPU }}s +
version:{{ .HonkVersion }} +
memory:{{ printf "%.02f" .Sensors.Memory }}MB +
uptime:{{ printf "%.02f" .Sensors.Uptime }}s +
cputime:{{ printf "%.02f" .Sensors.CPU }}s

diff --git a/views/chatter.html b/views/chatter.html index 46cd451..c1ce4ee 100644 --- a/views/chatter.html +++ b/views/chatter.html @@ -1,4 +1,5 @@ {{ template "header.html" . }} +

@@ -10,14 +11,8 @@


- + -

{{ $chonkcsrf := .ChonkCSRF }} {{ range .Chatter }} @@ -59,7 +54,7 @@ chatter: {{ .Target }}


- +

{{ end }} diff --git a/views/combos.html b/views/combos.html index 2d6650c..5a4362b 100644 --- a/views/combos.html +++ b/views/combos.html @@ -6,7 +6,7 @@ {{ range .Combos }}
-

{{ . }} +

{{ . }}

{{ end }} diff --git a/views/header.html b/views/header.html index 305e40c..8792e36 100644 --- a/views/header.html +++ b/views/header.html @@ -6,14 +6,11 @@ {{ if .LocalStyleParam }} {{ end }} - - +
{{ if .UserInfo }}
@@ -22,7 +19,7 @@
  • home
  • @me{{ if .UserInfo.Options.MeCount }}({{ .UserInfo.Options.MeCount }}){{ end }}
  • first -
  • +
  • combos
      @@ -39,7 +36,7 @@
    • honkers
    • filters
    • account -
    • +
    • more stuff
        @@ -59,7 +56,7 @@

      -

      top +

      top

      {{ else }}
      diff --git a/views/honk.html b/views/honk.html index 6fa0040..fdc6168 100644 --- a/views/honk.html +++ b/views/honk.html @@ -1,4 +1,4 @@ -
      +
      {{ $bonkcsrf := .BonkCSRF }} {{ $IsPreview := .IsPreview }} {{ $maplink := .MapLink }} @@ -30,7 +30,7 @@ {{ .What }} {{ .Date.Local.Format "02 Jan 2006 15:04 -0700" }} {{ if .Oonker }}
      - + {{ if $bonkcsrf }} original: {{ .Oondle }} {{ else }} @@ -40,14 +40,14 @@ original: {{ .Oondle }} {{ else }} {{ if .RID }}
      - + in reply to: {{ .RID }} {{ end }} {{ end }}
      {{ if $bonkcsrf }} -convoy: {{ .Convoy }} +convoy: {{ .Convoy }} {{ end }}
  • @@ -95,7 +95,7 @@ in reply to: {{ .RID }} {{ .Honk.Guesses }}

    {{ .Honk.Noise }} {{ else }} - + {{ end }} {{ end }} {{ if and $bonkcsrf (not $IsPreview) }} @@ -106,41 +106,41 @@ in reply to: {{ .RID }}

    {{ if .Honk.Public }} {{ if .Honk.IsBonked }} - + {{ else }} - + {{ end }} {{ else }} {{ end }} - - - + + + -