Skip to content

Commit

Permalink
move message_format config option below message
Browse files Browse the repository at this point in the history
Keep related options next to each other.
  • Loading branch information
jkhsjdhjs committed Jan 19, 2024
1 parent 9f16829 commit 552ad61
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ The message that is sent when the webhook is triggered.
Supports formatting [as defined below](#formatting).


### `message_format`
The format the message is interpreted as. Must be one of:
- `plaintext` (default)
- `markdown`
- `html`


### `auth_type`
This can be used to protect a webhook against unauthorized access.
Can be one of `Basic` for HTTP basic auth with username and password or `Bearer` for bearer token auth.
Expand All @@ -108,13 +115,6 @@ If `auth_type` is `Basic`, this must be the username and password, separated by
If `auth_type` is `Bearer`, this is the token used for token bearer authorization, so requests must carry an `Authorization: Bearer <token>` header.


### `message_format`
The format the message is interpreted as. Must be one of:
- `plaintext` (default)
- `markdown`
- `html`


### `force_json`
This setting takes a boolean and specifies whether the request body should be interpreted and parsed as json, even if the content type says otherwise.

Expand Down
2 changes: 1 addition & 1 deletion base-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ path: "/send"
method: "POST"
room: "!AAAAAAAAAAAAAAAAAA:example.com"
message: "Hello world!"
message_format: "plaintext"
auth_type:
auth_token:
message_format: "plaintext"
force_json: false
ignore_empty_messages: false
14 changes: 7 additions & 7 deletions plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ def do_update(self, helper: ConfigUpdateHelper) -> None:
# validate base config as it also contains default values
# for options not present in the source config.

# validate message_format
valid_message_formats = {"markdown", "plaintext", "html"}
message_format = helper.base["message_format"]
if message_format not in valid_message_formats:
raise ValueError(f"Invalid message_format '{message_format}' specified! "
f"Must be one of: {', '.join(valid_message_formats)}")

# validate auth_type and auth_token
valid_auth_types = {"Basic", "Bearer"}
auth_type = helper.base["auth_type"]
Expand All @@ -71,13 +78,6 @@ def do_update(self, helper: ConfigUpdateHelper) -> None:
raise ValueError(f"Invalid auth_token '{auth_token}' specified! For HTTP basic auth, it must contain "
"a username and a password, separated by a colon (<username>:<password>).")

# validate message_format
valid_message_formats = {"markdown", "plaintext", "html"}
message_format = helper.base["message_format"]
if message_format not in valid_message_formats:
raise ValueError(f"Invalid message_format '{message_format}' specified! "
f"Must be one of: {', '.join(valid_message_formats)}")


class WebhookPlugin(Plugin):

Expand Down

0 comments on commit 552ad61

Please sign in to comment.