also export the inbox

This commit is contained in:
Ted Unangst 2023-08-18 14:32:27 -04:00
parent 1910279c6b
commit 842816f1bf
2 changed files with 26 additions and 2 deletions

View File

@ -245,7 +245,7 @@ func gethonksforuserfirstclass(userid int64, wanted int64) []*Honk {
func gethonksforme(userid int64, wanted int64) []*Honk { func gethonksforme(userid int64, wanted int64) []*Honk {
dt := time.Now().Add(-7 * 24 * time.Hour).UTC().Format(dbtimeformat) 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) return getsomehonks(rows, err)
} }
func gethonksfromlongago(userid int64, wanted int64) []*Honk { 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 '% - %')" 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) 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) 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) 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") 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) 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)

View File

@ -556,6 +556,30 @@ func export(username, file string) {
j["orderedItems"] = jonks j["orderedItems"] = jonks
j.Write(w) 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/") zd.Create("media/")
for donk := range donks { for donk := range donks {
var media string var media string