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

WIP: send error if someone wasn't added to admin group correctly. #99

Closed
wants to merge 5 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/mailadm/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,13 @@ def ac_incoming_message(self, message: deltachat.Message):
logging.debug("ignoring message, it's just admins discussing in a support group")
else:
chat = message.create_chat()
if chat.is_group():
if chat.is_protected() and not message.is_encrypted():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can mean any of:

  • The message was not encrypted, probably sent with a classic MUA
  • The message was signed with a different key, probably because we verified the contact earlier, then the contact changed the key. It could be that nobody verified the contact yet. We can still write into the group.
  • The contact is not a member of the group. We cannot write to the group and need a recovery group.

sender = message.get_sender_contact().addr
logging.warning("The bot doesn't trust %s, please re-add them to admin group" %
(sender,))
message.chat.send_text("I didn't see %s being added to this group - can someone who"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this really work? I guess in this case you will not be able to send the message, because the group is protected and you don't have a verified key for one of the members.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. I'll think of something.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to create a new unverified group to tell the admin group members that the admin group is broken.

I also mitigated one corner case in which this can lead to an AttributeError (if someone in the group quote-replies to the group creation message, because then the bot thinks it's a support group).

I don't like this solution very much; it basically adds one more chat type which the bot needs to handle, thereby further increasing complexity. Maybe just leaving the recovery group directly after creating it would be better, what do you think?

" verified them re-add them?" % (sender,))
elif chat.is_group():
logging.info("%s added me to a group, I'm leaving it.",
message.get_sender_contact().addr)
chat.send_text("Sorry, you can not contact me in groups. Please use a 1:1 chat.")
Expand Down Expand Up @@ -116,6 +122,9 @@ def is_admin_group_message(self, command: deltachat.Message):
else:
logging.info("%s is not allowed to give commands to mailadm.",
command.get_sender_contact())
elif command.chat.is_protected() and not command.is_encrypted():
# warning is handled in ac_incoming_message
return False
else:
logging.info("The admin group is broken. Try `mailadm setup-bot`. Group ID: %s",
str(self.admingrpid))
Expand Down