superseriousbusiness / gotosocial

Fast, fun, small ActivityPub server.
https://docs.gotosocial.org
GNU Affero General Public License v3.0
3.67k stars 311 forks source link

[feature] Store status tombstones to avoid breaking threads #2058

Open tsmethurst opened 1 year ago

tsmethurst commented 1 year ago

Right now if a status parent is deleted, child statuses end up 'orphaned' and will return an error during status visibility checks.

To avoid breaking threads, we should consider storing tombstones for deleted statuses. The ID of the tombstone could be the ID of the tombstoned (yes that's a word now) status, and it could contain fields like AccountID, InReplyToID, InReplyToURI, etc. Something along those lines. When doing visibility checks, if a parent status for the given status cannot be found, the visibility checker could look in tombstones to see if the status is orphaned, and alter visibility accordingly.

To avoid clogging up the db with unchecked tombstones, tombstones older than a month (?) could be periodically cleared out.

handlerug commented 10 months ago

To avoid clogging up the db with unchecked tombstones, tombstones older than a month (?) could be periodically cleared out.

Does that mean that status visibility checks will start failing again after a month (as neither the status nor its tombstone would be present in the database)?

tsmethurst commented 10 months ago

Well, I think any tombstoning we would do to avoid breaking threads would also be accompanied by some tweaks to the visibility logic. So yes and no!

mirabilos commented 1 month ago

A wild idea I just had is to mangle the in_reply_to_id, in_reply_to_uri and in_reply_to_account_id fields of all statuses whose parent gets deleted (e.g. in a blocking or defederating situation) to the next retained parent (or to the top, if none… for full effect, this might need thread-to-the-top traversal and fetching of missing toots if not yet present, but if not, emptying those fields might be better than nothing).

The thread_id could be kept (unless made a top-level post, I assume?).

This would not only avoid #2011 but also retain the thread information for forever-ish (otherwise, status tombstones ought to NOT be deleted (per https://github.com/superseriousbusiness/gotosocial/issues/2058#issuecomment-1814386837) as long as the thread is still present in statuses), modulo refetches I guess…

… status tombstones are probably the better solution.