diff --git a/api-messages.go b/api-messages.go index e4b60e7..a78ab85 100644 --- a/api-messages.go +++ b/api-messages.go @@ -39,6 +39,7 @@ func (app *appContext) GetCustomContent(gc *gin.Context) { "UserExpired": {Name: app.storage.lang.Email[lang].UserExpired["name"], Enabled: app.storage.MustGetCustomContentKey("UserExpired").Enabled}, "UserLogin": {Name: app.storage.lang.Admin[adminLang].Strings["userPageLogin"], Enabled: app.storage.MustGetCustomContentKey("UserLogin").Enabled}, "UserPage": {Name: app.storage.lang.Admin[adminLang].Strings["userPagePage"], Enabled: app.storage.MustGetCustomContentKey("UserPage").Enabled}, + "PostSignupCard": {Name: app.storage.lang.Admin[adminLang].Strings["postSignupCard"], Enabled: app.storage.MustGetCustomContentKey("PostSignupCard").Enabled, Description: app.storage.lang.Admin[adminLang].Strings["postSignupCardDescription"]}, } filter := gc.Query("filter") @@ -145,7 +146,11 @@ func (app *appContext) GetCustomMessageTemplate(gc *gin.Context) { } else if id == "UserLogin" { variables = []string{} customMessage.Variables = variables + } else if id == "PostSignupCard" { + variables = []string{"{username}", "{myAccountURL}"} + customMessage.Variables = variables } + content = customMessage.Content noContent := content == "" if !noContent { @@ -210,14 +215,14 @@ func (app *appContext) GetCustomMessageTemplate(gc *gin.Context) { msg, err = app.email.constructUserExpired(app, true) } values = app.email.userExpiredValues(app, false) - case "UserLogin", "UserPage": + case "UserLogin", "UserPage", "PostSignupCard": values = map[string]interface{}{} } if err != nil { respondBool(500, false, gc) return } - if noContent && id != "Announcement" && id != "UserPage" && id != "UserLogin" { + if noContent && id != "Announcement" && id != "UserPage" && id != "UserLogin" && id != "PostSignupCard" { content = msg.Text variables = make([]string, strings.Count(content, "{")) i := 0 @@ -243,17 +248,32 @@ func (app *appContext) GetCustomMessageTemplate(gc *gin.Context) { } app.storage.SetCustomContentKey(id, customMessage) var mail *Message - if id != "UserLogin" && id != "UserPage" { + if id != "UserLogin" && id != "UserPage" && id != "PostSignupCard" { mail, err = app.email.constructTemplate("", "
", app) if err != nil { respondBool(500, false, gc) return } + } else if id == "PostSignupCard" { + // Jankiness follows. + // Source content from "Success Message" setting. + if noContent { + content = "# " + app.storage.lang.User[app.storage.lang.chosenUserLang].Strings.get("successHeader") + "\n" + app.config.Section("ui").Key("success_message").String() + if app.config.Section("user_page").Key("enabled").MustBool(false) { + content += "\n\n
\n" + app.storage.lang.User[app.storage.lang.chosenUserLang].Strings.template("userPageSuccessMessage", tmpl{ + "myAccount": "[" + app.storage.lang.User[app.storage.lang.chosenUserLang].Strings.get("myAccount") + "]({myAccountURL})", + }) + } + } + mail = &Message{ + HTML: "

", + } + mail.Markdown = mail.HTML } else { mail = &Message{ - HTML: "
", - Markdown: "
", + HTML: "
", } + mail.Markdown = mail.HTML } gc.JSON(200, customEmailDTO{Content: content, Variables: variables, Conditionals: conditionals, Values: values, HTML: mail.HTML, Plaintext: mail.Text}) } diff --git a/config/config-base.json b/config/config-base.json index dfd5114..1b3bdd2 100644 --- a/config/config-base.json +++ b/config/config-base.json @@ -247,7 +247,7 @@ "requires_restart": false, "type": "text", "value": "Your account has been created. Click below to continue to Jellyfin.", - "description": "Displayed when a user creates an account" + "description": "Displayed when a user creates an account. Use the \"post-signup card\" in the Message editor for more control." }, "url_base": { "name": "Reverse Proxy subfolder", @@ -273,7 +273,7 @@ "type": "bool", "value": false, "advanced": true, - "description": "Navigate directly to the above URL instead of needing the user to click \"Continue\"." + "description": "Navigate directly to the above URL instead of needing the user to click \"Continue\". Overrides the post-signup card." }, "login_appearance": { "name": "Login screen appearance", @@ -702,7 +702,7 @@ "description": "Allow users to start a Password Reset by inputting their Discord/Telegram/Matrix username/id." }, "pwr_note": { - "name": "PWR Methods", + "name": "PWR Methods:", "type": "note", "depends_true": "enabled", "value": "", diff --git a/html/admin.html b/html/admin.html index b98bf6d..1dc3ad9 100644 --- a/html/admin.html +++ b/html/admin.html @@ -297,6 +297,7 @@ ×
+ {{ .strings.variables }}
{{ .strings.conditionals }} diff --git a/html/form-base.html b/html/form-base.html index 7f46a30..f25bb2e 100644 --- a/html/form-base.html +++ b/html/form-base.html @@ -31,6 +31,11 @@ window.reCAPTCHASiteKey = "{{ .reCAPTCHASiteKey }}"; window.userPageEnabled = {{ .userPageEnabled }}; window.userPageAddress = "{{ .userPageAddress }}"; + {{ if index . "customSuccessCard" }} + window.customSuccessCard = {{ .customSuccessCard }}; + {{ else }} + window.customSuccessCard = false; + {{ end }} {{ if .passwordReset }} diff --git a/html/form.html b/html/form.html index fbeecbe..6927e93 100644 --- a/html/form.html +++ b/html/form.html @@ -14,12 +14,19 @@