all repos — honk @ eb9d60e1996a0cc48e279b735d2e15bf68e194ef

my fork of honk

some minor cleanup
Ted Unangst tedu@tedunangst.com
Mon, 13 May 2019 13:02:12 -0400
commit

eb9d60e1996a0cc48e279b735d2e15bf68e194ef

parent

844cdfc15e932cfd026bff6104411bba73efb5be

3 files changed, 50 insertions(+), 58 deletions(-)

jump to
M activity.goactivity.go

@@ -894,7 +894,7 @@ rel, _ := jsongetstring(l, "rel")

t, _ := jsongetstring(l, "type") if rel == "self" && friendorfoe(t) { db.Exec("insert into xonkers (xid, ibox, obox, sbox, pubkey) values (?, ?, ?, ?, ?)", - name, href, "", "", "") + name, href, "", "", "") handlock.Lock() handfull[name] = href handlock.Unlock()

@@ -906,4 +906,3 @@ handfull[name] = ""

handlock.Unlock() return "" } -
M fun.gofun.go

@@ -50,13 +50,6 @@ if h.URL == "" {

h.URL = h.XID } } - h.Privacy = "limited" - for _, a := range h.Audience { - if a == thewholeworld { - h.Privacy = "" - break - } - } zap := make(map[*Donk]bool) h.Noise = unpucker(h.Noise) h.HTML = cleanstring(h.Noise)
M honk.gohonk.go

@@ -453,55 +453,6 @@ honks := gethonksbyconvoy(userid, c)

honkpage(w, r, u, nil, honks, "honks in convoy: "+c) } -func fingerlicker(w http.ResponseWriter, r *http.Request) { - orig := r.FormValue("resource") - - log.Printf("finger lick: %s", orig) - - if strings.HasPrefix(orig, "acct:") { - orig = orig[5:] - } - - name := orig - idx := strings.LastIndexByte(name, '/') - if idx != -1 { - name = name[idx+1:] - if "https://"+serverName+"/u/"+name != orig { - log.Printf("foreign request rejected") - name = "" - } - } else { - idx = strings.IndexByte(name, '@') - if idx != -1 { - name = name[:idx] - if name+"@"+serverName != orig { - log.Printf("foreign request rejected") - name = "" - } - } - } - user, err := butwhatabout(name) - if err != nil { - http.NotFound(w, r) - return - } - - j := NewJunk() - j["subject"] = fmt.Sprintf("acct:%s@%s", user.Name, serverName) - j["aliases"] = []string{user.URL} - var links []map[string]interface{} - l := NewJunk() - l["rel"] = "self" - l["type"] = `application/activity+json` - l["href"] = user.URL - links = append(links, l) - j["links"] = links - - w.Header().Set("Cache-Control", "max-age=3600") - w.Header().Set("Content-Type", "application/jrd+json") - WriteJunk(w, j) -} - func showhonk(w http.ResponseWriter, r *http.Request) { name := mux.Vars(r)["name"] xid := mux.Vars(r)["xid"]

@@ -1129,6 +1080,55 @@ bitethethumbs()

} http.Redirect(w, r, "/killzone", http.StatusSeeOther) +} + +func fingerlicker(w http.ResponseWriter, r *http.Request) { + orig := r.FormValue("resource") + + log.Printf("finger lick: %s", orig) + + if strings.HasPrefix(orig, "acct:") { + orig = orig[5:] + } + + name := orig + idx := strings.LastIndexByte(name, '/') + if idx != -1 { + name = name[idx+1:] + if "https://"+serverName+"/u/"+name != orig { + log.Printf("foreign request rejected") + name = "" + } + } else { + idx = strings.IndexByte(name, '@') + if idx != -1 { + name = name[:idx] + if name+"@"+serverName != orig { + log.Printf("foreign request rejected") + name = "" + } + } + } + user, err := butwhatabout(name) + if err != nil { + http.NotFound(w, r) + return + } + + j := NewJunk() + j["subject"] = fmt.Sprintf("acct:%s@%s", user.Name, serverName) + j["aliases"] = []string{user.URL} + var links []map[string]interface{} + l := NewJunk() + l["rel"] = "self" + l["type"] = `application/activity+json` + l["href"] = user.URL + links = append(links, l) + j["links"] = links + + w.Header().Set("Cache-Control", "max-age=3600") + w.Header().Set("Content-Type", "application/jrd+json") + WriteJunk(w, j) } func somedays() string {