Skip to content

Commit

Permalink
refactor: fix minor typos 🪲
Browse files Browse the repository at this point in the history
  • Loading branch information
KarelZe committed Jan 7, 2024
1 parent 8ec80e6 commit ae4e90d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,5 @@ dmypy.json

venv/
env/

testing/
21 changes: 14 additions & 7 deletions utils/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class Message:
client_arrival_time: Optional[str] = None
clientmessageid: Optional[str] = None
composetime: Optional[str] = None
conversation_id: Optional[str] = None
content: Optional[str] = None
contenttype: Optional[str] = None
created_time: Optional[str] = None
Expand Down Expand Up @@ -98,7 +99,7 @@ def __lt__(self, other):

LUT_KEYS_MSTEAMS_2_0 = {
"messageMap": "messages",
"id": "created_time",
"id": "createdTime",
"isSentByCurrentUser": "isFromMe",
"originalArrivalTime": "originalarrivaltime",
"clientMessageId": "clientmessageid",
Expand Down Expand Up @@ -174,9 +175,8 @@ def _parse_reply_chains(reply_chains: list[dict]) -> set[Message]:
cleaned_reply_chains = set()

for rc in reply_chains:
kwargs = rc.get("value", {}) | {"origin_file": rc.get("origin_file")}

# Reassign new keys to old identifiers
kwargs = rc.get("value", {})
keys = [LUT_KEYS_MSTEAMS_2_0.get(k, k) for k in kwargs.keys()]
kwargs.update(zip(keys, kwargs.values()))

Expand All @@ -202,7 +202,13 @@ def _parse_reply_chains(reply_chains: list[dict]) -> set[Message]:
# TODO: required to check for "reactionInChat" or "reaction"?
message_values["record_type"] = "reaction"

cleaned_reply_chains.add(Message.from_dict(message_values))
message_kwargs = message_values | {
"created_time": decode_timestamp(message_values["createdTime"]),
"version": decode_timestamp(message_values["version"]),
"origin_file": rc.get("origin_file"),
}

cleaned_reply_chains.add(Message.from_dict(message_kwargs))
return cleaned_reply_chains


Expand All @@ -222,9 +228,10 @@ def parse_records(records: list[dict]) -> list[dict]:

# sort within groups i.e., Contacts, Meetings, Conversations
parsed_records = (
sorted(_parse_people(people) | _parse_buddies(buddies))
+ sorted(_parse_reply_chains(reply_chains))
+ sorted(_parse_conversations(conversations))
_parse_people(people)
| _parse_buddies(buddies)
| _parse_reply_chains(reply_chains)
| _parse_conversations(conversations)
)
return [r.to_dict() for r in parsed_records]

Expand Down

0 comments on commit ae4e90d

Please sign in to comment.