-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
DeltaChat bot as additional command interface #46
Conversation
This is ready for review! Finally, it took almost a year to get this ready. We can build more features on top of this, but it should be a good foundation, and all the conceptual problems are solved now, I would say. I think currently the I added @hpk42 to the Admin Group of x.testrun.org for now; if anyone else wants to be a part of this group to try it out, write me. If you want to try out the |
doc/index.rst
Outdated
You don't have to login with SSH every time you want to create tokens. You can | ||
also use the bot interface to talk to the bot in a verified Delta group. The | ||
bot needs an e-mail account to operate - it doesn't have to be on your mailcow | ||
server, it can be any e-mail account which also works with Delta Chat. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't have to login with SSH every time you want to create tokens. You can | |
also use the bot interface to talk to the bot in a verified Delta group. The | |
bot needs an e-mail account to operate - it doesn't have to be on your mailcow | |
server, it can be any e-mail account which also works with Delta Chat. | |
You don't have to login with SSH or user docker commands every time you want to create tokens. You can rather setup a dedicated bot e-mail address and bootstrap a verified "admin group chat", in order to add/remove/list tokens for e-mail account creation. The bot's e-mail address can be any e-mail address and does not need to reside on the e-mail domain whose accounts it is managing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, not sure about that wording, but I rephrased it a bit along those lines. As it always is with writing, too many cooks...
src/mailadm/bot.py
Outdated
|
||
@account_hookimpl | ||
def ac_member_added(self, chat: deltachat.Chat, contact, actor, message): | ||
assert chat.num_contacts() == 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not robust enough i think: if for some reason a second person tries to join the admin group, then the event-thread will error and probably die, and become dysfunctional. If "chat.num_contacts() > 2" then a message should be send to the admin chat that there was a failed attempt at joining another address (and telling about the precise e-mail address which tried to join).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, this hook is only used during setup-bot
so we can wait until the user actually joined the group. So we actually want to check that exactly one person joined so far, because that means the script worked. But we want more users to join later, so it's not really something we would warn about.
It doesn't raise an exception anymore though.
mail_domain = rconn.config.mail_domain | ||
admingrpid_old = rconn.config.admingrpid | ||
|
||
chat = ac.create_group_chat("Admin group on {}".format(mail_domain), contacts=[], verified=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chat = ac.create_group_chat("Admin group on {}".format(mail_domain), contacts=[], verified=True) | |
chat = ac.create_group_chat("AAdmins {}".format(mail_domain), contacts=[], verified=True) |
"Account Admins" :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm, not a fan^^ I mean, users can rename it as they want, but I called it an admin group to make obvious what it's for...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks good to me, only a few remarks.
I'd prefer if there were also some unit tests for some of the functions in commands.py and bot.py but that's not a blocker.
If you are fine with my latest additions, just merge it :) |
src/mailadm/bot.py
Outdated
while not contact.is_verified(): | ||
time.sleep(0.1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this neccessary? Because "member added can now happen before verification is complete"? That sounds wrong, though. A member can only be added to a verified group if it is verified. I'd consider this a bug and this is a dangerous work-around which can block the "event execution" overall for the bot if the contact ends up not getting verified (because of lost messages etc.). If anything, then "for i in range(500): if contact.is_verified(): break else: time.sleep(...)" to limit the hanging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, the reason is that sometimes the welcome message arrives at the user before the "verification complete" message arrives - this makes the welcome message unreadable to the user, as it is sent by an unverified contact to a verified group. This was ugly, and this small loop should ensure that the welcome message is at least sent after the last verification roundtrip message.
I will take it out for now, as it shouldn't be a blocker for this PR. Maybe delaying the welcome message 5 seconds would help.
This reverts commit 6bb1a67.
Context: #36
basically #23, but rebased on master and with some more progress.
Overview over the changes:
mailadm setup-bot
command to initialize the admin groupadd-token
,add-user
,list-tokens
, andprune
logic from cmdline.py to commands.pyTo do:
install_mailadm.sh
&uninstall_mailadm.sh
on master and rebase afterwards: remove old install & uninstall scripts #47MAILADM_HOME
to pytest" - not sure why I even did thatmailadm setup-bot