diff --git a/activity.go b/activity.go index 7ffc15a..36dae53 100644 --- a/activity.go +++ b/activity.go @@ -1060,28 +1060,28 @@ func isactor(t string) bool { return true } -func investigate(name string) *Honker { +func investigate(name string) (*Honker, error) { if name == "" { - return nil + return nil, fmt.Errorf("no name") } if name[0] == '@' { name = gofish(name) } if name == "" { - return nil + return nil, fmt.Errorf("no name") } log.Printf("digging up some info on %s", name) obj, err := GetJunkFast(name) if err != nil { log.Printf("error investigating honker: %s", err) - return nil + return nil, err } t, _ := obj.GetString("type") if !isactor(t) { log.Printf("it's not a person! %s", name) - return nil + return nil, err } xid, _ := obj.GetString("id") handle, _ := obj.GetString("preferredUsername") - return &Honker{XID: xid, Handle: handle} + return &Honker{XID: xid, Handle: handle}, nil } diff --git a/fun.go b/fun.go index 983d42c..6ffd696 100644 --- a/fun.go +++ b/fun.go @@ -419,7 +419,7 @@ func findhandle(xid string) string { var handle string err := row.Scan(&handle) if err != nil { - p := investigate(xid) + p, _ := investigate(xid) if p == nil { m := re_unurl.FindStringSubmatch(xid) if len(m) > 2 { diff --git a/honk.go b/honk.go index 4083da0..01e3fe3 100644 --- a/honk.go +++ b/honk.go @@ -480,7 +480,7 @@ func inbox(w http.ResponseWriter, r *http.Request) { func ximport(w http.ResponseWriter, r *http.Request) { xid := r.FormValue("xid") - p := investigate(xid) + p, _ := investigate(xid) if p != nil { xid = p.XID } @@ -1426,8 +1426,9 @@ func savehonker(w http.ResponseWriter, r *http.Request) { if peep == "peep" { flavor = "peep" } - p := investigate(url) - if p == nil { + p, err := investigate(url) + if err != nil { + http.Error(w, "error investigating: "+err.Error(), http.StatusInternalServerError) log.Printf("failed to investigate honker") return } @@ -1435,7 +1436,7 @@ func savehonker(w http.ResponseWriter, r *http.Request) { if name == "" { name = p.Handle } - _, err := stmtSaveHonker.Exec(u.UserID, name, url, flavor, combos) + _, err = stmtSaveHonker.Exec(u.UserID, name, url, flavor, combos) if err != nil { log.Print(err) return