mirror of
https://github.com/jointakahe/takahe.git
synced 2024-11-22 15:21:01 +00:00
Lay groundwork for moved identity state
This commit is contained in:
parent
93dfc85cf7
commit
84703bbc45
2 changed files with 20 additions and 0 deletions
|
@ -242,6 +242,10 @@ class FanOutStates(StateGraph):
|
||||||
except httpx.RequestError:
|
except httpx.RequestError:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Handle sending identity moved to remote
|
||||||
|
case (FanOut.Types.identity_moved, False):
|
||||||
|
raise NotImplementedError()
|
||||||
|
|
||||||
# Sending identity edited/deleted to local is a no-op
|
# Sending identity edited/deleted to local is a no-op
|
||||||
case (FanOut.Types.identity_edited, True):
|
case (FanOut.Types.identity_edited, True):
|
||||||
pass
|
pass
|
||||||
|
@ -277,6 +281,7 @@ class FanOut(StatorModel):
|
||||||
identity_edited = "identity_edited"
|
identity_edited = "identity_edited"
|
||||||
identity_deleted = "identity_deleted"
|
identity_deleted = "identity_deleted"
|
||||||
identity_created = "identity_created"
|
identity_created = "identity_created"
|
||||||
|
identity_moved = "identity_moved"
|
||||||
|
|
||||||
state = StateField(FanOutStates)
|
state = StateField(FanOutStates)
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,9 @@ class IdentityStates(StateGraph):
|
||||||
deleted = State(try_interval=300, attempt_immediately=True)
|
deleted = State(try_interval=300, attempt_immediately=True)
|
||||||
deleted_fanned_out = State(delete_after=86400 * 7)
|
deleted_fanned_out = State(delete_after=86400 * 7)
|
||||||
|
|
||||||
|
moved = State(try_interval=300, attempt_immediately=True)
|
||||||
|
moved_fanned_out = State(externally_progressed=True)
|
||||||
|
|
||||||
deleted.transitions_to(deleted_fanned_out)
|
deleted.transitions_to(deleted_fanned_out)
|
||||||
|
|
||||||
edited.transitions_to(updated)
|
edited.transitions_to(updated)
|
||||||
|
@ -60,6 +63,8 @@ class IdentityStates(StateGraph):
|
||||||
outdated.transitions_to(updated)
|
outdated.transitions_to(updated)
|
||||||
updated.transitions_to(outdated)
|
updated.transitions_to(outdated)
|
||||||
|
|
||||||
|
moved.transitions_to(moved_fanned_out)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def group_deleted(cls):
|
def group_deleted(cls):
|
||||||
return [cls.deleted, cls.deleted_fanned_out]
|
return [cls.deleted, cls.deleted_fanned_out]
|
||||||
|
@ -96,6 +101,16 @@ class IdentityStates(StateGraph):
|
||||||
cls.targets_fan_out(instance, FanOut.Types.identity_edited)
|
cls.targets_fan_out(instance, FanOut.Types.identity_edited)
|
||||||
return cls.updated
|
return cls.updated
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def handle_moved(cls, instance: "Identity"):
|
||||||
|
from activities.models import FanOut
|
||||||
|
|
||||||
|
if not instance.local:
|
||||||
|
return cls.updated
|
||||||
|
|
||||||
|
cls.targets_fan_out(instance, FanOut.Types.identity_moved)
|
||||||
|
return cls.moved_fanned_out
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def handle_deleted(cls, instance: "Identity"):
|
def handle_deleted(cls, instance: "Identity"):
|
||||||
from activities.models import FanOut
|
from activities.models import FanOut
|
||||||
|
|
Loading…
Reference in a new issue