Lay groundwork for moved identity state
This commit is contained in:
parent
93dfc85cf7
commit
84703bbc45
|
@ -242,6 +242,10 @@ class FanOutStates(StateGraph):
|
|||
except httpx.RequestError:
|
||||
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
|
||||
case (FanOut.Types.identity_edited, True):
|
||||
pass
|
||||
|
@ -277,6 +281,7 @@ class FanOut(StatorModel):
|
|||
identity_edited = "identity_edited"
|
||||
identity_deleted = "identity_deleted"
|
||||
identity_created = "identity_created"
|
||||
identity_moved = "identity_moved"
|
||||
|
||||
state = StateField(FanOutStates)
|
||||
|
||||
|
|
|
@ -51,6 +51,9 @@ class IdentityStates(StateGraph):
|
|||
deleted = State(try_interval=300, attempt_immediately=True)
|
||||
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)
|
||||
|
||||
edited.transitions_to(updated)
|
||||
|
@ -60,6 +63,8 @@ class IdentityStates(StateGraph):
|
|||
outdated.transitions_to(updated)
|
||||
updated.transitions_to(outdated)
|
||||
|
||||
moved.transitions_to(moved_fanned_out)
|
||||
|
||||
@classmethod
|
||||
def group_deleted(cls):
|
||||
return [cls.deleted, cls.deleted_fanned_out]
|
||||
|
@ -96,6 +101,16 @@ class IdentityStates(StateGraph):
|
|||
cls.targets_fan_out(instance, FanOut.Types.identity_edited)
|
||||
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
|
||||
def handle_deleted(cls, instance: "Identity"):
|
||||
from activities.models import FanOut
|
||||
|
|
Loading…
Reference in New Issue