added DEFAULT_SIGNAL_TEXT_MODE env variable

* allows to set the default text mode globally.
  The setting is only used when the 'text_mode' is not
  explicitly set in the payload.

see #671
This commit is contained in:
Bernhard B
2025-03-20 22:14:40 +01:00
parent c26c6d8587
commit a30c63f1b1
2 changed files with 12 additions and 1 deletions

View File

@@ -145,3 +145,5 @@ There are a bunch of environmental variables that can be set inside the docker c
* `SWAGGER_USE_HTTPS_AS_PREFERRED_SCHEME`: Use the HTTPS Scheme as preferred scheme in the Swagger UI.
* `PORT`: Defaults to port `8080` unless this env var is set to tell it otherwise.
* `DEFAULT_SIGNAL_TEXT_MODE`: Allows to set the default text mode that should be used when sending a message (supported values: `normal`, `styled`). The setting is only used in case the `text_mode` is not explicitly set in the payload of the `send` method.

View File

@@ -437,10 +437,19 @@ func (a *Api) SendV2(c *gin.Context) {
return
}
textMode := req.TextMode
if textMode == nil {
defaultSignalTextMode := utils.GetEnv("DEFAULT_SIGNAL_TEXT_MODE", "normal")
if defaultSignalTextMode == "styled" {
styledStr := "styled"
textMode = &styledStr
}
}
data, err := a.signalClient.SendV2(
req.Number, req.Message, req.Recipients, req.Base64Attachments, req.Sticker,
req.Mentions, req.QuoteTimestamp, req.QuoteAuthor, req.QuoteMessage, req.QuoteMentions,
req.TextMode, req.EditTimestamp, req.NotifySelf)
textMode, req.EditTimestamp, req.NotifySelf)
if err != nil {
switch err.(type) {
case *client.RateLimitErrorType: