when sending updates or deletes, send to all fetch recipients too
This commit is contained in:
parent
577eb7068d
commit
ecbd80352f
|
@ -1209,6 +1209,9 @@ func honkworldwide(user *WhatAbout, honk *Honk) {
|
||||||
rcpts[h.XID] = true
|
rcpts[h.XID] = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for _, f := range getbacktracks(honk.XID) {
|
||||||
|
rcpts[f] = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for a := range rcpts {
|
for a := range rcpts {
|
||||||
go deliverate(0, user.ID, a, msg)
|
go deliverate(0, user.ID, a, msg)
|
||||||
|
|
|
@ -693,6 +693,7 @@ var stmtGetZonkers, stmtRecentHonkers, stmtGetXonker, stmtSaveXonker, stmtDelete
|
||||||
var stmtAllOnts, stmtSaveOnt, stmtUpdateFlags, stmtClearFlags *sql.Stmt
|
var stmtAllOnts, stmtSaveOnt, stmtUpdateFlags, stmtClearFlags *sql.Stmt
|
||||||
var stmtHonksForUserFirstClass, stmtSaveMeta, stmtDeleteMeta, stmtUpdateHonk *sql.Stmt
|
var stmtHonksForUserFirstClass, stmtSaveMeta, stmtDeleteMeta, stmtUpdateHonk *sql.Stmt
|
||||||
var stmtHonksISaved, stmtGetFilters, stmtSaveFilter, stmtDeleteFilter *sql.Stmt
|
var stmtHonksISaved, stmtGetFilters, stmtSaveFilter, stmtDeleteFilter *sql.Stmt
|
||||||
|
var stmtGetTracks *sql.Stmt
|
||||||
|
|
||||||
func preparetodie(db *sql.DB, s string) *sql.Stmt {
|
func preparetodie(db *sql.DB, s string) *sql.Stmt {
|
||||||
stmt, err := db.Prepare(s)
|
stmt, err := db.Prepare(s)
|
||||||
|
@ -769,4 +770,5 @@ func prepareStatements(db *sql.DB) {
|
||||||
stmtGetFilters = preparetodie(db, "select hfcsid, json from hfcs where userid = ?")
|
stmtGetFilters = preparetodie(db, "select hfcsid, json from hfcs where userid = ?")
|
||||||
stmtSaveFilter = preparetodie(db, "insert into hfcs (userid, json) values (?, ?)")
|
stmtSaveFilter = preparetodie(db, "insert into hfcs (userid, json) values (?, ?)")
|
||||||
stmtDeleteFilter = preparetodie(db, "delete from hfcs where userid = ? and hfcsid = ?")
|
stmtDeleteFilter = preparetodie(db, "delete from hfcs where userid = ? and hfcsid = ?")
|
||||||
|
stmtGetTracks = preparetodie(db, "select fetches from tracks where xid = ?")
|
||||||
}
|
}
|
||||||
|
|
33
web.go
33
web.go
|
@ -890,6 +890,33 @@ type Track struct {
|
||||||
who string
|
who string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getbacktracks(xid string) []string {
|
||||||
|
c := make(chan bool)
|
||||||
|
dumptracks <- c
|
||||||
|
<-c
|
||||||
|
row := stmtGetTracks.QueryRow(xid)
|
||||||
|
var rawtracks string
|
||||||
|
err := row.Scan(&rawtracks)
|
||||||
|
if err != nil {
|
||||||
|
if err != sql.ErrNoRows {
|
||||||
|
log.Printf("error scanning tracks: %s", err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
var rcpts []string
|
||||||
|
for _, f := range strings.Split(rawtracks, " ") {
|
||||||
|
idx := strings.LastIndexByte(f, '#')
|
||||||
|
if idx != -1 {
|
||||||
|
f = f[:idx]
|
||||||
|
}
|
||||||
|
if !strings.HasPrefix(f, "https://") {
|
||||||
|
f = fmt.Sprintf("%https://%s/inbox", f)
|
||||||
|
}
|
||||||
|
rcpts = append(rcpts, f)
|
||||||
|
}
|
||||||
|
return rcpts
|
||||||
|
}
|
||||||
|
|
||||||
func savetracks(tracks map[string][]string) {
|
func savetracks(tracks map[string][]string) {
|
||||||
db := opendatabase()
|
db := opendatabase()
|
||||||
tx, err := db.Begin()
|
tx, err := db.Begin()
|
||||||
|
@ -940,6 +967,7 @@ func savetracks(tracks map[string][]string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var trackchan = make(chan Track)
|
var trackchan = make(chan Track)
|
||||||
|
var dumptracks = make(chan chan bool)
|
||||||
|
|
||||||
func tracker() {
|
func tracker() {
|
||||||
timeout := 4 * time.Minute
|
timeout := 4 * time.Minute
|
||||||
|
@ -955,6 +983,11 @@ func tracker() {
|
||||||
tracks = make(map[string][]string)
|
tracks = make(map[string][]string)
|
||||||
}
|
}
|
||||||
sleeper.Reset(timeout)
|
sleeper.Reset(timeout)
|
||||||
|
case c := <-dumptracks:
|
||||||
|
if len(tracks) > 0 {
|
||||||
|
savetracks(tracks)
|
||||||
|
}
|
||||||
|
c <- true
|
||||||
case <-endoftheworld:
|
case <-endoftheworld:
|
||||||
if len(tracks) > 0 {
|
if len(tracks) > 0 {
|
||||||
savetracks(tracks)
|
savetracks(tracks)
|
||||||
|
|
Loading…
Reference in New Issue