nodeinfo from jxs
@@ -250,11 +250,7 @@ }
func gethonksfromlongago(userid int64, wanted int64) []*Honk { now := time.Now() var honks []*Honk -<<<<<<< HEAD for i := 1; i <= 4; i++ { -======= - for i := 1; i <= 3; i++ { ->>>>>>> 4506960 (import) dt := time.Date(now.Year()-i, now.Month(), now.Day(), now.Hour(), now.Minute(), now.Second(), 0, now.Location()) dt1 := dt.Add(-36 * time.Hour).UTC().Format(dbtimeformat)@@ -489,13 +485,7 @@ elog.Printf("error parsing badonks: %s", err)
continue } case "wonkles": -<<<<<<< HEAD case "guesses": -======= - h.Wonkles = j - case "guesses": - h.Guesses = template.HTML(j) ->>>>>>> 4506960 (import) case "oldrev": default: elog.Printf("unknown meta genus: %s", genus)@@ -558,11 +548,8 @@ case "image/png":
xid += ".png" case "image/jpeg": xid += ".jpg" -<<<<<<< HEAD case "image/svg+xml": xid += ".svg" -======= ->>>>>>> 4506960 (import) case "application/pdf": xid += ".pdf" case "text/plain":@@ -589,7 +576,6 @@ fileid, _ := res.LastInsertId()
return fileid, xid, nil } -<<<<<<< HEAD func finddonkid(fileid int64, url string) *Donk { donk := new(Donk) row := stmtFindFileId.QueryRow(fileid, url)@@ -604,8 +590,6 @@ }
return nil } -======= ->>>>>>> 4506960 (import) func finddonk(url string) *Donk { donk := new(Donk) row := stmtFindFile.QueryRow(url)@@ -927,23 +911,6 @@ elog.Printf("error saving mentions: %s", err)
return err } } -<<<<<<< HEAD -======= - if w := h.Wonkles; w != "" { - _, err := tx.Stmt(stmtSaveMeta).Exec(h.ID, "wonkles", w) - if err != nil { - elog.Printf("error saving wonkles: %s", err) - return err - } - } - if g := h.Guesses; g != "" { - _, err := tx.Stmt(stmtSaveMeta).Exec(h.ID, "guesses", g) - if err != nil { - elog.Printf("error saving guesses: %s", err) - return err - } - } ->>>>>>> 4506960 (import) return nil }@@ -1011,11 +978,7 @@ func savexonker(what, value, flav, when string) {
stmtSaveXonker.Exec(what, value, flav, when) } -<<<<<<< HEAD func savehonker(user *WhatAbout, url, name, flavor, combos, mj string) (int64, error) { -======= -func savehonker(user *WhatAbout, url, name, flavor, combos, mj string) error { ->>>>>>> 4506960 (import) var owner string if url[0] == '#' { flavor = "peep"@@ -1027,11 +990,7 @@ } else {
info, err := investigate(url) if err != nil { ilog.Printf("failed to investigate honker: %s", err) -<<<<<<< HEAD return 0, err -======= - return err ->>>>>>> 4506960 (import) } url = info.XID if name == "" {@@ -1050,30 +1009,16 @@ elog.Printf("honker scan err: %s", err)
} else { err = fmt.Errorf("it seems you are already subscribed to them") } -<<<<<<< HEAD return 0, err -======= - return err ->>>>>>> 4506960 (import) } res, err := stmtSaveHonker.Exec(user.ID, name, url, flavor, combos, owner, mj) if err != nil { elog.Print(err) -<<<<<<< HEAD return 0, err } honkerid, _ := res.LastInsertId() return honkerid, nil -======= - return err - } - honkerid, _ := res.LastInsertId() - if flavor == "presub" { - followyou(user, honkerid) - } - return nil ->>>>>>> 4506960 (import) } func cleanupdb(arg string) {@@ -1143,6 +1088,30 @@ elog.Fatal(err)
} } +func getusercount() int { + row := stmtGetUserCount.QueryRow() + var count int + row.Scan(&count) + return count +} + +func getactiveusercount(monthsago int) int { + origin := time.Now().AddDate(0, -monthsago, 0).UTC().Format(dbtimeformat) + row := stmtGetActiveUserCount.QueryRow(origin) + + var count int + row.Scan(&count) + return count +} + +func getlocalhonkcount() int { + row := stmtGetLocalHonkCount.QueryRow() + + var count int + row.Scan(&count) + return count +} + var stmtHonkers, stmtDubbers, stmtNamedDubbers, stmtSaveHonker, stmtUpdateFlavor, stmtUpdateHonker *sql.Stmt var stmtDeleteHonker *sql.Stmt var stmtAnyXonk, stmtOneXonk, stmtPublicHonks, stmtUserHonks, stmtHonksByCombo, stmtHonksByConvoy *sql.Stmt@@ -1150,11 +1119,7 @@ var stmtHonksByOntology, stmtHonksForUser, stmtHonksForMe, stmtSaveDub, stmtHonksByXonker *sql.Stmt
var stmtHonksFromLongAgo *sql.Stmt var stmtHonksByHonker, stmtSaveHonk, stmtUserByName, stmtUserByNumber *sql.Stmt var stmtEventHonks, stmtOneBonk, stmtFindZonk, stmtFindXonk, stmtSaveDonk *sql.Stmt -<<<<<<< HEAD var stmtFindFile, stmtFindFileId, stmtGetFileData, stmtSaveFileData, stmtSaveFile *sql.Stmt -======= -var stmtFindFile, stmtGetFileData, stmtSaveFileData, stmtSaveFile *sql.Stmt ->>>>>>> 4506960 (import) var stmtCheckFileData *sql.Stmt var stmtAddDoover, stmtGetDoovers, stmtLoadDoover, stmtZapDoover, stmtOneHonker *sql.Stmt var stmtUntagged, stmtDeleteHonk, stmtDeleteDonks, stmtDeleteOnts, stmtSaveZonker *sql.Stmt@@ -1165,10 +1130,10 @@ var stmtSaveMeta, stmtDeleteAllMeta, stmtDeleteOneMeta, stmtDeleteSomeMeta, stmtUpdateHonk *sql.Stmt
var stmtHonksISaved, stmtGetFilters, stmtSaveFilter, stmtDeleteFilter *sql.Stmt var stmtGetTracks *sql.Stmt var stmtSaveChonk, stmtLoadChonks, stmtGetChatters *sql.Stmt -<<<<<<< HEAD var stmtDeliquentCheck, stmtDeliquentUpdate *sql.Stmt -======= ->>>>>>> 4506960 (import) +var stmtGetUserCount *sql.Stmt +var stmtGetActiveUserCount *sql.Stmt +var stmtGetLocalHonkCount *sql.Stmt func preparetodie(db *sql.DB, s string) *sql.Stmt { stmt, err := db.Prepare(s)
@@ -9,11 +9,11 @@ echo go 1.16+ is required
false fi -if [ \! \( -e /usr/include/sqlite3.h -o -e /usr/local/include/sqlite3.h \) ] ; then - echo unable to find sqlite3.h header - echo please install libsqlite3 dev package - false -fi +# if [ \! \( -e /usr/include/sqlite3.h -o -e /usr/local/include/sqlite3.h \) ] ; then +# echo unable to find sqlite3.h header +# echo please install libsqlite3 dev package +# false +# fi touch .preflightcheck
@@ -2256,6 +2256,49 @@ http.NotFound(w, r)
} } +func knowninformation(w http.ResponseWriter, r *http.Request) { + j := junk.New() + l := junk.New() + + l["rel"] = `http://nodeinfo.diaspora.software/ns/schema/2.0` + l["href"] = fmt.Sprintf("https://%s/nodeinfo/2.0", serverName) + j["links"] = []junk.Junk{l} + + w.Header().Set("Content-Type", "application/json") + j.Write(w) +} + +func actualinformation(w http.ResponseWriter, r *http.Request) { + j := junk.New() + + soft := junk.New() + soft["name"] = "honk" + soft["version"] = softwareVersion + + services := junk.New() + services["inbound"] = []string{} + services["outbound"] = []string{"rss2.0"} + + users := junk.New() + users["total"] = getusercount() + users["activeHalfyear"] = getactiveusercount(6) + users["activeMonth"] = getactiveusercount(1) + + usage := junk.New() + usage["users"] = users + usage["localPosts"] = getlocalhonkcount() + + j["version"] = "2.0" + j["protocols"] = []string{"activitypub"} + j["software"] = soft + j["services"] = services + j["openRegistrations"] = false + j["usage"] = usage + + w.Header().Set("Content-Type", "application/json") + j.Write(w) +} + func somedays() string { secs := 432000 + notrand.Int63n(432000) return fmt.Sprintf("%d", secs)@@ -2746,6 +2789,8 @@ getters.HandleFunc("/d/{xid:[\\pL[:digit:].]+}", servefile)
getters.HandleFunc("/emu/{emu:[^.]*[^/]+}", serveemu) getters.HandleFunc("/meme/{meme:[^.]*[^/]+}", servememe) getters.HandleFunc("/.well-known/webfinger", fingerlicker) + getters.HandleFunc("/.well-known/nodeinfo", knowninformation) + getters.HandleFunc("/nodeinfo/2.0", actualinformation) getters.HandleFunc("/flag/{code:.+}", showflag)