main: use source instead of sourceNumber

Due to privacy features of signal, sourceNumber might be null
This commit is contained in:
lemoer 2024-12-28 02:17:27 +01:00
parent acb8ae2847
commit 458bfbfc2c

12
main.py
View File

@ -316,10 +316,10 @@ class LabCleaningBot:
match envelope:
# Normal direct message (no edits, no reactions)
case EnvelopeData(dataMessage=DataMessage(message=message, groupInfo=None), sourceNumber=sourceNumber):
print(message, "direct", sourceNumber)
case EnvelopeData(dataMessage=DataMessage(message=message, groupInfo=None), source=source):
print(message, "direct", source)
# Normal group message (no edits, no reactions)
case EnvelopeData(dataMessage=DataMessage(message=message, groupInfo=GroupInfo(groupId=group_id)), sourceNumber=sourceNumber):
case EnvelopeData(dataMessage=DataMessage(message=message, groupInfo=GroupInfo(groupId=group_id)), source=source):
print(message, group_id)
# Reaction in direct messages
case EnvelopeData(
@ -332,7 +332,7 @@ class LabCleaningBot:
groupInfo=None,
timestamp=timestamp
),
sourceNumber=sourceNumber):
source=source):
reactionTimestamp = signal_timestamp_to_datetime(timestamp)
requestTimestamp = signal_timestamp_to_datetime(targetSentTimestamp)
@ -375,9 +375,9 @@ class LabCleaningBot:
response_msg = "You cannot reject the request after the timeout."
self.api.send_message(
SendMessageSimple(message=response_msg, recipients=[sourceNumber]))
SendMessageSimple(message=response_msg, recipients=[source]))
print(emoji, "direct", sourceNumber, isRemove)
print(emoji, "direct", source, isRemove)
def create_or_update_task_group(self, task: Task) -> Result[str, str]:
chatgroup = task.chatgroup