Skip to content

Conversation

@PythonGermany
Copy link
Contributor

@PythonGermany PythonGermany commented Dec 22, 2025

Summary

Closes #1464

Checklist

  • Check for outstanding TODO#1464 or TODO#1468 in code
  • Tested and/or added tests to validate that the changes work as intended, if applicable.
  • Updated documentation in README.md, if applicable.

@github-actions github-actions bot added feature New feature or request area/alerting Related to alerting labels Dec 22, 2025
@PythonGermany PythonGermany force-pushed the add-threema-gateway-alert-provider branch 5 times, most recently from 5004226 to c2d9183 Compare December 22, 2025 21:41
Comment on lines 80 to 123
type RecipientType int // TODO#1464: Maybe move to separate file in package to keep things organized

const (
RecipientTypeInvalid RecipientType = iota
RecipientTypeId
RecipientTypePhone
RecipientTypeEmail
)

func parseRecipientType(s string) RecipientType {
if val, ok := validRecipientTypes[s]; ok {
return val
}
return RecipientTypeInvalid
}

type Recipient struct {
Value string `yaml:"-"`
Type RecipientType `yaml:"-"`
}

var _ encoding.TextUnmarshaler = (*Recipient)(nil)
var _ encoding.TextMarshaler = (*Recipient)(nil)

func (r *Recipient) UnmarshalText(text []byte) error {
parts := strings.Split(string(text), ":")
switch {
case len(parts) > 2:
return ErrInvalidRecipientFormat
case len(parts) == 2:
if r.Type = parseRecipientType(parts[0]); r.Type == RecipientTypeInvalid {
return ErrInvalidRecipientType
}
r.Value = parts[1]
default:
r.Type = defaultRecipientType
r.Value = parts[0]
}
return nil
}

func (r Recipient) MarshalText() ([]byte, error) {
return []byte(r.Value), nil
}
Copy link
Contributor Author

@PythonGermany PythonGermany Dec 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not seen a solution to preprocess/parse string values from the yaml config like this anywhere else in the repo. This new provider was a good playground to test it out.

I think applied to the condition system it could improve code quality (and maybe performance, I have not enough experience with go to know how much) significantly, because then parsing of the condition and runtime evaluation would be completely separated.

@TwiN What do you think about my approach?

@PythonGermany PythonGermany force-pushed the add-threema-gateway-alert-provider branch from c2d9183 to 40dea85 Compare December 22, 2025 22:38
@PythonGermany PythonGermany force-pushed the add-threema-gateway-alert-provider branch from 40dea85 to acafd93 Compare December 22, 2025 23:09
@PythonGermany PythonGermany force-pushed the add-threema-gateway-alert-provider branch from 91dadb9 to fbef1ac Compare December 23, 2025 18:05
@PythonGermany PythonGermany changed the title feat(alerting): Add support for Threema Gateway as an alerting provider feat(alerting): Add support for Threema Gateway as an alerting provider (basic mode) Dec 23, 2025
@PythonGermany
Copy link
Contributor Author

I have requested a Gateway ID from Threema. Once I have a working Gateway I will be able to test the alert provider against their API and once the tests are successful this PR will be ready.

@PythonGermany PythonGermany force-pushed the add-threema-gateway-alert-provider branch from 5697f3c to b36b2e3 Compare December 25, 2025 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/alerting Related to alerting feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(alerting): Add basic support for Threema Gateway as an alerting provider

1 participant