Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'NoneType' object has no attribute 'name' - in get_group_update_data_v1 #60

Open
markusstraub opened this issue Jan 4, 2022 · 1 comment

Comments

@markusstraub
Copy link

$ signal2html  -i signal_backup/ -o signal_backup_html/
2022-01-04 21:29:11 | INFO - This is signal2html version 0.2.8
2022-01-04 21:29:11 | INFO - Found Signal database version: 123.
2022-01-04 21:29:11 | WARNING - This database version is untested, please report errors.
2022-01-04 21:29:11 | WARNING - Couldn't find attachment '/home/markus/tmp/signal_backups/signal_backup/Attachment_355_1556041763007.bin'. Maybe it was deleted or never downloaded?

... some more warnings snipped

2022-01-04 21:29:52 | WARNING - Couldn't find attachment '/home/markus/tmp/signal_backups/signal_backup/Attachment_5198_1632986264422.bin'. Maybe it was deleted or never downloaded?
Traceback (most recent call last):
  File "/home/markus/.local/bin/signal2html", line 8, in <module>
    sys.exit(main())
  File "/home/markus/.local/lib/python3.8/site-packages/signal2html/__main__.py", line 20, in main
    sys.exit(main())
  File "/home/markus/.local/lib/python3.8/site-packages/signal2html/ui.py", line 35, in main
    process_backup(args.input_dir, args.output_dir)
  File "/home/markus/.local/lib/python3.8/site-packages/signal2html/core.py", line 679, in process_backup
    populate_thread(
  File "/home/markus/.local/lib/python3.8/site-packages/signal2html/core.py", line 636, in populate_thread
    sms_records = get_sms_records(db, thread, addressbook)
  File "/home/markus/.local/lib/python3.8/site-packages/signal2html/core.py", line 101, in get_sms_records
    data = get_data_from_body(_type, body, addressbook, _id)
  File "/home/markus/.local/lib/python3.8/site-packages/signal2html/core.py", line 383, in get_data_from_body
    data = get_group_update_data_v1(
  File "/home/markus/.local/lib/python3.8/site-packages/signal2html/core.py", line 232, in get_group_update_data_v1
    name = addressbook.get_recipient_by_uuid(member.uuid).name
AttributeError: 'NoneType' object has no attribute 'name'
@markusstraub
Copy link
Author

This fixes the problem for me:

diff --git a/signal2html/core.py b/signal2html/core.py
index e02f8d2..11d8cca 100644
--- a/signal2html/core.py
+++ b/signal2html/core.py
@@ -229,8 +229,10 @@ def get_group_update_data_v1(rawbody, addressbook, mid):
         name = None
         match_from_phone = False
         if member.uuid:
-            name = addressbook.get_recipient_by_uuid(member.uuid).name
-        elif member.phone:
+            recipient = addressbook.get_recipient_by_uuid(member.uuid)
+            if recipient:
+                name = recipient.name
+        if member.phone and name is None:
             name = addressbook.get_recipient_by_phone(member.phone).name
             match_from_phone = True

And it may probably be a good idea to also change this (though it didn't cause any problems for me)

@@ -417,7 +419,7 @@ def get_mms_mentions(encoded_mentions, addressbook, mid):
         recipient = addressbook.get_recipient_by_uuid(
             structured_mention.who_uuid
         )
-        name = recipient.name
+        name = recipient.name if recipient else None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant