donks for days. multiple images with api, adapted from benjojo

This commit is contained in:
Ted Unangst 2023-07-24 14:28:24 -04:00
parent b688f24e6d
commit c19490a802
1 changed files with 18 additions and 15 deletions

33
web.go
View File

@ -1801,20 +1801,22 @@ func submithonk(w http.ResponseWriter, r *http.Request) *Honk {
donkxid = fmt.Sprintf("%s:%d", d.XID, d.FileID) donkxid = fmt.Sprintf("%s:%d", d.XID, d.FileID)
} }
} else { } else {
p := strings.Split(donkxid, ":") for _, xid := range r.Form["donkxid"] {
xid := p[0] p := strings.Split(xid, ":")
url := fmt.Sprintf("https://%s/d/%s", serverName, xid) xid = p[0]
var donk *Donk url := fmt.Sprintf("https://%s/d/%s", serverName, xid)
if len(p) > 1 { var donk *Donk
fileid, _ := strconv.ParseInt(p[1], 10, 0) if len(p) > 1 {
donk = finddonkid(fileid, url) fileid, _ := strconv.ParseInt(p[1], 10, 0)
} else { donk = finddonkid(fileid, url)
donk = finddonk(url) } else {
} donk = finddonk(url)
if donk != nil { }
honk.Donks = append(honk.Donks, donk) if donk != nil {
} else { honk.Donks = append(honk.Donks, donk)
ilog.Printf("can't find file: %s", xid) } else {
ilog.Printf("can't find file: %s", xid)
}
} }
} }
memetize(honk) memetize(honk)
@ -2490,7 +2492,8 @@ func apihandler(w http.ResponseWriter, r *http.Request) {
http.Error(w, "missing donk", http.StatusBadRequest) http.Error(w, "missing donk", http.StatusBadRequest)
return return
} }
w.Write([]byte(d.XID)) donkxid := fmt.Sprintf("%s:%d", d.XID, d.FileID)
w.Write([]byte(donkxid))
case "zonkit": case "zonkit":
zonkit(w, r) zonkit(w, r)
case "gethonks": case "gethonks":