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

send error if someone wasn't added to admin group correctly. #95

Closed
wants to merge 1 commit into from

Conversation

missytake
Copy link
Contributor

fixes #68

I was too lazy to write a complicated test which reproduces a corrupted verified group, but with the traceback in #68 I think we don't need to reproduce this to fix it. It's quite straightforward; and after all the bug is only annoying, not a security issue or anything. So imho we can merge this.

@missytake missytake requested a review from link2xt January 7, 2023 19:06
@@ -141,6 +143,13 @@ 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():
Copy link
Contributor

Choose a reason for hiding this comment

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

is the command allowed to be unencrypted at all? IOW i guess the first part of the elif expression is not needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if you intended to write "is the admin group allowed to be unprotected at all?" - then you're correct, it isn't and the is_protected() chat isn't needed.

That is, as long as nobody fiddles with the mailadm database and assigns admingrpid to a different, unprotected chat. If that happens, we have a problem 😅 and then we want to catch it in the else class below, rather than say "please readd this person to the admin group".

So I slightly prefer the flow proposed in this PR, but we can also take out the is_protected() check.


A problem I see in this function, which can make questions like this one quite complex: over all, a message can have six different boolean attributes which destinate what should happen with it. So there are 64 different possibilities what kind of a message we have to deal with. I'm fiddling with a pivot table atm to figure out how to refactor this in a future PR.

(for reference, the 6 attributes are:)

  • message.starts_with(„/“)
  • message.chat.is_group()
  • message.chat.is_protected()
  • message.is_encrypted()
  • message.chat.id == self.admingroup.id
  • message.get_sender_contact() in self.admingroup.get_contacts()

@missytake
Copy link
Contributor Author

closed in favor of #99.

@missytake missytake closed this Jan 20, 2023
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

Successfully merging this pull request may close these issues.

ValueError if someone writes to admin group without being part of the admin group from the bot's perspective
2 participants