forked from LeineLab-Public/lab-signal-bot
apitypes: sourceNumber can be null
This commit is contained in:
parent
286588e0fe
commit
1c3e363433
43
apitypes.py
43
apitypes.py
@ -122,6 +122,45 @@ def test_reaction_message():
|
||||
assert m.envelope.dataMessage.reaction.isRemove is False
|
||||
assert m.account == "+4900000000002"
|
||||
|
||||
# This is a message with a reaction from an anonymous
|
||||
# source (where the source number is not known to the bot)
|
||||
# sourceNumber is None/null here
|
||||
|
||||
data2 = """{
|
||||
"envelope": {
|
||||
"source": "00000000-0000-0000-0000-000000000000",
|
||||
"sourceNumber": null,
|
||||
"sourceUuid": "00000000-0000-0000-0000-000000000000",
|
||||
"sourceName": "Anonymous",
|
||||
"sourceDevice": 2,
|
||||
"timestamp": 1735490493003,
|
||||
"serverReceivedTimestamp": 1735490493148,
|
||||
"serverDeliveredTimestamp": 1735490493149,
|
||||
"dataMessage": {
|
||||
"timestamp": 1735490493003,
|
||||
"message": null,
|
||||
"expiresInSeconds": 0,
|
||||
"viewOnce": false,
|
||||
"reaction": {
|
||||
"emoji": "👎",
|
||||
"targetAuthor": "+4900000000001",
|
||||
"targetAuthorNumber": "+4900000000001",
|
||||
"targetAuthorUuid": "00000000-0000-0000-0000-000000000000",
|
||||
"targetSentTimestamp": 1735490231727,
|
||||
"isRemove": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"account": "+4900000000001"
|
||||
}"""
|
||||
|
||||
res2 = parse_response(Message, data2)
|
||||
assert res2.is_ok()
|
||||
|
||||
m2 = res2.unwrap()
|
||||
assert(m2.envelope.source == "00000000-0000-0000-0000-000000000000")
|
||||
assert(m2.envelope.sourceNumber is None)
|
||||
|
||||
def test_simple_message():
|
||||
data = """{
|
||||
"envelope": {
|
||||
@ -550,8 +589,8 @@ class EditMessage(BaseModel):
|
||||
dataMessage: DataMessage
|
||||
|
||||
class Envelope(BaseModel):
|
||||
source: str
|
||||
sourceNumber: str
|
||||
source: str # can be uuid or number
|
||||
sourceNumber: str | None # Might be none if the bot doesn't know the phone number
|
||||
sourceUuid: str
|
||||
sourceName: str
|
||||
sourceDevice: int
|
||||
|
Loading…
Reference in New Issue
Block a user