newsletterDisplayName builds the name passed to Listmonk: trimmed "first last" if either is set, otherwise the local-part of the email.
(u *models.User)
| 989 | // newsletterDisplayName builds the name passed to Listmonk: trimmed |
| 990 | // "first last" if either is set, otherwise the local-part of the email. |
| 991 | func newsletterDisplayName(u *models.User) string { |
| 992 | first := "" |
| 993 | last := "" |
| 994 | if u.FirstName != nil { |
| 995 | first = strings.TrimSpace(*u.FirstName) |
| 996 | } |
| 997 | if u.LastName != nil { |
| 998 | last = strings.TrimSpace(*u.LastName) |
| 999 | } |
| 1000 | combined := strings.TrimSpace(first + " " + last) |
| 1001 | if combined != "" { |
| 1002 | return combined |
| 1003 | } |
| 1004 | if at := strings.IndexByte(u.Email, '@'); at > 0 { |
| 1005 | return u.Email[:at] |
| 1006 | } |
| 1007 | return u.Email |
| 1008 | } |
| 1009 | |
| 1010 | // SubscribeNewsletter handles POST /auth/subscribe-newsletter. |
| 1011 | // Subscribes the authenticated user to the marketing newsletter via the public |
no outgoing calls
no test coverage detected