From bf18145db8538f658c64300f5ca23c060bf10524 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Fri, 3 May 2019 14:43:08 -0400 Subject: [PATCH] zonking of bonking --- activity.go | 8 +++++++- docs/spec.txt | 10 +++++----- honk.go | 3 +-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/activity.go b/activity.go index 6a1f077..ad128f7 100644 --- a/activity.go +++ b/activity.go @@ -268,7 +268,13 @@ func needxonkid(user *WhatAbout, xid string) bool { func savexonk(user *WhatAbout, x *Honk) { if x.What == "eradicate" { log.Printf("eradicating %s by %s", x.RID, x.Honker) - _, err := stmtDeleteHonk.Exec(x.RID, x.Honker, user.ID) + mh := re_unurl.FindStringSubmatch(x.Honker) + mr := re_unurl.FindStringSubmatch(x.RID) + if len(mh) < 2 || len(mr) < 2 || mh[1] != mr[1] { + log.Printf("not deleting owner mismatch") + return + } + _, err := stmtZonkIt.Exec(user.ID, x.RID) if err != nil { log.Printf("error eradicating: %s", err) } diff --git a/docs/spec.txt b/docs/spec.txt index 5073962..aae545d 100644 --- a/docs/spec.txt +++ b/docs/spec.txt @@ -51,10 +51,10 @@ view. (Previously this was accomplished via separate tables. That made some queries more difficult, but I think it's possible to workaround this. It would be considerably safer.) The honker column will be empty for local honks. -The what column further refines the type of honk. If a reply, tonk. If -deleted, zonk. If shared, bonk. In particular for the case of bonk, there -aren't enough columns to store original honker and bonker. This seems to work -out okay though. +The what column further refines the type of honk. If a reply, tonk. +If shared, bonk. In particular for the case of bonk, there +aren't enough columns to store original honker and bonker. +This seems to work out okay though. Attachments are physically saved as files, and logically joined to honks via the donks table. Emus are saved as donks as well. @@ -73,7 +73,7 @@ The xid column generally corresponds to ActivityPub id. For local honks, it will be a short string, not a complete URL. Note that some logical seeming joins won't work. The honker column of honks -does not have a corresponding entry in the honkers table, since we frequently +may not have a corresponding entry in the honkers table, since we frequently receive messages from people we don't follow. Should we track everybody whose identity crosses our path? This seems unnecessary. The honkers table is more like a mapping of active relationships, not a directory of all peoples. diff --git a/honk.go b/honk.go index 6d67ed8..1971838 100644 --- a/honk.go +++ b/honk.go @@ -1303,7 +1303,7 @@ func serve() { var stmtHonkers, stmtDubbers, stmtSaveHonker, stmtUpdateFlavor, stmtUpdateCombos *sql.Stmt var stmtOneXonk, stmtPublicHonks, stmtUserHonks, stmtHonksByCombo, stmtHonksByConvoy *sql.Stmt -var stmtHonksForUser, stmtHonksForMe, stmtDeleteHonk, stmtSaveDub *sql.Stmt +var stmtHonksForUser, stmtHonksForMe, stmtSaveDub *sql.Stmt var stmtHonksByHonker, stmtSaveHonk, stmtFileData, stmtWhatAbout *sql.Stmt var stmtFindXonk, stmtSaveDonk, stmtFindFile, stmtSaveFile *sql.Stmt var stmtAddDoover, stmtGetDoovers, stmtLoadDoover, stmtZapDoover *sql.Stmt @@ -1342,7 +1342,6 @@ func prepareStatements(db *sql.DB) { stmtFileData = preparetodie(db, "select media, content from files where xid = ?") stmtFindXonk = preparetodie(db, "select honkid from honks where userid = ? and xid = ?") stmtSaveDonk = preparetodie(db, "insert into donks (honkid, fileid) values (?, ?)") - stmtDeleteHonk = preparetodie(db, "delete from honks where xid = ? and honker = ? and userid = ?") stmtZonkIt = preparetodie(db, "delete from honks where userid = ? and xid = ?") stmtFindFile = preparetodie(db, "select fileid from files where url = ?") stmtSaveFile = preparetodie(db, "insert into files (xid, name, url, media, content) values (?, ?, ?, ?, ?)")