Files
3f5b3cdd98 feat: add configurable SMTP HELO hostname (#2146)
* feat: add configurable SMTP HELO hostname

Allow the SMTP HELO/EHLO hostname to be configured separately from
the SMTP server hostname.

This is useful when the SMTP server requires clients to identify
themselves with a fully qualified hostname different from the server
address.

* chore: remove vendored dependency changes

* Bump go-pkgz/notify to v1.4.0 and document SMTP_HELO_HOST

The HELOHost field lands in go-pkgz/notify v1.4.0, so the branch needs the
bump to compile; v1.3.0 in master has no such field. The example module is
tidied alongside, as any change to backend/go.mod requires.

Documents the parameter in the parameters table and, separately, in the email
setup page: what it does, that leaving it unset keeps the previous `localhost`
greeting, and the case it exists for, a relay refusing the greeting under
Postfix `reject_non_fqdn_helo_hostname`.

Also records the current limit: verification emails for email authentication
go through go-pkgz/auth's own sender, which has no equivalent setting, so the
greeting there is unchanged.

* Bump go-pkgz/auth to v2.2.0 and apply SMTP_HELO_HOST to verification email

The verification email sender had no way to set the greeting, so a relay that
refuses the HELO would accept notifications and still reject sign-in emails.
EmailParams gains HELOHost in go-pkgz/auth v2.2.0, so the same SMTP_HELO_HOST
now drives both paths.

The example module is tidied alongside, as any change to backend/go.mod
requires.

---------

Co-authored-by: oli <someone@somewhere.tld>
Co-authored-by: Dmitry Verkhoturov <paskal.07@gmail.com>
2026-08-19 02:52:39 -05:00

73 lines
1.8 KiB
Go

package stats
// ArgMax finds the index of the highest number in a slice,
// returning the first occurrence in the case of ties
func ArgMax(input Float64Data) (int, error) {
// Return an error if there are no numbers
if input.Len() == 0 {
return -1, ErrEmptyInput
}
// Track the index of the highest value seen so far
index := 0
// Loop and replace with strictly higher values only,
// which keeps the first occurrence on ties
for i := 1; i < input.Len(); i++ {
if input.Get(i) > input.Get(index) {
index = i
}
}
return index, nil
}
// ArgMin finds the index of the lowest number in a slice,
// returning the first occurrence in the case of ties
func ArgMin(input Float64Data) (int, error) {
// Return an error if there are no numbers
if input.Len() == 0 {
return -1, ErrEmptyInput
}
// Track the index of the lowest value seen so far
index := 0
// Loop and replace with strictly lower values only,
// which keeps the first occurrence on ties
for i := 1; i < input.Len(); i++ {
if input.Get(i) < input.Get(index) {
index = i
}
}
return index, nil
}
// Range finds the difference between the highest and
// lowest numbers in a slice
func Range(input Float64Data) (float64, error) {
// Return an error if there are no numbers
max, err := Max(input)
if err != nil {
return max, ErrEmptyInput
}
// Disregard error, since Max would have already returned it
min, _ := Min(input)
return max - min, nil
}
// ArgMax returns the index of the highest number in the data
func (f Float64Data) ArgMax() (int, error) { return ArgMax(f) }
// ArgMin returns the index of the lowest number in the data
func (f Float64Data) ArgMin() (int, error) { return ArgMin(f) }
// Range returns the difference between the highest and lowest numbers in the data
func (f Float64Data) Range() (float64, error) { return Range(f) }