consistent order of variables and row scans
This commit is contained in:
parent
cda608726d
commit
7bffa8414d
|
@ -206,8 +206,8 @@ saveit:
|
|||
}
|
||||
|
||||
func iszonked(userid int64, xid string) bool {
|
||||
row := stmtFindZonk.QueryRow(userid, xid)
|
||||
var id int64
|
||||
row := stmtFindZonk.QueryRow(userid, xid)
|
||||
err := row.Scan(&id)
|
||||
if err == nil {
|
||||
return true
|
||||
|
@ -235,8 +235,8 @@ func needxonkid(user *WhatAbout, xid string) bool {
|
|||
log.Printf("already zonked: %s", xid)
|
||||
return false
|
||||
}
|
||||
row := stmtFindXonk.QueryRow(user.ID, xid)
|
||||
var id int64
|
||||
row := stmtFindXonk.QueryRow(user.ID, xid)
|
||||
err := row.Scan(&id)
|
||||
if err == nil {
|
||||
return false
|
||||
|
@ -1294,8 +1294,8 @@ var handfull = cache.New(cache.Options{Filler: func(name string) (string, bool)
|
|||
log.Printf("bad fish name: %s", name)
|
||||
return "", true
|
||||
}
|
||||
row := stmtGetXonker.QueryRow(name, "fishname")
|
||||
var href string
|
||||
row := stmtGetXonker.QueryRow(name, "fishname")
|
||||
err := row.Scan(&href)
|
||||
if err == nil {
|
||||
return href, true
|
||||
|
@ -1399,8 +1399,8 @@ func ingestpubkey(origin string, obj junk.Junk) {
|
|||
obj = keyobj
|
||||
}
|
||||
keyname, ok := obj.GetString("id")
|
||||
row := stmtGetXonker.QueryRow(keyname, "pubkey")
|
||||
var data string
|
||||
row := stmtGetXonker.QueryRow(keyname, "pubkey")
|
||||
err := row.Scan(&data)
|
||||
if err == nil {
|
||||
return
|
||||
|
|
4
fun.go
4
fun.go
|
@ -494,8 +494,8 @@ func originate(u string) string {
|
|||
}
|
||||
|
||||
var allhandles = cache.New(cache.Options{Filler: func(xid string) (string, bool) {
|
||||
row := stmtGetXonker.QueryRow(xid, "handle")
|
||||
var handle string
|
||||
row := stmtGetXonker.QueryRow(xid, "handle")
|
||||
err := row.Scan(&handle)
|
||||
if err != nil {
|
||||
log.Printf("need to get a handle: %s", xid)
|
||||
|
@ -581,8 +581,8 @@ func ziggy(userid int64) *KeyInfo {
|
|||
}
|
||||
|
||||
var zaggies = cache.New(cache.Options{Filler: func(keyname string) (*rsa.PublicKey, bool) {
|
||||
row := stmtGetXonker.QueryRow(keyname, "pubkey")
|
||||
var data string
|
||||
row := stmtGetXonker.QueryRow(keyname, "pubkey")
|
||||
err := row.Scan(&data)
|
||||
if err != nil {
|
||||
log.Printf("hitting the webs for missing pubkey: %s", keyname)
|
||||
|
|
10
web.go
10
web.go
|
@ -351,9 +351,9 @@ func inbox(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
log.Printf("updating honker follow: %s", who)
|
||||
|
||||
var x string
|
||||
db := opendatabase()
|
||||
row := db.QueryRow("select xid from honkers where xid = ? and userid = ? and flavor in ('dub', 'undub')", who, user.ID)
|
||||
var x string
|
||||
err = row.Scan(&x)
|
||||
if err != sql.ErrNoRows {
|
||||
log.Printf("duplicate follow request: %s", who)
|
||||
|
@ -367,10 +367,10 @@ func inbox(w http.ResponseWriter, r *http.Request) {
|
|||
go rubadubdub(user, j)
|
||||
case "Accept":
|
||||
log.Printf("updating honker accept: %s", who)
|
||||
var name string
|
||||
db := opendatabase()
|
||||
row := db.QueryRow("select name from honkers where userid = ? and xid = ? and flavor in ('presub')",
|
||||
user.ID, who)
|
||||
var name string
|
||||
err := row.Scan(&name)
|
||||
if err != nil {
|
||||
log.Printf("can't get honker name: %s", err)
|
||||
|
@ -486,9 +486,9 @@ func serverinbox(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
ont := "#" + m[1]
|
||||
log.Printf("%s wants to follow %s", who, ont)
|
||||
var x string
|
||||
db := opendatabase()
|
||||
row := db.QueryRow("select xid from honkers where name = ? and xid = ? and userid = ? and flavor in ('dub', 'undub')", ont, who, user.ID)
|
||||
var x string
|
||||
err = row.Scan(&x)
|
||||
if err != sql.ErrNoRows {
|
||||
log.Printf("duplicate follow request: %s", who)
|
||||
|
@ -1731,9 +1731,9 @@ func submithonker(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
url = info.XID
|
||||
|
||||
var x string
|
||||
db := opendatabase()
|
||||
row := db.QueryRow("select xid from honkers where xid = ? and userid = ? and flavor in ('sub', 'unsub', 'peep')", url, u.UserID)
|
||||
var x string
|
||||
err = row.Scan(&x)
|
||||
if err != sql.ErrNoRows {
|
||||
http.Error(w, "it seems you are already subscribed to them", http.StatusInternalServerError)
|
||||
|
@ -1947,9 +1947,9 @@ func servememe(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
func servefile(w http.ResponseWriter, r *http.Request) {
|
||||
xid := mux.Vars(r)["xid"]
|
||||
row := stmtGetFileData.QueryRow(xid)
|
||||
var media string
|
||||
var data []byte
|
||||
row := stmtGetFileData.QueryRow(xid)
|
||||
err := row.Scan(&media, &data)
|
||||
if err != nil {
|
||||
log.Printf("error loading file: %s", err)
|
||||
|
|
Loading…
Reference in New Issue