From 36e9b49ac109b542e080ce967eb782b885d9b7d3 Mon Sep 17 00:00:00 2001 From: FChannel <=> Date: Tue, 26 Jan 2021 13:39:08 -0800 Subject: tombstone cache posts --- CacheDatabase.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'CacheDatabase.go') diff --git a/CacheDatabase.go b/CacheDatabase.go index fe55e84..cbb7cd1 100644 --- a/CacheDatabase.go +++ b/CacheDatabase.go @@ -562,6 +562,34 @@ func DeleteObjectFromCache(db *sql.DB, id string) { CheckError(err, "could not delete cache replies activitystream") } +func TombstoneObjectFromCache(db *sql.DB, id string) { + + datetime := time.Now().Format(time.RFC3339) + + query := `update cacheactivitystream set type='Tombstone', name='', content='', attributedto='deleted', updated=$1, deleted=$2 where id=$3` + + _, err := db.Exec(query, datetime, datetime, id) + + CheckError(err, "error with tombstone cache object") + + query = `update cacheactivitystream set type='Tombstone', mediatype='image/png', href=$1, name='', content='', attributedto='deleted', updated=$2, deleted=$3 where id in (select attachment from cacheactivitystream where id=$4)` + + _, err = db.Exec(query, "/public/removed.png", datetime, datetime, id) + + CheckError(err, "error with tombstone attachment cache object") + + query = `update cacheactivitystream set type='Tombstone', mediatype='image/png', href=$1, name='', content='', attributedto='deleted', updated=$2, deleted=$3 where id in (select preview from cacheactivitystream where id=$4)` + + _, err = db.Exec(query, "/public/removed.png", datetime, datetime, id) + + CheckError(err, "error with tombstone preview cache object") + + query = `delete from replies where id=$1` + _, err = db.Exec(query, id) + + CheckError(err, "could not delete cache replies activitystream") +} + func GetObjectPostsTotalCache(db *sql.DB, actor Actor) int{ count := 0 -- cgit v1.2.3