ignore posts that are not known to match policy
until now, delete_from_account would only ignore posts that were too young, but would fetch and refresh posts that didn't match fave/media/DM policies. this was fine most of the time but would result in a lot of refreshes if those policies were very restrictive. now these policies are respected when selecting candidate posts for deletion closes #174
This commit is contained in:
parent
dea3ab760a
commit
36860b6bf7
20
tasks.py
20
tasks.py
|
@ -234,8 +234,24 @@ def delete_from_account(account_id):
|
||||||
posts = (
|
posts = (
|
||||||
Post.query.with_parent(account, 'posts')
|
Post.query.with_parent(account, 'posts')
|
||||||
.filter(Post.created_at + account.policy_keep_younger <= db.func.now())
|
.filter(Post.created_at + account.policy_keep_younger <= db.func.now())
|
||||||
.filter(~Post.id.in_(db.select((latest_n_posts.c.id, )))).order_by(
|
.filter(~Post.id.in_(db.select((latest_n_posts.c.id, )))))
|
||||||
db.func.random()).limit(100).all())
|
|
||||||
|
if(account.policy_keep_favourites != 'none'):
|
||||||
|
posts = posts.filter(db.or_(
|
||||||
|
Post.favourite == (account.policy_keep_favourites == 'deleteonly'),
|
||||||
|
Post.is_reblog))
|
||||||
|
if(account.policy_keep_media != 'none'):
|
||||||
|
posts = posts.filter(db.or_(
|
||||||
|
Post.has_media == (account.policy_keep_media == 'deleteonly'),
|
||||||
|
Post.is_reblog))
|
||||||
|
if(account.policy_keep_direct):
|
||||||
|
posts = posts.filter(~Post.direct)
|
||||||
|
|
||||||
|
limit = 100
|
||||||
|
if account.service == 'mastodon':
|
||||||
|
limit = 10
|
||||||
|
|
||||||
|
posts = posts.order_by(db.func.random()).limit(limit).all()
|
||||||
|
|
||||||
to_delete = None
|
to_delete = None
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue