From 0b830e9b5e3ac36f4846fb6fe68fc6736631849c Mon Sep 17 00:00:00 2001 From: Harvey Tindall Date: Thu, 7 Sep 2023 14:31:42 +0100 Subject: [PATCH] referrals: enable for new users from profile --- api-users.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/api-users.go b/api-users.go index 50fd259..7adc77d 100644 --- a/api-users.go +++ b/api-users.go @@ -304,6 +304,12 @@ func (app *appContext) newUser(req newUserDTO, confirmed bool) (f errorFunc, suc } } id := user.ID + + emailStore := EmailAddress{ + Addr: req.Email, + Contact: (req.Email != ""), + } + var profile Profile if invite.Profile != "" { app.debug.Printf("Applying settings from profile \"%s\"", invite.Profile) @@ -325,10 +331,15 @@ func (app *appContext) newUser(req newUserDTO, confirmed bool) (f errorFunc, suc if !((status == 200 || status == 204) && err == nil) { app.err.Printf("%s: Failed to set configuration template (%d): %v", req.Code, status, err) } + if app.config.Section("user_page").Key("enabled").MustBool(false) && app.config.Section("user_page").Key("referrals").MustBool(false) && profile.ReferralTemplateKey != "" { + emailStore.ReferralTemplateKey = profile.ReferralTemplateKey + // Store here, just incase email are disabled (whether this is even possible, i don't know) + app.storage.SetEmailsKey(id, emailStore) + } } // if app.config.Section("password_resets").Key("enabled").MustBool(false) { if req.Email != "" { - app.storage.SetEmailsKey(id, EmailAddress{Addr: req.Email, Contact: true}) + app.storage.SetEmailsKey(id, emailStore) } expiry := time.Time{} if invite.UserExpiry {