def test_new_message_user(session): data = { "attachments": [], "body": "test", "irisSeqId": "1111111", "irisTags": ["DeltaNewMessage"], "messageMetadata": { "actorFbId": "1234", "folderId": {"systemFolderId": "INBOX"}, "messageId": "mid.$XYZ", "offlineThreadingId": "11223344556677889900", "skipBumpThread": False, "skipSnippetUpdate": False, "tags": ["source:messenger:web"], "threadKey": {"otherUserFbId": "1234"}, "threadReadStateEffect": "KEEP_AS_IS", "timestamp": "1600000000000", }, "requestContext": {"apiArgs": {}}, "class": "NewMessage", } assert MessageEvent( author=User(session=session, id="1234"), thread=User(session=session, id="1234"), message=MessageData( thread=User(session=session, id="1234"), id="mid.$XYZ", author="1234", text="test", created_at=datetime.datetime( 2020, 9, 13, 12, 26, 40, tzinfo=datetime.timezone.utc ), ), at=datetime.datetime(2020, 9, 13, 12, 26, 40, tzinfo=datetime.timezone.utc), ) == parse_delta(session, data)
def test_person_removed(session): data = { "irisSeqId": "11223344", "irisTags": ["DeltaParticipantLeftGroupThread", "is_from_iris_fanout"], "leftParticipantFbId": "1234", "messageMetadata": { "actorFbId": "3456", "adminText": "You removed Abc Def from the group.", "folderId": {"systemFolderId": "INBOX"}, "messageId": "mid.$XYZ", "offlineThreadingId": "1122334455", "skipBumpThread": True, "tags": [], "threadKey": {"threadFbId": "4321"}, "threadReadStateEffect": "KEEP_AS_IS", "timestamp": "1500000000000", "unsendType": "deny_log_message", }, "participants": ["1234", "2345", "3456", "4567"], "requestContext": {"apiArgs": {}}, "tqSeqId": "1111", "class": "ParticipantLeftGroupThread", } assert PersonRemoved( author=User(session=session, id="3456"), thread=Group(session=session, id="4321"), removed=User(session=session, id="1234"), at=datetime.datetime(2017, 7, 14, 2, 40, tzinfo=datetime.timezone.utc), ) == parse_delta(session, data)
def test_orca_typing_notifications(session): data = {"type": "typ", "sender_fbid": 1234, "state": 1} (event, ) = parse_events(session, "/orca_typing_notifications", data) assert event == Typing( author=User(session=session, id="1234"), thread=User(session=session, id="1234"), status=True, )
def test_user_status_unblocked(session): data = { "threadKey": { "otherUserFbId": 1234 }, "canViewerReply": True, "reason": 2, "actorFbid": 1234, } assert UserStatusEvent( author=User(session=session, id="1234"), thread=User(session=session, id="1234"), blocked=False, ) == parse_client_delta(session, {"deltaChangeViewerStatus": data})
def test_thread_parse_participants(session): nodes = [ {"messaging_actor": {"__typename": "User", "id": "1234"}}, {"messaging_actor": {"__typename": "User", "id": "2345"}}, {"messaging_actor": {"__typename": "Page", "id": "3456"}}, {"messaging_actor": {"__typename": "MessageThread", "id": "4567"}}, {"messaging_actor": {"__typename": "UnavailableMessagingActor", "id": "5678"}}, ] assert [ User(session=session, id="1234"), User(session=session, id="2345"), Page(session=session, id="3456"), Group(session=session, id="4567"), ] == list(ThreadABC._parse_participants(session, {"nodes": nodes}))
def test_mark_read(session): data = { "actionTimestamp": "1600000000000", "irisSeqId": "1111111", "irisTags": ["DeltaMarkRead", "is_from_iris_fanout"], "threadKeys": [{"threadFbId": "1234"}, {"otherUserFbId": "2345"}], "tqSeqId": "1111", "watermarkTimestamp": "1500000000000", "class": "MarkRead", } assert ThreadsRead( author=User(session=session, id=session.user_id), threads=[Group(session=session, id="1234"), User(session=session, id="2345")], at=datetime.datetime(2020, 9, 13, 12, 26, 40, tzinfo=datetime.timezone.utc), ) == parse_delta(session, data)
def test_title_set(session): data = { "irisSeqId": "11223344", "irisTags": ["DeltaThreadName", "is_from_iris_fanout"], "messageMetadata": { "actorFbId": "3456", "adminText": "You named the group abc.", "folderId": {"systemFolderId": "INBOX"}, "messageId": "mid.$XYZ", "offlineThreadingId": "1122334455", "skipBumpThread": False, "tags": [], "threadKey": {"threadFbId": "4321"}, "threadReadStateEffect": "KEEP_AS_IS", "timestamp": "1500000000000", "unsendType": "deny_log_message", }, "name": "abc", "participants": ["1234", "2345", "3456", "4567"], "requestContext": {"apiArgs": {}}, "tqSeqId": "1111", "class": "ThreadName", } assert TitleSet( author=User(session=session, id="3456"), thread=Group(session=session, id="4321"), title="abc", at=datetime.datetime(2017, 7, 14, 2, 40, tzinfo=datetime.timezone.utc), ) == parse_delta(session, data)
def test_plan_ended(session): data = {} assert PlanEnded( author=User(session=session, id="1234"), thread=Group(session=session, id="4321"), plan=PlanData( session=session, id="112233", time=datetime.datetime(2020, 9, 13, 12, 26, 40, tzinfo=datetime.timezone.utc), title="A plan", author_id="1234", guests={ "1234": GuestStatus.GOING, "2345": GuestStatus.INVITED, "3456": GuestStatus.INVITED, }, ), at=datetime.datetime(2017, 7, 14, 2, 40, tzinfo=datetime.timezone.utc), ) == parse_admin_message(session, data)
def test_thread_typing(session): data = {"sender_fbid": 1234, "state": 0, "type": "typ", "thread": "4321"} (event, ) = parse_events(session, "/thread_typing", data) assert event == Typing( author=User(session=session, id="1234"), thread=Group(session=session, id="4321"), status=False, )
def test_user_call_ended(session): data = { "irisSeqId": "1111111", "irisTags": ["DeltaAdminTextMessage", "is_from_iris_fanout"], "messageMetadata": { "actorFbId": "1234", "adminText": "Abc called you.", "folderId": { "systemFolderId": "INBOX" }, "messageId": "mid.$XYZ", "offlineThreadingId": "11223344556677889900", "skipBumpThread": False, "skipSnippetUpdate": False, "tags": ["source:generic_admin_text", "no_push"], "threadKey": { "otherUserFbId": "1234" }, "threadReadStateEffect": "KEEP_AS_IS", "timestamp": "1500000000000", "unsendType": "deny_log_message", }, "requestContext": { "apiArgs": {} }, "type": "messenger_call_log", "untypedData": { "call_capture_attachments": "", "caller_id": "1234", "conference_name": "MESSENGER:1234567890", "rating": "0", "messenger_call_instance_id": "1234567890", "video": "", "event": "one_on_one_call_ended", "server_info": "", "call_duration": "3", "callee_id": "100002950119740", }, "class": "AdminTextMessage", } assert CallEnded( author=User(session=session, id="1234"), thread=User(session=session, id="1234"), duration=datetime.timedelta(seconds=3), at=datetime.datetime(2017, 7, 14, 2, 40, tzinfo=datetime.timezone.utc), ) == parse_admin_message(session, data)
def test_thread_event_parse_metadata(session): data = { "actorFbId": "4321", "folderId": {"systemFolderId": "INBOX"}, "messageId": "mid.$XYZ", "offlineThreadingId": "112233445566", "skipBumpThread": False, "skipSnippetUpdate": False, "tags": ["source:messenger:web"], "threadKey": {"otherUserFbId": "1234"}, "threadReadStateEffect": "KEEP_AS_IS", "timestamp": "1500000000000", } assert ( User(session=session, id="4321"), User(session=session, id="1234"), datetime.datetime(2017, 7, 14, 2, 40, tzinfo=datetime.timezone.utc), ) == ThreadEvent._parse_metadata(session, {"messageMetadata": data})
def test_reaction_event_added(session): data = { "threadKey": { "otherUserFbId": 1234 }, "messageId": "mid.$XYZ", "action": 0, "userId": 4321, "reaction": "😍", "senderId": 4321, "offlineThreadingId": "6623596674408921967", } thread = User(session=session, id="1234") assert ReactionEvent( author=User(session=session, id="4321"), thread=thread, message=Message(thread=thread, id="mid.$XYZ"), reaction="😍", ) == parse_client_delta(session, {"deltaMessageReaction": data})
def test_t_ms_full(session): """A full example of parsing of data in /t_ms.""" payload = { "deltas": [{ "deltaMessageReaction": { "threadKey": { "threadFbId": 4321 }, "messageId": "mid.$XYZ", "action": 0, "userId": 1234, "reaction": "😢", "senderId": 1234, "offlineThreadingId": "1122334455", } }] } data = { "deltas": [ { "payload": [ord(x) for x in _util.json_minimal(payload)], "class": "ClientPayload", }, { "class": "NoOp", }, { "forceInsert": False, "messageId": "mid.$ABC", "threadKey": { "threadFbId": "4321" }, "class": "ForcedFetch", }, ], "firstDeltaSeqId": 111111, "lastIssuedSeqId": 111113, "queueEntityId": 1234, } thread = Group(session=session, id="4321") assert [ ReactionEvent( author=User(session=session, id="1234"), thread=thread, message=Message(thread=thread, id="mid.$XYZ"), reaction="😢", ), UnfetchedThreadEvent( thread=thread, message=Message(thread=thread, id="mid.$ABC"), ), ] == list(parse_events(session, "/t_ms", data))
def test_admins_removed(session): data = { "irisSeqId": "1111111", "irisTags": ["DeltaAdminTextMessage", "is_from_iris_fanout"], "messageMetadata": { "actorFbId": "1234", "adminText": "You removed yourself as a group admin.", "folderId": { "systemFolderId": "INBOX" }, "messageId": "mid.$XYZ", "offlineThreadingId": "11223344556677889900", "skipBumpThread": True, "tags": ["source:titan:web"], "threadKey": { "threadFbId": "4321" }, "threadReadStateEffect": "KEEP_AS_IS", "timestamp": "1500000000000", "unsendType": "deny_log_message", }, "participants": ["1234", "2345", "3456"], "requestContext": { "apiArgs": {} }, "tqSeqId": "1111", "type": "change_thread_admins", "untypedData": { "THREAD_CATEGORY": "GROUP", "TARGET_ID": "1234", "ADMIN_TYPE": "0", "ADMIN_EVENT": "remove_admin", }, "class": "AdminTextMessage", } assert AdminsRemoved( author=User(session=session, id="1234"), thread=Group(session=session, id="4321"), removed=[User(session=session, id="1234")], at=datetime.datetime(2017, 7, 14, 2, 40, tzinfo=datetime.timezone.utc), ) == parse_admin_message(session, data)
def test_thread_folder(session): data = { "class": "ThreadFolder", "folder": "FOLDER_PENDING", "irisSeqId": "1111", "irisTags": ["DeltaThreadFolder", "is_from_iris_fanout"], "requestContext": {"apiArgs": {}}, "threadKey": {"otherUserFbId": "1234"}, } assert ThreadFolder( thread=User(session=session, id="1234"), folder=ThreadLocation.PENDING ) == parse_delta(session, data)
def test_nickname_set(session): data = { "irisSeqId": "1111111", "irisTags": ["DeltaAdminTextMessage", "is_from_iris_fanout"], "messageMetadata": { "actorFbId": "1234", "adminText": "You set the nickname for Abc Def to abc.", "folderId": { "systemFolderId": "INBOX" }, "messageId": "mid.$XYZ", "offlineThreadingId": "11223344556677889900", "skipBumpThread": False, "tags": ["source:titan:web", "no_push"], "threadKey": { "threadFbId": "4321" }, "threadReadStateEffect": "MARK_UNREAD", "timestamp": "1500000000000", "unsendType": "deny_log_message", }, "participants": ["1234", "2345", "3456"], "requestContext": { "apiArgs": {} }, "tqSeqId": "1111", "type": "change_thread_nickname", "untypedData": { "nickname": "abc", "participant_id": "2345" }, "class": "AdminTextMessage", } assert NicknameSet( author=User(session=session, id="1234"), thread=Group(session=session, id="4321"), subject=User(session=session, id="2345"), nickname="abc", at=datetime.datetime(2017, 7, 14, 2, 40, tzinfo=datetime.timezone.utc), ) == parse_admin_message(session, data)
def test_emoji_set(session): data = { "irisSeqId": "1111111", "irisTags": ["DeltaAdminTextMessage"], "messageMetadata": { "actorFbId": "1234", "adminText": "You set the emoji to 🌟.", "folderId": { "systemFolderId": "INBOX" }, "messageId": "mid.$XYZ", "offlineThreadingId": "11223344556677889900", "skipBumpThread": False, "skipSnippetUpdate": False, "tags": ["source:generic_admin_text"], "threadKey": { "otherUserFbId": "1234" }, "threadReadStateEffect": "MARK_UNREAD", "timestamp": "1500000000000", "unsendType": "deny_log_message", }, "requestContext": { "apiArgs": {} }, "type": "change_thread_icon", "untypedData": { "thread_icon_url": "https://www.facebook.com/images/emoji.php/v9/te0/1/16/1f31f.png", "thread_icon": "🌟", }, "class": "AdminTextMessage", } assert EmojiSet( author=User(session=session, id="1234"), thread=User(session=session, id="1234"), emoji="🌟", at=datetime.datetime(2017, 7, 14, 2, 40, tzinfo=datetime.timezone.utc), ) == parse_admin_message(session, data)
def test_people_added(session): data = { "addedParticipants": [ { "fanoutPolicy": "IRIS_MESSAGE_QUEUE", "firstName": "Abc", "fullName": "Abc Def", "initialFolder": "FOLDER_INBOX", "initialFolderId": {"systemFolderId": "INBOX"}, "isMessengerUser": False, "userFbId": "1234", } ], "irisSeqId": "11223344", "irisTags": ["DeltaParticipantsAddedToGroupThread", "is_from_iris_fanout"], "messageMetadata": { "actorFbId": "3456", "adminText": "You added Abc Def to the group.", "folderId": {"systemFolderId": "INBOX"}, "messageId": "mid.$XYZ", "offlineThreadingId": "1122334455", "skipBumpThread": False, "tags": [], "threadKey": {"threadFbId": "4321"}, "threadReadStateEffect": "KEEP_AS_IS", "timestamp": "1500000000000", "unsendType": "deny_log_message", }, "participants": ["1234", "2345", "3456", "4567"], "requestContext": {"apiArgs": {}}, "tqSeqId": "1111", "class": "ParticipantsAddedToGroupThread", } assert PeopleAdded( author=User(session=session, id="3456"), thread=Group(session=session, id="4321"), added=[User(session=session, id="1234")], at=datetime.datetime(2017, 7, 14, 2, 40, tzinfo=datetime.timezone.utc), ) == parse_delta(session, data)
def test_nickname_clear(session): data = { "irisSeqId": "1111111", "irisTags": ["DeltaAdminTextMessage"], "messageMetadata": { "actorFbId": "1234", "adminText": "You cleared your nickname.", "folderId": { "systemFolderId": "INBOX" }, "messageId": "mid.$XYZ", "offlineThreadingId": "11223344556677889900", "skipBumpThread": False, "skipSnippetUpdate": False, "tags": ["source:generic_admin_text"], "threadKey": { "otherUserFbId": "1234" }, "threadReadStateEffect": "MARK_UNREAD", "timestamp": "1500000000000", "unsendType": "deny_log_message", }, "requestContext": { "apiArgs": {} }, "type": "change_thread_nickname", "untypedData": { "nickname": "", "participant_id": "1234" }, "class": "AdminTextMessage", } assert NicknameSet( author=User(session=session, id="1234"), thread=User(session=session, id="1234"), subject=User(session=session, id="1234"), nickname=None, at=datetime.datetime(2017, 7, 14, 2, 40, tzinfo=datetime.timezone.utc), ) == parse_admin_message(session, data)
def test_event_get_thread_user(session): data = { "actorFbId": "4321", "folderId": {"systemFolderId": "INBOX"}, "messageId": "mid.$XYZ", "offlineThreadingId": "112233445566", "skipBumpThread": False, "skipSnippetUpdate": False, "tags": ["source:messenger:web"], "threadKey": {"otherUserFbId": "1234"}, "threadReadStateEffect": "KEEP_AS_IS", "timestamp": "1500000000000", } assert User(session=session, id="1234") == Event._get_thread(session, data)
def get_contact_list(self): """Returns all contacts (friends or non-friends) of the client. Returns: list: :class:`User` objects Raises: FBchatException: If request failed """ data = {"viewer": self._uid} j = self._payload_post("/chat/user_info_all", data) users = [] for data in j.values(): if data["type"] in ["user", "friend"]: users.append(User._from_all_fetch(data)) return users
def test_read_receipt(session): data = { "actionTimestampMs": "1600000000000", "actorFbId": "1234", "irisSeqId": "1111111", "irisTags": ["DeltaReadReceipt", "is_from_iris_fanout"], "requestContext": {"apiArgs": {}}, "threadKey": {"threadFbId": "4321"}, "tqSeqId": "1111", "watermarkTimestampMs": "1500000000000", "class": "ReadReceipt", } assert ThreadsRead( author=User(session=session, id="1234"), threads=[Group(session=session, id="4321")], at=datetime.datetime(2020, 9, 13, 12, 26, 40, tzinfo=datetime.timezone.utc), ) == parse_delta(session, data)
async def handle_got_message(msg, session, fbchat_client): logging.info(f"API Message: {msg}") if type(msg) == str: resp_json = loads(msg) else: resp_json = msg got_gateway = resp_json.get("gateway") if bool(got_gateway) is True: got_username = resp_json.get("username") file_data = None try: file_data = resp_json["Extra"]["file"][0]["Data"] file_data = standard_b64decode(file_data) search_link = False got_text = resp_json["Extra"]["file"][0]["Name"] except (KeyError, TypeError): logging.info(f"From API received json: {resp_json}") search_link = True got_text = resp_json.get("text") img_type_result, filename, cat = await find_file_type( search_text=got_text, search_link=search_link) if filename == got_text and search_link is False: got_text = f"sent {img_type_result} file" fb_thread = NeededVars.reverse_threads[got_gateway] thread = Group(session=session, id=fb_thread) if fb_thread in NeededVars.users: thread = User(session=session, id=fb_thread) await send_file(f"{got_username}", thread, fbchat_client, file_data, cat, img_type_result, filename, search_link) got_text = await format_text_quote(got_text) logging.info( f"From api sending message: username: {got_username} | text: {got_text}" ) await send_text(f"{got_username}{got_text}", thread) logging.info( f"Sent message: username: {got_username} | text: {got_text}")
def test_reaction_event_removed(session): data = { "threadKey": { "threadFbId": 1234 }, "messageId": "mid.$XYZ", "action": 1, "userId": 4321, "senderId": 4321, "offlineThreadingId": "6623586106713014836", } thread = Group(session=session, id="1234") assert ReactionEvent( author=User(session=session, id="4321"), thread=thread, message=Message(thread=thread, id="mid.$XYZ"), reaction=None, ) == parse_client_delta(session, {"deltaMessageReaction": data})
def test_delivery_receipt_user(session): data = { "deliveredWatermarkTimestampMs": "1500000000000", "irisSeqId": "1111111", "irisTags": ["DeltaDeliveryReceipt", "is_from_iris_fanout"], "messageIds": ["mid.$XYZ", "mid.$ABC"], "requestContext": {"apiArgs": {}}, "threadKey": {"otherUserFbId": "1234"}, "class": "DeliveryReceipt", } thread = User(session=session, id="1234") assert MessagesDelivered( author=thread, thread=thread, messages=[ Message(thread=thread, id="mid.$XYZ"), Message(thread=thread, id="mid.$ABC"), ], at=datetime.datetime(2017, 7, 14, 2, 40, tzinfo=datetime.timezone.utc), ) == parse_delta(session, data)
def test_color_set(session): data = { "irisSeqId": "1111111", "irisTags": ["DeltaAdminTextMessage", "is_from_iris_fanout"], "messageMetadata": { "actorFbId": "1234", "adminText": "You changed the chat theme to Orange.", "folderId": { "systemFolderId": "INBOX" }, "messageId": "mid.$XYZ", "offlineThreadingId": "11223344556677889900", "skipBumpThread": False, "tags": ["source:titan:web", "no_push"], "threadKey": { "threadFbId": "4321" }, "threadReadStateEffect": "MARK_UNREAD", "timestamp": "1500000000000", "unsendType": "deny_log_message", }, "participants": ["1234", "2345", "3456"], "requestContext": { "apiArgs": {} }, "tqSeqId": "1111", "type": "change_thread_theme", "untypedData": { "should_show_icon": "1", "theme_color": "FFFF7E29", "accessibility_label": "Orange", }, "class": "AdminTextMessage", } assert ColorSet( author=User(session=session, id="1234"), thread=Group(session=session, id="4321"), color="#ff7e29", at=datetime.datetime(2017, 7, 14, 2, 40, tzinfo=datetime.timezone.utc), ) == parse_admin_message(session, data)
def test_approvalmode_unset(session): data = { "irisSeqId": "1111111", "irisTags": ["DeltaAdminTextMessage", "is_from_iris_fanout"], "messageMetadata": { "actorFbId": "1234", "adminText": "You turned off member approval. Anyone with the link can join the group.", "folderId": { "systemFolderId": "INBOX" }, "messageId": "mid.$XYZ", "offlineThreadingId": "11223344556677889900", "skipBumpThread": True, "tags": ["source:titan:web", "no_push"], "threadKey": { "threadFbId": "4321" }, "threadReadStateEffect": "KEEP_AS_IS", "timestamp": "1500000000000", "unsendType": "deny_log_message", }, "participants": ["1234", "2345", "3456"], "requestContext": { "apiArgs": {} }, "tqSeqId": "1111", "type": "change_thread_approval_mode", "untypedData": { "APPROVAL_MODE": "0", "THREAD_CATEGORY": "GROUP" }, "class": "AdminTextMessage", } assert ApprovalModeSet( author=User(session=session, id="1234"), thread=Group(session=session, id="4321"), require_admin_approval=False, at=datetime.datetime(2017, 7, 14, 2, 40, tzinfo=datetime.timezone.utc), ) == parse_admin_message(session, data)
def test_call_joined(session): data = { "irisSeqId": "1111111", "irisTags": ["DeltaAdminTextMessage", "is_from_iris_fanout"], "messageMetadata": { "actorFbId": "1234", "adminText": "Abc joined the call.", "folderId": { "systemFolderId": "INBOX" }, "messageId": "mid.$XYZ", "offlineThreadingId": "11223344556677889900", "skipBumpThread": False, "tags": ["source:titan:web"], "threadKey": { "threadFbId": "4321" }, "threadReadStateEffect": "MARK_UNREAD", "timestamp": "1500000000000", "unsendType": "deny_log_message", }, "participants": ["1234", "2345", "3456"], "requestContext": { "apiArgs": {} }, "tqSeqId": "1111", "type": "participant_joined_group_call", "untypedData": { "server_info_data": "XYZ123ABC", "group_call_type": "0", "joining_user": "******", }, "class": "AdminTextMessage", } assert CallJoined( author=User(session=session, id="1234"), thread=Group(session=session, id="4321"), at=datetime.datetime(2017, 7, 14, 2, 40, tzinfo=datetime.timezone.utc), ) == parse_admin_message(session, data)
def test_group_from_graphql(session): data = { "name": "Group ABC", "thread_key": { "thread_fbid": "11223344" }, "image": None, "is_group_thread": True, "all_participants": { "nodes": [ { "messaging_actor": { "__typename": "User", "id": "1234" } }, { "messaging_actor": { "__typename": "User", "id": "2345" } }, { "messaging_actor": { "__typename": "User", "id": "3456" } }, ] }, "customization_info": { "participant_customizations": [], "outgoing_bubble_color": None, "emoji": "😀", }, "thread_admins": [{ "id": "1234" }], "group_approval_queue": { "nodes": [] }, "approval_mode": 0, "joinable_mode": { "mode": "0", "link": "" }, "event_reminders": { "nodes": [] }, } assert GroupData( session=session, id="11223344", photo=None, name="Group ABC", last_active=None, message_count=None, plan=None, participants=[ User(session=session, id="1234"), User(session=session, id="2345"), User(session=session, id="3456"), ], nicknames={}, color="#0084ff", emoji="😀", admins={"1234"}, approval_mode=False, approval_requests=set(), join_link="", ) == GroupData._from_graphql(session, data)
def test_plan_deleted(session): guest_list = [ { "guest_list_state": "GOING", "node": { "id": "1234" } }, { "guest_list_state": "INVITED", "node": { "id": "3456" } }, { "guest_list_state": "INVITED", "node": { "id": "2345" } }, ] data = { "irisSeqId": "1111111", "irisTags": ["DeltaAdminTextMessage", "is_from_iris_fanout"], "messageMetadata": { "actorFbId": "1234", "adminText": "You deleted the plan A plan for Mon, 20 Jan at 15:30.", "folderId": { "systemFolderId": "INBOX" }, "messageId": "mid.$XYZ", "offlineThreadingId": "11223344556677889900", "skipBumpThread": False, "tags": ["source:titan:web", "no_push"], "threadKey": { "threadFbId": "4321" }, "threadReadStateEffect": "MARK_UNREAD", "timestamp": "1500000000000", "unsendType": "deny_log_message", }, "participants": ["1234", "2345", "3456"], "requestContext": { "apiArgs": {} }, "tqSeqId": "1111", "type": "lightweight_event_delete", "untypedData": { "event_end_time": "0", "event_timezone": "", "event_id": "112233", "event_type": "EVENT", "event_location_id": "2233445566", "latitude": "0", "event_title": "A plan", "event_time": "1600000000", "event_seconds_to_notify_before": "3600", "guest_state_list": _util.json_minimal(guest_list), "event_note": "", "longitude": "0", }, "class": "AdminTextMessage", } assert PlanDeleted( author=User(session=session, id="1234"), thread=Group(session=session, id="4321"), plan=PlanData( session=session, id="112233", time=datetime.datetime(2020, 9, 13, 12, 26, 40, tzinfo=datetime.timezone.utc), title="A plan", location_id="2233445566", author_id=None, guests={ "1234": GuestStatus.GOING, "2345": GuestStatus.INVITED, "3456": GuestStatus.INVITED, }, ), at=datetime.datetime(2017, 7, 14, 2, 40, tzinfo=datetime.timezone.utc), ) == parse_admin_message(session, data)