mastodon
mastodon copied to clipboard
Implement account media prune and fetch command
This implements two new sub-commands for tootctl media
:
-
prune-profile-media
to remove old avatar and header images -
fetch-profile-media
to download missing avatar and header images basically undoing the prune command
I am new to Ruby and ActiveRecord, so please advise if something is wrong, I will fix the errors if needed.
This is a fix to #9567
The basis for deletion by this script is the datetime of the last webfinger request : could you provide examples of things that would result in webfinger requests ? E.g. if the remote account is already known by the local instance, and the remote account does not change profile picture / header / note, do you still have regular webfinger request to the account ?
As I understand the last_webfingered_at
date resolves mainly to the Account.possibly_stale?
property. This marks an account as stale if the last webfinger is older than 1 day (or nil
). So if the account is used by something incoming i think the webfinger process is restarted after about one day.
I think (if i understand correctly) mastodon will trigger a re-download of a missing avatar or header image when it processes an activity including that user. ActivityPub::Activity::Update
calls ActivityPub::ProcessAccountService
in its update_account
function when the ActivityPub message contains an actor. ProcessAccountService
will then run RedownloadAvatarWorker
which checks for an empty avatar and if a remote url is set triggers a download of the remote asset file.
Ok i see some linter stuff. Will fix this evening. Seems the linter in my vscode setup did not run.
I am afraid I cannot fix all linter problems as the linter complains about complexity of a function that was already there:
Perceived complexity for remove_orphans is too high. [26/25]
Ok, I have to retract this, the webfinger is not updated as often as I suspected. I'll have to find another way of doing this. updated_at
also doesn't work. Perhaps the last posted status we have seen? I think I know why this has never been implemented. It's really non-trivial and full of edge cases :(
I'll experiment a bit more on it and will retry in a few days with a new PR. Sorry for the work I produced for my fellow reviewers.