cache webfinger responses
This commit is contained in:
parent
cd7518c0a5
commit
7d6556ee36
31
web.go
31
web.go
|
@ -2171,15 +2171,10 @@ func dochpass(w http.ResponseWriter, r *http.Request) {
|
||||||
http.Redirect(w, r, "/account", http.StatusSeeOther)
|
http.Redirect(w, r, "/account", http.StatusSeeOther)
|
||||||
}
|
}
|
||||||
|
|
||||||
func fingerlicker(w http.ResponseWriter, r *http.Request) {
|
var oldfingers = cache.New(cache.Options{Filler: func(orig string) ([]byte, bool) {
|
||||||
orig := r.FormValue("resource")
|
|
||||||
|
|
||||||
dlog.Printf("finger lick: %s", orig)
|
|
||||||
|
|
||||||
if strings.HasPrefix(orig, "acct:") {
|
if strings.HasPrefix(orig, "acct:") {
|
||||||
orig = orig[5:]
|
orig = orig[5:]
|
||||||
}
|
}
|
||||||
|
|
||||||
name := orig
|
name := orig
|
||||||
idx := strings.LastIndexByte(name, '/')
|
idx := strings.LastIndexByte(name, '/')
|
||||||
if idx != -1 {
|
if idx != -1 {
|
||||||
|
@ -2200,12 +2195,7 @@ func fingerlicker(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
}
|
||||||
user, err := butwhatabout(name)
|
user, err := butwhatabout(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.NotFound(w, r)
|
return nil, false
|
||||||
return
|
|
||||||
}
|
|
||||||
if stealthmode(user.ID, r) {
|
|
||||||
http.NotFound(w, r)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
j := junk.New()
|
j := junk.New()
|
||||||
|
@ -2216,9 +2206,22 @@ func fingerlicker(w http.ResponseWriter, r *http.Request) {
|
||||||
l["type"] = `application/activity+json`
|
l["type"] = `application/activity+json`
|
||||||
l["href"] = user.URL
|
l["href"] = user.URL
|
||||||
j["links"] = []junk.Junk{l}
|
j["links"] = []junk.Junk{l}
|
||||||
|
return j.ToBytes(), true
|
||||||
|
}})
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/jrd+json")
|
func fingerlicker(w http.ResponseWriter, r *http.Request) {
|
||||||
j.Write(w)
|
orig := r.FormValue("resource")
|
||||||
|
|
||||||
|
dlog.Printf("finger lick: %s", orig)
|
||||||
|
|
||||||
|
var j []byte
|
||||||
|
ok := oldfingers.Get(orig, &j)
|
||||||
|
if ok {
|
||||||
|
w.Header().Set("Content-Type", "application/jrd+json")
|
||||||
|
w.Write(j)
|
||||||
|
} else {
|
||||||
|
http.NotFound(w, r)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func somedays() string {
|
func somedays() string {
|
||||||
|
|
Loading…
Reference in New Issue