Commit Graph

18 Commits

Author SHA1 Message Date
Aine
f97ebb604a manage users in runtime, closes #16 2022-08-29 21:41:14 +03:00
Aine
5a5a649cba add cache 2022-08-29 15:28:37 +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
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
bd14987561 move settings.Allowed() to bot.Allowed() 2022-08-28 18:36:01 +03:00
Slavi Pantaleev
dc5ed41723 Merge branch 'main' into 'user-whitelisting'
# Conflicts:
#   bot/bot.go
2022-08-28 14:50:57 +00:00
Aine
6eae1a65c4 add utils.UnwrapError() to provide meaningful error messages 2022-08-27 22:38:23 +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
Aine
2dcba843cc add 'nofiles' option, refactored bot.Send(); fixes #2 2022-08-26 16:11:08 +03:00
Aine
42c9e15619 add 'nothreads' option, fixes #4 2022-08-26 16:00:37 +03:00
Aine
41a52c1eca add 'nohtml' option, fixes #5 2022-08-26 15:56:25 +03:00
Aine
b0c274491f refactor to context, remove sentry spans 2022-08-25 22:31:12 +03:00
Slavi Pantaleev
8507af670a exists -> ok 2022-08-25 21:44:06 +03:00
Aine
f9cf94c914 threads 2022-08-24 21:28:30 +03:00