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