activity_tools.inbox
1from .objects import Follow, Undo, InboxObject, Actor 2 3class Inbox: 4 5 def __init__(self, data) -> None: 6 self.data = data 7 8 for key in ["@context", "object", "type"]: 9 if not key in data: 10 raise Exception(f"Missing {key} in inbox message") 11 12 def parse(self) -> InboxObject: 13 func_name = f"type_{self.data['type'].lower()}" 14 15 if not hasattr(self, func_name): 16 raise Exception(f"Inbox message type {self.data['type']} is not implemented") 17 18 return getattr(self, func_name)() 19 20 def type_follow(self): 21 return Follow(self.data) 22 23 def type_undo(self): 24 return Undo(self.data)
class
Inbox:
4class Inbox: 5 6 def __init__(self, data) -> None: 7 self.data = data 8 9 for key in ["@context", "object", "type"]: 10 if not key in data: 11 raise Exception(f"Missing {key} in inbox message") 12 13 def parse(self) -> InboxObject: 14 func_name = f"type_{self.data['type'].lower()}" 15 16 if not hasattr(self, func_name): 17 raise Exception(f"Inbox message type {self.data['type']} is not implemented") 18 19 return getattr(self, func_name)() 20 21 def type_follow(self): 22 return Follow(self.data) 23 24 def type_undo(self): 25 return Undo(self.data)