some minor cleanup

This commit is contained in:
Ted Unangst 2019-05-13 13:02:12 -04:00
parent eed4d3b421
commit ed357653a8
3 changed files with 50 additions and 58 deletions

View File

@ -906,4 +906,3 @@ func gofish(name string) string {
handlock.Unlock()
return ""
}

7
fun.go
View File

@ -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)

98
honk.go
View File

@ -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)