diff options
-rw-r--r-- | CacheDatabase.go | 28 | ||||
-rw-r--r-- | Database.go | 8 | ||||
-rw-r--r-- | OutboxPost.go | 2 | ||||
-rw-r--r-- | main.go | 1 |
4 files changed, 29 insertions, 10 deletions
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 diff --git a/Database.go b/Database.go index c0df3a4..0d3ceca 100644 --- a/Database.go +++ b/Database.go @@ -729,7 +729,6 @@ func GetObjectImgsTotalDB(db *sql.DB, actor Actor) int{ func DeletePreviewFromFile(db *sql.DB, id string) { var query = `select href, type from activitystream where id in (select preview from activitystream where id=$1)` - // var query = fmt.Sprintf("select href, type from activitystream where id in (select attachment from activitystream where id='%s')", id) rows, err := db.Query(query, id) @@ -758,7 +757,6 @@ func DeletePreviewFromFile(db *sql.DB, id string) { func DeleteAttachmentFromFile(db *sql.DB, id string) { var query = `select href, type from activitystream where id in (select attachment from activitystream where id=$1)` - // var query = fmt.Sprintf("select href, type from activitystream where id in (select attachment from activitystream where id='%s')", id) rows, err := db.Query(query, id) @@ -787,7 +785,6 @@ func DeleteAttachmentFromFile(db *sql.DB, id string) { func DeletePreviewRepliesFromDB(db *sql.DB, id string) { var query = `select id from activitystream where id in (select id from replies where inreplyto=$1)` - // var query = fmt.Sprintf("select id from activitystream where id (select id from replies where inreplyto='%s');", id) rows, err := db.Query(query, id) @@ -807,7 +804,6 @@ func DeletePreviewRepliesFromDB(db *sql.DB, id string) { func DeleteAttachmentRepliesFromDB(db *sql.DB, id string) { var query = `select id from activitystream where id in (select id from replies where inreplyto=$1)` - // var query = fmt.Sprintf("select id from activitystream where id (select id from replies where inreplyto='%s');", id) rows, err := db.Query(query, id) @@ -829,7 +825,6 @@ func DeleteAttachmentFromDB(db *sql.DB, id string) { datetime := time.Now().Format(time.RFC3339) var query = `update activitystream set type='Tombstone', mediatype='image/png', href=$1, name='', content='', attributedto='deleted', updated=$2, deleted=$3 where id in (select attachment from activitystream where id=$4)` - // var query = fmt.Sprintf("update activitystream set type='Tombstone', mediatype='image/png', href='%s', name='', content='', attributedto='deleted', updated='%s', deleted='%s' where id in (select attachment from activitystream where id='%s');", Domain + "/public/removed.png", datetime, datetime, id) _, err := db.Exec(query, Domain + "/public/removed.png", datetime, datetime, id) @@ -840,7 +835,6 @@ func DeletePreviewFromDB(db *sql.DB, id string) { datetime := time.Now().Format(time.RFC3339) var query = `update activitystream set type='Tombstone', mediatype='image/png', href=$1, name='', content='', attributedto='deleted', updated=$2, deleted=$3 where id in (select preview from activitystream where id=$4)` - // var query = fmt.Sprintf("update activitystream set type='Tombstone', mediatype='image/png', href='%s', name='', content='', attributedto='deleted', updated='%s', deleted='%s' where id in (select attachment from activitystream where id='%s');", Domain + "/public/removed.png", datetime, datetime, id) _, err := db.Exec(query, Domain + "/public/removed.png", datetime, datetime, id) @@ -857,7 +851,6 @@ func DeleteObjectRepliedTo(db *sql.DB, id string){ func DeleteObjectFromDB(db *sql.DB, id string) { datetime := time.Now().Format(time.RFC3339) var query = `update activitystream set type='Tombstone', name='', content='', attributedto='deleted', updated=$1, deleted=$2 where id=$3` - // var query = fmt.Sprintf("update activitystream set type='Tombstone', name='', content='', attributedto='deleted', updated='%s', deleted='%s' where id='%s';", datetime, datetime, id) _, err := db.Exec(query, datetime, datetime, id) @@ -878,7 +871,6 @@ func DeleteObjectRepliesFromDB(db *sql.DB, id string) { datetime := time.Now().Format(time.RFC3339) var query = `update activitystream set type='Tombstone', name='', content='', attributedto='deleted', updated=$1, deleted=$2 where id in (select id from replies where inreplyto=$3)` - // var query = fmt.Sprintf("update activitystream set type='Tombstone', name='', content='', attributedto='deleted' updated='%s', deleted='%s' where id in (select id from replies where inreplyto='%s');", datetime, datetime, id) _, err := db.Exec(query, datetime, datetime, id) CheckError(err, "error with delete object replies") diff --git a/OutboxPost.go b/OutboxPost.go index 60fa769..99f18d9 100644 --- a/OutboxPost.go +++ b/OutboxPost.go @@ -517,7 +517,7 @@ func ParseInboxRequest(w http.ResponseWriter, r *http.Request, db *sql.DB) { for _, e := range activity.To { actor := GetActorFromDB(db, e) if actor.Id != "" { - DeleteObjectFromCache(db, activity.Object.Id) + TombstoneObjectFromCache(db, activity.Object.Id) return } } @@ -705,7 +705,6 @@ func main() { http.Redirect(w, r, r.Header.Get("Referer"), http.StatusSeeOther) return } - w.WriteHeader(http.StatusBadRequest) w.Write([]byte("")) |