mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-12-22 09:00:10 +00:00
userpage: generate & display referral links
shown on a new card, with an explanation, the number of remaining uses, and expiry of the current referral.
This commit is contained in:
parent
0a82f889f3
commit
311ecb7030
@ -14,7 +14,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
REFERRAL_EXPIRY_DAYS = 365
|
||||
REFERRAL_EXPIRY_DAYS = 90
|
||||
)
|
||||
|
||||
// @Summary Returns the logged-in user's Jellyfin ID & Username, and other details.
|
||||
@ -81,6 +81,25 @@ func (app *appContext) MyDetails(gc *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
if app.config.Section("user_page").Key("referrals").MustBool(false) {
|
||||
// 1. Look for existing template bound to this Jellyfin ID
|
||||
// If one exists, that means its just for us and so we
|
||||
// can use it directly.
|
||||
inv := Invite{}
|
||||
err := app.storage.db.FindOne(&inv, badgerhold.Where("ReferrerJellyfinID").Eq(resp.Id))
|
||||
if err == nil {
|
||||
resp.HasReferrals = true
|
||||
} else {
|
||||
// 2. Look for a template matching the key found in the user storage
|
||||
// Since this key is shared between users in a profile, we make a copy.
|
||||
user, ok := app.storage.GetEmailsKey(gc.GetString("jfId"))
|
||||
err = app.storage.db.Get(user.ReferralTemplateKey, &inv)
|
||||
if ok && err == nil {
|
||||
resp.HasReferrals = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gc.JSON(200, resp)
|
||||
}
|
||||
|
||||
@ -685,6 +704,6 @@ func (app *appContext) GetMyReferral(gc *gin.Context) {
|
||||
Code: inv.Code,
|
||||
RemainingUses: inv.RemainingUses,
|
||||
NoLimit: inv.NoLimit,
|
||||
Expiry: inv.ValidTill,
|
||||
Expiry: inv.ValidTill.Unix(),
|
||||
})
|
||||
}
|
||||
|
@ -24,6 +24,7 @@
|
||||
window.matrixRequired = {{ .matrixRequired }};
|
||||
window.matrixUserID = "{{ .matrixUser }}";
|
||||
window.validationStrings = JSON.parse({{ .validationStrings }});
|
||||
window.referralsEnabled = {{ .referralsEnabled }};
|
||||
</script>
|
||||
{{ template "header.html" . }}
|
||||
<title>{{ .strings.myAccount }}</title>
|
||||
@ -150,6 +151,20 @@
|
||||
<div class="user-expiry-countdown"></div>
|
||||
</div>
|
||||
</div>
|
||||
{{ if .referralsEnabled }}
|
||||
<div>
|
||||
<div class="card @low dark:~d_neutral unfocused" id="card-referrals">
|
||||
<span class="heading mb-2">{{ .strings.referrals }}</span>
|
||||
<aside class="aside ~neutral my-4 col">{{ .strings.referralsDescription }}</aside>
|
||||
<div class="row flex-expand">
|
||||
<div class="user-referrals-info"></div>
|
||||
<div class="grid my-2">
|
||||
<button type="button" class="user-referrals-button button ~info dark:~d_info @low" title="Copy">{{ .strings.copyReferral }}<i class="ri-file-copy-line ml-2"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
<script src="{{ .urlBase }}/js/user.js" type="module"></script>
|
||||
|
@ -79,7 +79,6 @@
|
||||
"inviteUsersCreated": "Oprettet brugere",
|
||||
"inviteNoProfile": "Ingen Profil",
|
||||
"inviteDateCreated": "Oprettet",
|
||||
"inviteRemainingUses": "Resterende anvendelser",
|
||||
"inviteNoInvites": "Ingen",
|
||||
"inviteExpiresInTime": "Udløber om {n}",
|
||||
"notifyEvent": "Meddel den:",
|
||||
|
@ -53,7 +53,6 @@
|
||||
"inviteUsersCreated": "Erstellte Benutzer",
|
||||
"inviteNoProfile": "Kein Profil",
|
||||
"inviteDateCreated": "Erstellt",
|
||||
"inviteRemainingUses": "Verbleibende Verwendungen",
|
||||
"inviteNoInvites": "Keine",
|
||||
"inviteExpiresInTime": "Läuft in {n} ab",
|
||||
"notifyEvent": "Benachrichtigen bei:",
|
||||
|
@ -56,7 +56,6 @@
|
||||
"inviteUsersCreated": "Δημιουργηθέντες χρήστες",
|
||||
"inviteNoProfile": "Κανένα Προφίλ",
|
||||
"inviteDateCreated": "Δημιουργηθέντα",
|
||||
"inviteRemainingUses": "Εναπομείναντες χρήσεις",
|
||||
"inviteNoInvites": "Καμία",
|
||||
"inviteExpiresInTime": "Λήγει σε {n}",
|
||||
"notifyEvent": "Ενημέρωση όταν:",
|
||||
|
@ -124,7 +124,6 @@
|
||||
"addProfileStoreHomescreenLayout": "Store homescreen layout",
|
||||
"inviteNoUsersCreated": "None yet!",
|
||||
"inviteUsersCreated": "Created users",
|
||||
"inviteRemainingUses": "Remaining uses",
|
||||
"inviteNoInvites": "None",
|
||||
"inviteExpiresInTime": "Expires in {n}",
|
||||
"notifyEvent": "Notify on:",
|
||||
|
@ -95,7 +95,6 @@
|
||||
"inviteUsersCreated": "Created users",
|
||||
"inviteNoProfile": "No Profile",
|
||||
"inviteDateCreated": "Created",
|
||||
"inviteRemainingUses": "Remaining uses",
|
||||
"inviteNoInvites": "None",
|
||||
"inviteExpiresInTime": "Expires in {n}",
|
||||
"notifyEvent": "Notify on:",
|
||||
@ -224,4 +223,4 @@
|
||||
"plural": "Extended expiry for {n} users."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -75,7 +75,6 @@
|
||||
"inviteUsersCreated": "Usuarios creados",
|
||||
"inviteNoProfile": "Sin perfil",
|
||||
"inviteDateCreated": "Creado",
|
||||
"inviteRemainingUses": "Usos restantes",
|
||||
"inviteNoInvites": "Ninguno",
|
||||
"inviteExpiresInTime": "Caduca en {n}",
|
||||
"notifyEvent": "Notificar en:",
|
||||
|
@ -55,7 +55,6 @@
|
||||
"inviteUsersCreated": "Utilisateurs créés",
|
||||
"inviteNoProfile": "Aucun profil",
|
||||
"inviteDateCreated": "Créer",
|
||||
"inviteRemainingUses": "Utilisations restantes",
|
||||
"inviteNoInvites": "Aucune",
|
||||
"inviteExpiresInTime": "Expires dans {n}",
|
||||
"notifyEvent": "Notifier sur :",
|
||||
|
@ -87,7 +87,6 @@
|
||||
"inviteUsersCreated": "",
|
||||
"inviteNoProfile": "",
|
||||
"inviteDateCreated": "",
|
||||
"inviteRemainingUses": "",
|
||||
"inviteNoInvites": "",
|
||||
"inviteExpiresInTime": "",
|
||||
"notifyEvent": "",
|
||||
|
@ -56,7 +56,6 @@
|
||||
"inviteUsersCreated": "Pengguna yang telah dibuat",
|
||||
"inviteNoProfile": "Tidak ada profil",
|
||||
"inviteDateCreated": "Dibuat",
|
||||
"inviteRemainingUses": "Penggunaan yang tersisa",
|
||||
"inviteNoInvites": "Tidak ada",
|
||||
"inviteExpiresInTime": "Kadaluarsa dalam {n}",
|
||||
"notifyEvent": "Beritahu pada:",
|
||||
|
@ -53,7 +53,6 @@
|
||||
"inviteUsersCreated": "Aangemaakte gebruikers",
|
||||
"inviteNoProfile": "Geen profiel",
|
||||
"inviteDateCreated": "Aangemaakt",
|
||||
"inviteRemainingUses": "Resterend aantal keer te gebruiken",
|
||||
"inviteNoInvites": "Geen",
|
||||
"inviteExpiresInTime": "Verloopt over {n}",
|
||||
"notifyEvent": "Meldingen:",
|
||||
|
@ -87,7 +87,6 @@
|
||||
"inviteUsersCreated": "",
|
||||
"inviteNoProfile": "",
|
||||
"inviteDateCreated": "Utworzone",
|
||||
"inviteRemainingUses": "",
|
||||
"inviteNoInvites": "",
|
||||
"inviteExpiresInTime": "",
|
||||
"notifyEvent": "",
|
||||
|
@ -54,7 +54,6 @@
|
||||
"inviteUsersCreated": "Usuários criado",
|
||||
"inviteNoProfile": "Sem Perfil",
|
||||
"inviteDateCreated": "Criado",
|
||||
"inviteRemainingUses": "Uso restantes",
|
||||
"inviteNoInvites": "Nenhum",
|
||||
"inviteExpiresInTime": "Expira em {n}",
|
||||
"notifyEvent": "Notificar em:",
|
||||
|
@ -65,7 +65,6 @@
|
||||
"inviteUsersCreated": "Skapade användare",
|
||||
"inviteNoProfile": "Ingen profil",
|
||||
"inviteDateCreated": "Skapad",
|
||||
"inviteRemainingUses": "Återstående användningar",
|
||||
"inviteNoInvites": "Ingen",
|
||||
"inviteExpiresInTime": "Går ut om {n}",
|
||||
"notifyEvent": "Meddela den:",
|
||||
|
@ -86,7 +86,6 @@
|
||||
"inviteUsersCreated": "Người dùng đã tạo",
|
||||
"inviteNoProfile": "Không có Tài khoản mẫu",
|
||||
"inviteDateCreated": "Tạo",
|
||||
"inviteRemainingUses": "Số lần sử dụng còn lại",
|
||||
"inviteNoInvites": "Không có",
|
||||
"inviteExpiresInTime": "Hết hạn trong {n}",
|
||||
"notifyEvent": "Thông báo khi:",
|
||||
|
@ -80,7 +80,6 @@
|
||||
"inviteUsersCreated": "已创建的用户",
|
||||
"inviteNoProfile": "没有个人资料",
|
||||
"inviteDateCreated": "已创建",
|
||||
"inviteRemainingUses": "剩余使用次数",
|
||||
"inviteNoInvites": "无",
|
||||
"inviteExpiresInTime": "在 {n} 到期",
|
||||
"notifyEvent": "通知:",
|
||||
|
@ -87,7 +87,6 @@
|
||||
"inviteUsersCreated": "創建的帳戶",
|
||||
"inviteNoProfile": "無資料",
|
||||
"inviteDateCreated": "已創建",
|
||||
"inviteRemainingUses": "剩餘使用次數",
|
||||
"inviteNoInvites": "無",
|
||||
"inviteExpiresInTime": "在 {n} 到期",
|
||||
"notifyEvent": "通知:",
|
||||
|
@ -35,7 +35,8 @@
|
||||
"expiry": "Udløb",
|
||||
"add": "Tilføj",
|
||||
"edit": "Rediger",
|
||||
"delete": "Slet"
|
||||
"delete": "Slet",
|
||||
"inviteRemainingUses": "Resterende anvendelser"
|
||||
},
|
||||
"notifications": {
|
||||
"errorLoginBlank": "Brugernavnet og/eller adgangskoden blev efterladt tomme.",
|
||||
|
@ -35,7 +35,8 @@
|
||||
"expiry": "Ablaufdatum",
|
||||
"add": "Hinzufügen",
|
||||
"edit": "Bearbeiten",
|
||||
"delete": "Löschen"
|
||||
"delete": "Löschen",
|
||||
"inviteRemainingUses": "Verbleibende Verwendungen"
|
||||
},
|
||||
"notifications": {
|
||||
"errorLoginBlank": "Der Benutzername und/oder das Passwort wurden nicht ausgefüllt.",
|
||||
|
@ -25,7 +25,8 @@
|
||||
"disable": "Απενεργοποίηση",
|
||||
"expiry": "Λήξη",
|
||||
"edit": "Επεξεργασία",
|
||||
"delete": "Διαγραφή"
|
||||
"delete": "Διαγραφή",
|
||||
"inviteRemainingUses": "Εναπομείναντες χρήσεις"
|
||||
},
|
||||
"notifications": {
|
||||
"errorLoginBlank": "Το όνομα χρήστη και/ή ο κωδικός ήταν κενά.",
|
||||
|
@ -35,7 +35,8 @@
|
||||
"expiry": "Expiry",
|
||||
"add": "Add",
|
||||
"edit": "Edit",
|
||||
"delete": "Delete"
|
||||
"delete": "Delete",
|
||||
"inviteRemainingUses": "Remaining uses"
|
||||
},
|
||||
"notifications": {
|
||||
"errorLoginBlank": "The username and/or password was left blank.",
|
||||
|
@ -40,7 +40,8 @@
|
||||
"edit": "Edit",
|
||||
"delete": "Delete",
|
||||
"myAccount": "My Account",
|
||||
"referrals": "Referrals"
|
||||
"referrals": "Referrals",
|
||||
"inviteRemainingUses": "Remaining uses"
|
||||
},
|
||||
"notifications": {
|
||||
"errorLoginBlank": "The username and/or password were left blank.",
|
||||
@ -63,4 +64,4 @@
|
||||
"plural": "{n} Days"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -35,7 +35,8 @@
|
||||
"expiry": "Expiración",
|
||||
"add": "Agregar",
|
||||
"edit": "Editar",
|
||||
"delete": "Eliminar"
|
||||
"delete": "Eliminar",
|
||||
"inviteRemainingUses": "Usos restantes"
|
||||
},
|
||||
"notifications": {
|
||||
"errorLoginBlank": "El nombre de usuario y/o la contraseña se dejaron en blanco.",
|
||||
|
@ -35,7 +35,8 @@
|
||||
"expiry": "Expiration",
|
||||
"add": "Ajouter",
|
||||
"edit": "Éditer",
|
||||
"delete": "Effacer"
|
||||
"delete": "Effacer",
|
||||
"inviteRemainingUses": "Utilisations restantes"
|
||||
},
|
||||
"notifications": {
|
||||
"errorLoginBlank": "Le nom d'utilisateur et/ou le mot de passe sont vides.",
|
||||
|
@ -19,7 +19,8 @@
|
||||
"login": "Masuk",
|
||||
"logout": "Keluar",
|
||||
"edit": "Edit",
|
||||
"delete": "Hapus"
|
||||
"delete": "Hapus",
|
||||
"inviteRemainingUses": "Penggunaan yang tersisa"
|
||||
},
|
||||
"notifications": {
|
||||
"errorLoginBlank": "Nama pengguna dan / atau sandi kosong.",
|
||||
|
@ -28,4 +28,4 @@
|
||||
},
|
||||
"notifications": {},
|
||||
"quantityStrings": {}
|
||||
}
|
||||
}
|
8
lang/common/nds.json
Normal file
8
lang/common/nds.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"meta": {
|
||||
"name": "Nedderdütsch (NDS)"
|
||||
},
|
||||
"strings": {},
|
||||
"notifications": {},
|
||||
"quantityStrings": {}
|
||||
}
|
@ -35,7 +35,8 @@
|
||||
"expiry": "Verloop",
|
||||
"add": "Voeg toe",
|
||||
"edit": "Bewerken",
|
||||
"delete": "Verwijderen"
|
||||
"delete": "Verwijderen",
|
||||
"inviteRemainingUses": "Resterend aantal keer te gebruiken"
|
||||
},
|
||||
"notifications": {
|
||||
"errorLoginBlank": "De gebruikersnaam en/of wachtwoord is leeg.",
|
||||
|
@ -35,7 +35,8 @@
|
||||
"expiry": "Expira",
|
||||
"add": "Adicionar",
|
||||
"edit": "Editar",
|
||||
"delete": "Deletar"
|
||||
"delete": "Deletar",
|
||||
"inviteRemainingUses": "Uso restantes"
|
||||
},
|
||||
"notifications": {
|
||||
"errorLoginBlank": "O nome de usuário e/ou senha foram deixados em branco.",
|
||||
|
@ -28,4 +28,4 @@
|
||||
},
|
||||
"notifications": {},
|
||||
"quantityStrings": {}
|
||||
}
|
||||
}
|
@ -22,7 +22,8 @@
|
||||
"disabled": "Inaktiverad",
|
||||
"expiry": "Löper ut",
|
||||
"edit": "Redigera",
|
||||
"delete": "Radera"
|
||||
"delete": "Radera",
|
||||
"inviteRemainingUses": "Återstående användningar"
|
||||
},
|
||||
"notifications": {
|
||||
"errorLoginBlank": "Användarnamnet och/eller lösenordet lämnades tomt.",
|
||||
|
@ -13,7 +13,8 @@
|
||||
"expiry": "Hết hạn",
|
||||
"add": "Thêm",
|
||||
"edit": "Chỉnh sửa",
|
||||
"delete": "Xóa"
|
||||
"delete": "Xóa",
|
||||
"inviteRemainingUses": "Số lần sử dụng còn lại"
|
||||
},
|
||||
"notifications": {
|
||||
"errorConnection": "Không thể kết nối với jfa-go.",
|
||||
|
@ -35,7 +35,8 @@
|
||||
"expiry": "到期",
|
||||
"add": "添加",
|
||||
"edit": "编辑",
|
||||
"delete": "删除"
|
||||
"delete": "删除",
|
||||
"inviteRemainingUses": "剩余使用次数"
|
||||
},
|
||||
"notifications": {
|
||||
"errorLoginBlank": "用户名/密码留空。",
|
||||
|
@ -35,7 +35,8 @@
|
||||
"expiry": "到期",
|
||||
"add": "添加",
|
||||
"edit": "編輯",
|
||||
"delete": "刪除"
|
||||
"delete": "刪除",
|
||||
"inviteRemainingUses": "剩餘使用次數"
|
||||
},
|
||||
"notifications": {
|
||||
"errorLoginBlank": "帳戶名稱和/或密碼留空。",
|
||||
|
@ -49,4 +49,4 @@
|
||||
"clickBelow": "",
|
||||
"confirmEmail": ""
|
||||
}
|
||||
}
|
||||
}
|
@ -34,7 +34,9 @@
|
||||
"resetPasswordThroughLink": "To reset your password, enter your username, email address or a linked contact method username, and submit. A link will be sent to reset your password.",
|
||||
"resetSent": "Reset Sent.",
|
||||
"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"
|
||||
"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"
|
||||
},
|
||||
"notifications": {
|
||||
"errorUserExists": "User already exists.",
|
||||
@ -76,4 +78,4 @@
|
||||
"plural": "Must have at least {n} special characters"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -48,4 +48,4 @@
|
||||
"plural": "Deve avere almeno {n} caratteri speciali"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -57,4 +57,4 @@
|
||||
"plural": "Potrebnih je vsaj {n} posebnih znakov"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -13,4 +13,4 @@
|
||||
"changeYourPassword": "Spremenite svoje geslo po prijavi.",
|
||||
"enterYourPassword": "Vnesite svoje novo geslo spodaj."
|
||||
}
|
||||
}
|
||||
}
|
@ -157,4 +157,4 @@
|
||||
"emailMessage": "Email Message",
|
||||
"emailMessageNotice": "Displays at the bottom of emails."
|
||||
}
|
||||
}
|
||||
}
|
@ -149,4 +149,4 @@
|
||||
"emailMessage": "",
|
||||
"emailMessageNotice": ""
|
||||
}
|
||||
}
|
||||
}
|
@ -146,4 +146,4 @@
|
||||
"emailMessage": "",
|
||||
"emailMessageNotice": ""
|
||||
}
|
||||
}
|
||||
}
|
@ -13,4 +13,4 @@
|
||||
"languageSet": "",
|
||||
"discordDMs": ""
|
||||
}
|
||||
}
|
||||
}
|
@ -13,4 +13,4 @@
|
||||
"languageSet": "",
|
||||
"discordDMs": ""
|
||||
}
|
||||
}
|
||||
}
|
@ -13,4 +13,4 @@
|
||||
"languageSet": "Jezik nastavljen na {language}.",
|
||||
"discordDMs": "Prosimo preverite svoja zasebna sporočila za odziv."
|
||||
}
|
||||
}
|
||||
}
|
@ -390,6 +390,7 @@ type MyDetailsDTO struct {
|
||||
Discord *MyDetailsContactMethodsDTO `json:"discord,omitempty"`
|
||||
Telegram *MyDetailsContactMethodsDTO `json:"telegram,omitempty"`
|
||||
Matrix *MyDetailsContactMethodsDTO `json:"matrix,omitempty"`
|
||||
HasReferrals bool `json:"has_referrals,omitempty"`
|
||||
}
|
||||
|
||||
type MyDetailsContactMethodsDTO struct {
|
||||
@ -418,10 +419,10 @@ type ChangeMyPasswordDTO struct {
|
||||
}
|
||||
|
||||
type GetMyReferralRespDTO struct {
|
||||
Code string `json:"code"`
|
||||
RemainingUses int `json:"remaining-uses"`
|
||||
NoLimit bool `json:"no-limit"`
|
||||
Expiry time.Time `json:"expiry"` // Come back after this time to get a new referral
|
||||
Code string `json:"code"`
|
||||
RemainingUses int `json:"remaining_uses"`
|
||||
NoLimit bool `json:"no_limit"`
|
||||
Expiry int64 `json:"expiry"` // Come back after this time to get a new referral
|
||||
}
|
||||
|
||||
type EnableDisableReferralDTO struct {
|
||||
|
@ -38,7 +38,10 @@
|
||||
"expiry": "common",
|
||||
"add": "common",
|
||||
"edit": "common",
|
||||
"delete": "admin"
|
||||
"delete": "common",
|
||||
"myAccount": "common",
|
||||
"referrals": "common",
|
||||
"inviteRemainingUses": "admin"
|
||||
},
|
||||
"notifications": {
|
||||
"errorLoginBlank": "common",
|
||||
|
67
ts/user.ts
67
ts/user.ts
@ -1,7 +1,7 @@
|
||||
import { ThemeManager } from "./modules/theme.js";
|
||||
import { lang, LangFile, loadLangSelector } from "./modules/lang.js";
|
||||
import { Modal } from "./modules/modal.js";
|
||||
import { _get, _post, _delete, notificationBox, whichAnimationEvent, toDateString, toggleLoader, addLoader, removeLoader } from "./modules/common.js";
|
||||
import { _get, _post, _delete, notificationBox, whichAnimationEvent, toDateString, toggleLoader, addLoader, removeLoader, toClipboard } from "./modules/common.js";
|
||||
import { Login } from "./modules/login.js";
|
||||
import { Discord, Telegram, Matrix, ServiceConfiguration, MatrixConfiguration } from "./modules/account-linking.js";
|
||||
import { Validator, ValidatorConf, ValidatorRespDTO } from "./modules/validator.js";
|
||||
@ -18,6 +18,7 @@ interface userWindow extends Window {
|
||||
matrixUserID: string;
|
||||
discordSendPINMessage: string;
|
||||
pwrEnabled: string;
|
||||
referralsEnabled: boolean;
|
||||
}
|
||||
|
||||
declare var window: userWindow;
|
||||
@ -107,6 +108,14 @@ interface MyDetails {
|
||||
discord?: MyDetailsContactMethod;
|
||||
telegram?: MyDetailsContactMethod;
|
||||
matrix?: MyDetailsContactMethod;
|
||||
has_referrals: boolean;
|
||||
}
|
||||
|
||||
interface MyReferral {
|
||||
code: string;
|
||||
remaining_uses: string;
|
||||
no_limit: boolean;
|
||||
expiry: number;
|
||||
}
|
||||
|
||||
interface ContactDTO {
|
||||
@ -513,6 +522,62 @@ document.addEventListener("details-reload", () => {
|
||||
} else if (!statusCard.classList.contains("unfocused")) {
|
||||
setBestRowSpan(passwordCard, true);
|
||||
}
|
||||
|
||||
let referralCard = document.getElementById("card-referrals");
|
||||
if (window.referralsEnabled && typeof(referralCard) != "undefined" && referralCard != null) {
|
||||
if (details.has_referrals) {
|
||||
_get("/my/referral", null, (req: XMLHttpRequest) => {
|
||||
if (req.readyState != 4 || req.status != 200) return;
|
||||
const referral: MyReferral = req.response as MyReferral;
|
||||
const infoArea = referralCard.querySelector(".user-referrals-info") as HTMLDivElement;
|
||||
|
||||
infoArea.innerHTML = `
|
||||
<div class="row my-3">
|
||||
<div class="inline baseline">
|
||||
<span class="text-2xl">${referral.no_limit ? "∞" : referral.remaining_uses}</span> <span class="text-gray-400 text-lg">${window.lang.strings("inviteRemainingUses")}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row my-3">
|
||||
<div class="inline baseline">
|
||||
<span class="text-gray-400 text-lg">${window.lang.strings("expiry")}</span> <span class="text-2xl">${toDateString(new Date(referral.expiry * 1000))}</span>
|
||||
<div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
const linkButton = referralCard.querySelector(".user-referrals-button") as HTMLButtonElement;
|
||||
|
||||
let codeLink = window.location.href;
|
||||
for (let split of ["#", "?", "account", "my"]) {
|
||||
codeLink = codeLink.split(split)[0];
|
||||
}
|
||||
if (codeLink.slice(-1) != "/") { codeLink += "/"; }
|
||||
codeLink = codeLink + "invite/" + referral.code;
|
||||
|
||||
linkButton.addEventListener("click", () => {
|
||||
toClipboard(codeLink);
|
||||
const content = linkButton.innerHTML;
|
||||
linkButton.innerHTML = `
|
||||
${window.lang.strings("copied")} <i class="ri-check-line ml-2"></i>
|
||||
`;
|
||||
linkButton.classList.add("~positive");
|
||||
linkButton.classList.remove("~info");
|
||||
setTimeout(() => {
|
||||
linkButton.classList.add("~info");
|
||||
linkButton.classList.remove("~positive");
|
||||
linkButton.innerHTML = content;
|
||||
}, 2000);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
referralCard.classList.remove("unfocused");
|
||||
|
||||
});
|
||||
} else {
|
||||
referralCard.classList.add("unfocused");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
1
views.go
1
views.go
@ -204,6 +204,7 @@ func (app *appContext) MyUserPage(gc *gin.Context) {
|
||||
"langName": lang,
|
||||
"jfLink": app.config.Section("ui").Key("redirect_url").String(),
|
||||
"requirements": app.validator.getCriteria(),
|
||||
"referralsEnabled": app.config.Section("user_page").Key("enabled").MustBool(false) && app.config.Section("user_page").Key("referrals").MustBool(false),
|
||||
}
|
||||
if telegramEnabled {
|
||||
data["telegramUsername"] = app.telegram.username
|
||||
|
Loading…
Reference in New Issue
Block a user