Skip to content

Commit

Permalink
bugfix sender determination in the android whatsapp provider
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholas FitzRoy-Dale committed Sep 6, 2023
1 parent 3539943 commit 02643da
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
1 change: 1 addition & 0 deletions .rgignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ariadne
example
11 changes: 5 additions & 6 deletions rime/providers/androidwhatsapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,9 @@ def search_events(self, device, filter_):
# is as indicated by sender_jid_row_id.

# Find the sender.
if row[fields['sender_jid_row_id']] == 0:
if row[fields['from_me']]:
sender = device.device_operator_contact
elif row[fields['sender_jid_row_id']] == 0:
# Group chat.
author_device_jid = row[fields['author_device_jid']]
if author_device_jid:
Expand All @@ -376,10 +378,7 @@ def search_events(self, device, filter_):
# Private chat.
sender = self._get_contact(row[fields['sender_jid_row_id']]) # may be None

# One reason for sender to be none is that it's the device operator.
if sender is None and bool(row[fields['from_me']]):
sender = device.device_operator_contact
else:
if sender is None:
sender = device.unknown_contact

# Store session info.
Expand Down Expand Up @@ -472,7 +471,7 @@ def subset(self, subsetter, events: Iterable[Event], contacts: Iterable[Contact]
wa_message = event.provider_data

rows_message.add(wa_message.message_row_id)
if event.sender:
if event.sender and event.sender.provider_data:
rows_jid.update(jid_contact.id_ for jid_contact in event.sender.provider_data.jid_contacts)

if event.session:
Expand Down

0 comments on commit 02643da

Please sign in to comment.