some minor cleanup

master
Ted Unangst 5 years ago
parent eed4d3b421
commit ed357653a8

@ -894,7 +894,7 @@ func gofish(name string) string {
t, _ := jsongetstring(l, "type") t, _ := jsongetstring(l, "type")
if rel == "self" && friendorfoe(t) { if rel == "self" && friendorfoe(t) {
db.Exec("insert into xonkers (xid, ibox, obox, sbox, pubkey) values (?, ?, ?, ?, ?)", db.Exec("insert into xonkers (xid, ibox, obox, sbox, pubkey) values (?, ?, ?, ?, ?)",
name, href, "", "", "") name, href, "", "", "")
handlock.Lock() handlock.Lock()
handfull[name] = href handfull[name] = href
handlock.Unlock() handlock.Unlock()
@ -906,4 +906,3 @@ func gofish(name string) string {
handlock.Unlock() handlock.Unlock()
return "" return ""
} }

@ -50,13 +50,6 @@ func reverbolate(honks []*Honk) {
h.URL = h.XID h.URL = h.XID
} }
} }
h.Privacy = "limited"
for _, a := range h.Audience {
if a == thewholeworld {
h.Privacy = ""
break
}
}
zap := make(map[*Donk]bool) zap := make(map[*Donk]bool)
h.Noise = unpucker(h.Noise) h.Noise = unpucker(h.Noise)
h.HTML = cleanstring(h.Noise) h.HTML = cleanstring(h.Noise)

@ -453,55 +453,6 @@ func showconvoy(w http.ResponseWriter, r *http.Request) {
honkpage(w, r, u, nil, honks, "honks in convoy: "+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) { func showhonk(w http.ResponseWriter, r *http.Request) {
name := mux.Vars(r)["name"] name := mux.Vars(r)["name"]
xid := mux.Vars(r)["xid"] xid := mux.Vars(r)["xid"]
@ -1131,6 +1082,55 @@ func killitwithfire(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/killzone", http.StatusSeeOther) 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 { func somedays() string {
secs := 432000 + notrand.Int63n(432000) secs := 432000 + notrand.Int63n(432000)
return fmt.Sprintf("%d", secs) return fmt.Sprintf("%d", secs)

Loading…
Cancel
Save