MCPcopy Create free account
hub / github.com/PatchMon/PatchMon / newsletterDisplayName

Function newsletterDisplayName

server-source-code/internal/handler/auth.go:991–1008  ·  view source on GitHub ↗

newsletterDisplayName builds the name passed to Listmonk: trimmed "first last" if either is set, otherwise the local-part of the email.

(u *models.User)

Source from the content-addressed store, hash-verified

989// newsletterDisplayName builds the name passed to Listmonk: trimmed
990// "first last" if either is set, otherwise the local-part of the email.
991func 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

Callers 2

SubscribeNewsletterMethod · 0.85
AutoSubscribeIfHostedFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected