mirror of
https://github.com/jointakahe/takahe.git
synced 2025-02-18 00:25:20 +00:00
Purge failing inbox messages too
This commit is contained in:
parent
efd5f481e9
commit
bb0ee1b152
2 changed files with 11 additions and 8 deletions
|
@ -220,7 +220,6 @@ class Config(models.Model):
|
||||||
identity_min_length: int = 2
|
identity_min_length: int = 2
|
||||||
identity_max_per_user: int = 5
|
identity_max_per_user: int = 5
|
||||||
identity_max_age: int = 24 * 60 * 60
|
identity_max_age: int = 24 * 60 * 60
|
||||||
inbox_message_purge_after: int = 24 * 60 * 60
|
|
||||||
public_timeline: bool = True
|
public_timeline: bool = True
|
||||||
|
|
||||||
hashtag_unreviewed_are_public: bool = True
|
hashtag_unreviewed_are_public: bool = True
|
||||||
|
|
|
@ -1,17 +1,19 @@
|
||||||
from asgiref.sync import sync_to_async
|
from asgiref.sync import sync_to_async
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
from core.models import Config
|
|
||||||
from stator.models import State, StateField, StateGraph, StatorModel
|
from stator.models import State, StateField, StateGraph, StatorModel
|
||||||
|
|
||||||
|
|
||||||
class InboxMessageStates(StateGraph):
|
class InboxMessageStates(StateGraph):
|
||||||
received = State(try_interval=300)
|
received = State(try_interval=300)
|
||||||
processed = State(try_interval=86400, attempt_immediately=False)
|
processed = State(externally_progressed=True)
|
||||||
purged = State() # This is actually deletion, it will never get here
|
purge = State(try_interval=300)
|
||||||
|
purged = State() # Not actually real, nothing gets here
|
||||||
|
|
||||||
received.transitions_to(processed)
|
received.transitions_to(processed)
|
||||||
processed.transitions_to(purged)
|
processed.times_out_to(purge, 86400 * 1)
|
||||||
|
received.times_out_to(purge, 86400 * 3)
|
||||||
|
purge.transitions_to(purged)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def handle_received(cls, instance: "InboxMessage"):
|
async def handle_received(cls, instance: "InboxMessage"):
|
||||||
|
@ -151,9 +153,11 @@ class InboxMessageStates(StateGraph):
|
||||||
return cls.processed
|
return cls.processed
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def handle_processed(cls, instance: "InboxMessage"):
|
async def handle_purge(cls, instance: "InboxMessage"):
|
||||||
if instance.state_age > Config.system.inbox_message_purge_after:
|
"""
|
||||||
await InboxMessage.objects.filter(pk=instance.pk).adelete()
|
Just delete them!
|
||||||
|
"""
|
||||||
|
await InboxMessage.objects.filter(pk=instance.pk).adelete()
|
||||||
|
|
||||||
|
|
||||||
class InboxMessage(StatorModel):
|
class InboxMessage(StatorModel):
|
||||||
|
|
Loading…
Reference in a new issue