005a7322d224 — Peter Sanchez a month ago
Integrating patch from @icy to add support for StreetPass browser extension.

https://git.icyphox.sh/honk/commit/5950ef85c8e56db7596f02933be98fe084d59b76
1 files changed, 20 insertions(+), 2 deletions(-)

M web.go
M web.go +20 -2
@@ 33,6 33,7 @@ import (
 	"net/url"
 	"os"
 	"os/signal"
+	"path/filepath"
 	"regexp"
 	"runtime/pprof"
 	"sort"

          
@@ 2269,12 2270,19 @@ func dochpass(w http.ResponseWriter, r *
 var oldfingers = gencache.New(gencache.Options[string, []byte]{Fill: func(orig string) ([]byte, bool) {
 	if strings.HasPrefix(orig, "acct:") {
 		orig = orig[5:]
+	} else {
+		orig, _ = url.QueryUnescape(orig)
 	}
 	name := orig
 	idx := strings.LastIndexByte(name, '/')
 	if idx != -1 {
+		url := serverURL("/%s/%s", userSep, name)
 		name = name[idx+1:]
-		if serverURL("/%s/%s", userSep, name) != orig {
+		if strings.HasPrefix(name, "@") {
+			url = fmt.Sprintf("https://%s/%s", serverName, name)
+			name = name[1:]
+		}
+		if url != orig {
 			ilog.Printf("foreign request rejected")
 			name = ""
 		}

          
@@ 2300,7 2308,17 @@ var oldfingers = gencache.New(gencache.O
 	l["rel"] = "self"
 	l["type"] = `application/activity+json`
 	l["href"] = user.URL
-	j["links"] = []junk.Junk{l}
+
+	l3 := junk.New()
+	l3["rel"] = "http://webfinger.net/rel/avatar"
+	ext := filepath.Ext(user.Options.Avatar)
+	if ext[1:] == "jpg" {
+		l3["type"] = "image/jpeg"
+	} else if ext[1:] == "png" {
+		l3["type"] = "image/png"
+	}
+	l3["href"] = user.Options.Avatar
+	j["links"] = []junk.Junk{l, l3}
 	return j.ToBytes(), true
 }})