if we already have it, don't get it

This commit is contained in:
Ted Unangst 2019-10-01 23:30:10 -04:00
parent 9c0204572e
commit 2b9797e277
1 changed files with 23 additions and 20 deletions

43
web.go
View File

@ -374,29 +374,32 @@ func inbox(w http.ResponseWriter, r *http.Request) {
} }
func ximport(w http.ResponseWriter, r *http.Request) { func ximport(w http.ResponseWriter, r *http.Request) {
xid := r.FormValue("xid")
p, _ := investigate(xid)
if p != nil {
xid = p.XID
}
j, err := GetJunk(xid)
if err != nil {
http.Error(w, "error getting external object", http.StatusInternalServerError)
log.Printf("error getting external object: %s", err)
return
}
log.Printf("importing %s", xid)
u := login.GetUserInfo(r) u := login.GetUserInfo(r)
user, _ := butwhatabout(u.Username) xid := r.FormValue("xid")
xonk := getxonk(u.UserID, xid)
if xonk == nil {
p, _ := investigate(xid)
if p != nil {
xid = p.XID
}
j, err := GetJunk(xid)
if err != nil {
http.Error(w, "error getting external object", http.StatusInternalServerError)
log.Printf("error getting external object: %s", err)
return
}
log.Printf("importing %s", xid)
user, _ := butwhatabout(u.Username)
what, _ := j.GetString("type") what, _ := j.GetString("type")
if isactor(what) { if isactor(what) {
outbox, _ := j.GetString("outbox") outbox, _ := j.GetString("outbox")
gimmexonks(user, outbox) gimmexonks(user, outbox)
http.Redirect(w, r, "/h?xid="+url.QueryEscape(xid), http.StatusSeeOther) http.Redirect(w, r, "/h?xid="+url.QueryEscape(xid), http.StatusSeeOther)
return return
}
xonk = xonksaver(user, j, originate(xid))
} }
xonk := xonksaver(user, j, originate(xid))
convoy := "" convoy := ""
if xonk != nil { if xonk != nil {
convoy = xonk.Convoy convoy = xonk.Convoy