diff options
author | Andrew Godwin | 2022-11-10 23:42:43 -0700 |
---|---|---|
committer | Andrew Godwin | 2022-11-10 23:42:43 -0700 |
commit | fbfad9fbf5e061cb7c658dada3c4014c9796021c (patch) | |
tree | 41cb9c3685e347d506876e18c8e535e3d126f1d9 /users/models/inbox_message.py | |
parent | 2c3a1299709f2612e96c37e4e121c83ad4df7a56 (diff) | |
download | takahe-fbfad9fbf5e061cb7c658dada3c4014c9796021c.tar.gz takahe-fbfad9fbf5e061cb7c658dada3c4014c9796021c.tar.bz2 takahe-fbfad9fbf5e061cb7c658dada3c4014c9796021c.zip |
Inbound and outbound follows basic working
Diffstat (limited to 'users/models/inbox_message.py')
-rw-r--r-- | users/models/inbox_message.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/users/models/inbox_message.py b/users/models/inbox_message.py index 0dbdc3a..54b05e9 100644 --- a/users/models/inbox_message.py +++ b/users/models/inbox_message.py @@ -13,7 +13,7 @@ class InboxMessageStates(StateGraph): @classmethod async def handle_received(cls, instance: "InboxMessage"): - type = instance.message["type"].lower() + type = instance.message_type if type == "follow": await instance.follow_request() elif type == "accept": @@ -30,6 +30,7 @@ class InboxMessageStates(StateGraph): raise ValueError(f"Cannot handle activity of type undo.{inner_type}") else: raise ValueError(f"Cannot handle activity of type {type}") + return cls.processed class InboxMessage(StatorModel): @@ -60,10 +61,17 @@ class InboxMessage(StatorModel): """ Handles an incoming acceptance of one of our follow requests """ - Follow.remote_accepted( - source=Identity.by_actor_uri_with_create(self.message["actor"]), - target=Identity.by_actor_uri(self.message["object"]), - ) + target = Identity.by_actor_uri_with_create(self.message["actor"]) + source = Identity.by_actor_uri(self.message["object"]["actor"]) + if source is None: + raise ValueError( + f"Follow-Accept has invalid source {self.message['object']['actor']}" + ) + Follow.remote_accepted(source=source, target=target) + + @property + def message_type(self): + return self.message["type"].lower() async def follow_undo(self): """ |