Skip to content

Commit 41a7489

Browse files
Merge pull request #12 from loadsmart/supportMessageId
Support less seen versions of Message-ID
2 parents 8db7a57 + 5fb99c1 commit 41a7489

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

gmail_wrapper/entities.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def message_id(self):
9191
While self.id is the user-bound id of the message, self.message_id
9292
is the global id of the message, valid for every user on the thread.
9393
"""
94-
return self.headers.get("Message-ID")
94+
return self.headers.get("Message-ID", self.headers.get("Message-Id"))
9595

9696
@property
9797
def thread_id(self):

tests/test_entities.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,20 @@ def test_it_archives_a_message(self, mocker, client, raw_complete_message):
115115
raw_complete_message["id"], add_labels=None, remove_labels=["INBOX"]
116116
)
117117

118+
def test_message_id_property(self, client, raw_complete_message):
119+
message = Message(client, raw_complete_message)
120+
assert (
121+
message.message_id
122+
== "<BY5PR15MB353717D866FC27FEE4DB4EC7F77E0@BY5PR15MB3537.namprd15.prod.outlook.com>"
123+
)
124+
raw_complete_message["payload"]["headers"][3]["name"] = "Message-Id"
125+
assert (
126+
message.message_id
127+
== "<BY5PR15MB353717D866FC27FEE4DB4EC7F77E0@BY5PR15MB3537.namprd15.prod.outlook.com>"
128+
)
129+
raw_complete_message["payload"]["headers"][3]["name"] = "Invalid"
130+
assert message.message_id is None
131+
118132

119133
class TestAttachment:
120134
def test_it_has_basic_properties_without_additional_fetch(

0 commit comments

Comments
 (0)