From 41c092f578c6fdd5e609c0d117c67ee8714f43f2 Mon Sep 17 00:00:00 2001 From: Harvey Tindall Date: Thu, 7 Sep 2023 20:19:25 +0100 Subject: [PATCH] referrals: show referrer username on form --- html/form.html | 9 ++++++--- lang/form/en-us.json | 5 +++-- views.go | 9 +++++++++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/html/form.html b/html/form.html index 6bd2638..787cdb0 100644 --- a/html/form.html +++ b/html/form.html @@ -43,7 +43,7 @@
-
+
{{ if .passwordReset }} {{ .strings.passwordReset }} @@ -53,11 +53,14 @@ {{ if .passwordReset }} - {{ .strings.enterYourPassword }} + {{ .strings.enterYourPassword }} {{ else }} - {{ .helpMessage }} + {{ .helpMessage }} {{ end }} + {{ if .fromUser }} + {{ .strings.invitedBy }} {{ .fromUser }} + {{ end }}
diff --git a/lang/form/en-us.json b/lang/form/en-us.json index e89aaf5..14f7acf 100644 --- a/lang/form/en-us.json +++ b/lang/form/en-us.json @@ -36,7 +36,8 @@ "resetSentDescription": "If an account with the given username/contact method exists, a password reset link has been sent via all contact methods available. The code will expire in 30 minutes.", "changePassword": "Change Password", "referralsDescription": "Invite friends & family to Jellyfin with this link. Come back here for a new one if it expires.", - "copyReferral": "Copy Link" + "copyReferral": "Copy Link", + "invitedBy": "Invited By" }, "notifications": { "errorUserExists": "User already exists.", @@ -78,4 +79,4 @@ "plural": "Must have at least {n} special characters" } } -} \ No newline at end of file +} diff --git a/views.go b/views.go index 2d311ec..704a35d 100644 --- a/views.go +++ b/views.go @@ -619,6 +619,14 @@ func (app *appContext) InviteProxy(gc *gin.Context) { } userPageAddress += "/my/account" + fromUser := "" + if inv.ReferrerJellyfinID != "" { + sender, status, err := app.jf.UserByID(inv.ReferrerJellyfinID, false) + if status == 200 && err == nil { + fromUser = sender.Name + } + } + data := gin.H{ "urlBase": app.getURLBase(gc), "cssClass": app.cssClass, @@ -654,6 +662,7 @@ func (app *appContext) InviteProxy(gc *gin.Context) { "reCAPTCHASiteKey": app.config.Section("captcha").Key("recaptcha_site_key").MustString(""), "userPageEnabled": app.config.Section("user_page").Key("enabled").MustBool(false), "userPageAddress": userPageAddress, + "fromUser": fromUser, } if telegram { data["telegramPIN"] = app.telegram.NewAuthToken()