From 842816f1bfae7b0bced75ec549b985b7ac88ccf8 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Fri, 18 Aug 2023 14:32:27 -0400 Subject: [PATCH] also export the inbox --- database.go | 4 ++-- import.go | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/database.go b/database.go index 8c9696b..1647a6e 100644 --- a/database.go +++ b/database.go @@ -245,7 +245,7 @@ func gethonksforuserfirstclass(userid int64, wanted int64) []*Honk { func gethonksforme(userid int64, wanted int64) []*Honk { dt := time.Now().Add(-7 * 24 * time.Hour).UTC().Format(dbtimeformat) - rows, err := stmtHonksForMe.Query(wanted, userid, dt, userid) + rows, err := stmtHonksForMe.Query(wanted, userid, dt, userid, 250) return getsomehonks(rows, err) } func gethonksfromlongago(userid int64, wanted int64) []*Honk { @@ -1184,7 +1184,7 @@ func prepareStatements(db *sql.DB) { myhonkers := " and honker in (select xid from honkers where userid = ? and (flavor = 'sub' or flavor = 'peep' or flavor = 'presub') and combos not like '% - %')" stmtHonksForUser = preparetodie(db, selecthonks+"where honks.honkid > ? and honks.userid = ? and dt > ?"+myhonkers+butnotthose+limit) stmtHonksForUserFirstClass = preparetodie(db, selecthonks+"where honks.honkid > ? and honks.userid = ? and dt > ? and (rid = '' or what = 'bonk')"+myhonkers+butnotthose+limit) - stmtHonksForMe = preparetodie(db, selecthonks+"where honks.honkid > ? and honks.userid = ? and dt > ? and whofore = 1"+butnotthose+limit) + stmtHonksForMe = preparetodie(db, selecthonks+"where honks.honkid > ? and honks.userid = ? and dt > ? and whofore = 1"+butnotthose+smalllimit) stmtHonksFromLongAgo = preparetodie(db, selecthonks+"where honks.honkid > ? and honks.userid = ? and dt > ? and dt < ? and whofore = 2"+butnotthose+limit) stmtHonksISaved = preparetodie(db, selecthonks+"where honks.honkid > ? and honks.userid = ? and flags & 4 order by honks.honkid desc") stmtHonksByHonker = preparetodie(db, selecthonks+"join honkers on (honkers.xid = honks.honker or honkers.xid = honks.oonker) where honks.honkid > ? and honks.userid = ? and honkers.name = ?"+butnotthose+limit) diff --git a/import.go b/import.go index 627f98f..01c9156 100644 --- a/import.go +++ b/import.go @@ -556,6 +556,30 @@ func export(username, file string) { j["orderedItems"] = jonks j.Write(w) } + { + w, err := zd.Create("inbox.json") + if err != nil { + elog.Fatal(err) + } + var jonks []junk.Junk + rows, err := stmtHonksForMe.Query(0, user.ID, "0", user.ID, 1234567) + honks := getsomehonks(rows, err) + for _, honk := range honks { + j, _ := jonkjonk(user, honk) + for _, donk := range honk.Donks { + donks[donk.XID] = true + } + jonks = append(jonks, j) + } + j := junk.New() + j["@context"] = itiswhatitis + j["id"] = user.URL + "/inbox" + j["attributedTo"] = user.URL + j["type"] = "OrderedCollection" + j["totalItems"] = len(jonks) + j["orderedItems"] = jonks + j.Write(w) + } zd.Create("media/") for donk := range donks { var media string