From ed357653a85ceae3fa146fc8fc0e3fc57aa7f24f Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Mon, 13 May 2019 13:02:12 -0400 Subject: [PATCH] some minor cleanup --- activity.go | 3 +- fun.go | 7 ---- honk.go | 98 ++++++++++++++++++++++++++--------------------------- 3 files changed, 50 insertions(+), 58 deletions(-) diff --git a/activity.go b/activity.go index 910c6f0..cb61263 100644 --- a/activity.go +++ b/activity.go @@ -894,7 +894,7 @@ func gofish(name string) string { 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 @@ func gofish(name string) string { handlock.Unlock() return "" } - diff --git a/fun.go b/fun.go index 063ee7a..e2097dd 100644 --- a/fun.go +++ b/fun.go @@ -50,13 +50,6 @@ func reverbolate(honks []*Honk) { 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) diff --git a/honk.go b/honk.go index e449a3e..d208f77 100644 --- a/honk.go +++ b/honk.go @@ -453,55 +453,6 @@ func showconvoy(w http.ResponseWriter, r *http.Request) { 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"] @@ -1131,6 +1082,55 @@ func killitwithfire(w http.ResponseWriter, r *http.Request) { 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 { secs := 432000 + notrand.Int63n(432000) return fmt.Sprintf("%d", secs)