Commit Graph
135 Commits
Author SHA1 Message Date
Aine 050b8f890b Merge branch 'botconfig' into 'main'
manage users in runtime

Closes #16

See merge request etke.cc/postmoogle!24
2022-08-30 16:37:13 +00:00
Aine 233d212143 fix botSettings.Users() 2022-08-30 18:35:10 +03:00
Aine 84b1900dbb adjust initBotUsers() 2022-08-30 18:29:16 +03:00
Aine 0c74ae02fb fix one value 2022-08-30 16:13:10 +03:00
Aine cec2761911 users adjustments 2022-08-30 15:43:06 +03:00
Aine ea1ef9da7f !pm users changes 2022-08-30 15:00:34 +03:00
Aine 00b84fba0e cache even unexisting bot settings 2022-08-30 14:47:16 +03:00
Aine 9f66d1fee6 rename options, rename settings types 2022-08-30 14:45:07 +03:00
Aine 627e090afd rename account data keys, rearrange code 2022-08-30 14:42:07 +03:00
Aine 5ed3a53223 diff bot and room settings 2022-08-30 14:37:19 +03:00
Aine f97ebb604a manage users in runtime, closes #16 2022-08-29 21:41:14 +03:00
Aine 0ba951fbe6 set default POSTMOOGLE_USERS pattern 2022-08-29 20:56:28 +03:00
Aine 74e7fa5f3b update README, closes #11 2022-08-29 20:40:52 +03:00
Aine 89d5ec8a91 adjust !pm mailboxes, relates to #15 2022-08-29 20:31:25 +03:00
Aine e0bd71717c remove NOOWNER, closes #14 2022-08-29 20:21:37 +03:00
Aine ba73b5a97c add !pm delete, closes #13 2022-08-29 20:18:25 +03:00
Aine 505a1b42d7 removed federation, closes #12 2022-08-29 19:58:54 +03:00
Aine e52de55e1a update readme 2022-08-29 17:47:04 +03:00
Aine d59ab94b13 Merge branch 'admin-support' into 'main'
Initial work on admin commands support

See merge request etke.cc/postmoogle!22
2022-08-29 14:45:27 +00:00
Aine 064346eef9 Merge branch 'main' into admin-support 2022-08-29 15:48:10 +03:00
Aine 5a5a649cba add cache 2022-08-29 15:28:37 +03:00
Aine 1a87929567 rename files; show commands by access level 2022-08-29 15:19:07 +03:00
Slavi Pantaleev bc30f59e96 Move owner commands to their own file 2022-08-29 14:25:14 +03:00
Slavi Pantaleev d20d4aa5bf Move mailboxes admin command to a separate file 2022-08-29 14:20:20 +03:00
Slavi Pantaleev e59f5d5502 Make Match() with empty list not return a positive result
Now that we use Match() in allowAdmin() as well, it's awkward to
have it return `true` when called with an empty admin list.
No admins defined was taken to mean "everyone is an admin".

We can either have a `len(users) == 0` check in `allowAdmin` which
rejects the request, or we can change `Match()` so that it doesn't
return positive responses when called with an empty list. Doing the
latter sounds better. It's more natural that matching against an empty list
will yield "no match".
2022-08-29 14:10:52 +03:00
Aine 6623251695 refactored 2022-08-29 12:30:43 +03:00
Aine ba2596afa2 Merge branch 'fix-double-domain' into 'main'
Do not append domain twice when updating mailbox

See merge request etke.cc/postmoogle!23
2022-08-29 08:08:30 +00:00
Slavi Pantaleev 97a4d6c7bc Do not append @domain twice when updating mailbox
Fixes a regression introduced in 13776ad7
2022-08-29 10:46:59 +03:00
Slavi Pantaleev 79775c0c13 Add basic mailboxes command
This can be improved in the future, to show some additional information
about each mailbox like:

- "how many users are in that room"
- "which users are in that room"
- "who is the owner of the mailbox"

This can all be done later though.
2022-08-29 10:28:19 +03:00
Slavi Pantaleev a057654962 Put command access checks on the command level
Checking using `settings.Allowed` is odd. Not all commands are related
to setting configuration settings. Admin commands are coming in the
future, for which this is certainly not the case.

We now do access checks early on (during command processing), so command
handlers can be clean of access checks. If we're inside of a command
handler, the user is privileged to run it.
2022-08-29 10:27:53 +03:00
Slavi Pantaleev a62dc0df4f Add POSTMOOGLE_ADMINS 2022-08-29 09:10:31 +03:00
Aine 77a7e9efc6 Merge branch 'show-option-value-in-help' into 'main'
Show option values in help

See merge request etke.cc/postmoogle!21
2022-08-28 15:37:29 +00:00
Aine 2397075717 Merge branch 'user-whitelisting' into 'main'
Add support for configuring user whitelisting

See merge request etke.cc/postmoogle!20
2022-08-28 15:36:53 +00:00
Aine bd14987561 move settings.Allowed() to bot.Allowed() 2022-08-28 18:36:01 +03:00
Slavi Pantaleev 1d6b43a83a Reindent bot/bot.go 2022-08-28 17:56:19 +03:00
Slavi Pantaleev dc5ed41723 Merge branch 'main' into 'user-whitelisting'
# Conflicts:
#   bot/bot.go
2022-08-28 14:50:57 +00:00
Aine 3174b21aec [skip ci] update readme 2022-08-28 17:35:53 +03:00
Aine a150ada5c4 [skip ci] update readme 2022-08-28 17:35:15 +03:00
Aine 67fbc98c01 [skip ci] update readme 2022-08-28 17:34:02 +03:00
Aine 0e33107a4a add usage section in readme 2022-08-28 17:18:22 +03:00
Aine 9b1eb161e7 remove debug 2022-08-28 09:37:32 +03:00
Aine 13776ad7a6 properly update mailbox, fixes #9 2022-08-28 09:37:18 +03:00
Aine 6eae1a65c4 add utils.UnwrapError() to provide meaningful error messages 2022-08-27 22:38:23 +03:00
Aine d1c48b9b31 add per-room mutex, possibly fixes #8 2022-08-27 22:10:22 +03:00
Aine 53bc5e6d59 proposed changes 2022-08-27 21:59:58 +03:00
Slavi Pantaleev c8331e9958 Get rid of various duplicated optionMailbox formatting
`formatOptionValue` takes care of these now.

Besides fixing the duplication, this also fixes the lint error
affecting `sendHelp` - high complexity.
2022-08-27 19:35:45 +03:00
Slavi Pantaleev 972b4c11c5 Do not call getSettings() for each option in help
Retrieving the settings object for each and every option was wasteful

I don't like how we're doing custom formatting for optionMailbox in many
different places. This should be redone.
2022-08-27 19:22:21 +03:00
Slavi Pantaleev 0d88de9f77 Show option values in help
Before:

> * **`!pm help`** - Show this help message
> * **`!pm stop`** - Disable bridge for the room and clear all configuration
> * **`!pm mailbox`** - Get or set mailbox of the room
> * **`!pm owner`** - Get or set owner of the room
> * **`!pm nosender`** - Get or set `nosender` of the room (`true` - hide email sender; `false` - show email sender)
> * **`!pm nosubject`** - Get or set `nosubject` of the room (`true` - hide email subject; `false` - show email subject)
> * **`!pm nohtml`** - Get or set `nohtml` of the room (`true` - ignore HTML in email; `false` - parse HTML in emails)
> * **`!pm nothreads`** - Get or set `nothreads` of the room (`true` - ignore email threads; `false` - convert email threads into matrix threads)
> * **`!pm nofiles`** - Get or set `nofiles` of the room (`true` - ignore email attachments; `false` - upload email attachments

After:

> * **`!pm help`** - Show this help message
> * **`!pm stop`** - Disable bridge for the room and clear all configuration
> * **`!pm mailbox`** (currently `something@example.com`) - Get or set mailbox of the room
> * **`!pm owner`** (currently `@someone:example.com`) - Get or set owner of the room
> * **`!pm nosender`** (currently `false`) - Get or set `nosender` of the room (`true` - hide email sender; `false` - show email sender)
> * **`!pm nosubject`** (currently `true`) - Get or set `nosubject` of the room (`true` - hide email subject; `false` - show email subject)
> * **`!pm nohtml`** (currently `false`) - Get or set `nohtml` of the room (`true` - ignore HTML in email; `false` - parse HTML in emails)
> * **`!pm nothreads`** (currently `false`) - Get or set `nothreads` of the room (`true` - ignore email threads; `false` - convert email threads into matrix threads)
> * **`!pm nofiles`** (currently `false`) - Get or set `nofiles` of the room (`true` - ignore email attachments; `false` - upload email attachments)
2022-08-27 17:47:16 +03:00
Slavi Pantaleev 3bc10bfe4f Honor allowed users list 2022-08-27 17:29:00 +03:00
Slavi Pantaleev 275ccbd9e5 Implement feedback 2022-08-27 08:11:36 +03:00