mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-11-09 20:00:12 +00:00
Compare commits
3 Commits
68004e1d34
...
8e153cd92f
Author | SHA1 | Date | |
---|---|---|---|
8e153cd92f | |||
d509abdd5c | |||
96c51af15a |
102
api-userpage.go
102
api-userpage.go
@ -10,7 +10,7 @@ import (
|
|||||||
"github.com/golang-jwt/jwt"
|
"github.com/golang-jwt/jwt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// @Summary Returns the logged-in user's Jellyfin ID & Username.
|
// @Summary Returns the logged-in user's Jellyfin ID & Username, and other details.
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Success 200 {object} MyDetailsDTO
|
// @Success 200 {object} MyDetailsDTO
|
||||||
// @Router /my/details [get]
|
// @Router /my/details [get]
|
||||||
@ -379,3 +379,103 @@ func (app *appContext) MyTelegramVerifiedInvite(gc *gin.Context) {
|
|||||||
app.storage.SetTelegramKey(gc.GetString("jfId"), tgUser)
|
app.storage.SetTelegramKey(gc.GetString("jfId"), tgUser)
|
||||||
respondBool(200, true, gc)
|
respondBool(200, true, gc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Summary Generate and send a new PIN to your given matrix user.
|
||||||
|
// @Produce json
|
||||||
|
// @Success 200 {object} boolResponse
|
||||||
|
// @Failure 400 {object} stringResponse
|
||||||
|
// @Failure 401 {object} boolResponse
|
||||||
|
// @Failure 500 {object} boolResponse
|
||||||
|
// @Param MatrixSendPINDTO body MatrixSendPINDTO true "User's Matrix ID."
|
||||||
|
// @Router /my/matrix/user [post]
|
||||||
|
// @tags User Page
|
||||||
|
func (app *appContext) MatrixSendMyPIN(gc *gin.Context) {
|
||||||
|
var req MatrixSendPINDTO
|
||||||
|
gc.BindJSON(&req)
|
||||||
|
if req.UserID == "" {
|
||||||
|
respond(400, "errorNoUserID", gc)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if app.config.Section("matrix").Key("require_unique").MustBool(false) {
|
||||||
|
for _, u := range app.storage.GetMatrix() {
|
||||||
|
if req.UserID == u.UserID {
|
||||||
|
respondBool(400, false, gc)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ok := app.matrix.SendStart(req.UserID)
|
||||||
|
if !ok {
|
||||||
|
respondBool(500, false, gc)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
respondBool(200, true, gc)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Summary Check whether your matrix PIN is valid, and link the account to yours if so.
|
||||||
|
// @Produce json
|
||||||
|
// @Success 200 {object} boolResponse
|
||||||
|
// @Failure 401 {object} boolResponse
|
||||||
|
// @Param pin path string true "PIN code to check"
|
||||||
|
// @Param invCode path string true "invite Code"
|
||||||
|
// @Param userID path string true "Matrix User ID"
|
||||||
|
// @Router /my/matrix/verified/{userID}/{pin} [get]
|
||||||
|
// @tags User Page
|
||||||
|
func (app *appContext) MatrixCheckMyPIN(gc *gin.Context) {
|
||||||
|
userID := gc.Param("userID")
|
||||||
|
pin := gc.Param("pin")
|
||||||
|
user, ok := app.matrix.tokens[pin]
|
||||||
|
if !ok {
|
||||||
|
app.debug.Println("Matrix: PIN not found")
|
||||||
|
respondBool(200, false, gc)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if user.User.UserID != userID {
|
||||||
|
app.debug.Println("Matrix: User ID of PIN didn't match")
|
||||||
|
respondBool(200, false, gc)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
mxUser := *user.User
|
||||||
|
mxUser.Contact = true
|
||||||
|
existingUser, ok := app.storage.GetMatrixKey(gc.GetString("jfId"))
|
||||||
|
if ok {
|
||||||
|
mxUser.Lang = existingUser.Lang
|
||||||
|
mxUser.Contact = existingUser.Contact
|
||||||
|
}
|
||||||
|
|
||||||
|
app.storage.SetMatrixKey(gc.GetString("jfId"), mxUser)
|
||||||
|
delete(app.matrix.tokens, pin)
|
||||||
|
respondBool(200, true, gc)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Summary unlink the Discord account from your Jellyfin user. Always succeeds.
|
||||||
|
// @Produce json
|
||||||
|
// @Success 200 {object} boolResponse
|
||||||
|
// @Router /my/discord [delete]
|
||||||
|
// @Tags Users
|
||||||
|
func (app *appContext) UnlinkMyDiscord(gc *gin.Context) {
|
||||||
|
app.storage.DeleteDiscordKey(gc.GetString("jfId"))
|
||||||
|
respondBool(200, true, gc)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Summary unlink the Telegram account from your Jellyfin user. Always succeeds.
|
||||||
|
// @Produce json
|
||||||
|
// @Success 200 {object} boolResponse
|
||||||
|
// @Router /my/telegram [delete]
|
||||||
|
// @Tags Users
|
||||||
|
func (app *appContext) UnlinkMyTelegram(gc *gin.Context) {
|
||||||
|
app.storage.DeleteTelegramKey(gc.GetString("jfId"))
|
||||||
|
respondBool(200, true, gc)
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Summary unlink the Matrix account from your Jellyfin user. Always succeeds.
|
||||||
|
// @Produce json
|
||||||
|
// @Success 200 {object} boolResponse
|
||||||
|
// @Router /my/matrix [delete]
|
||||||
|
// @Tags Users
|
||||||
|
func (app *appContext) UnlinkMyMatrix(gc *gin.Context) {
|
||||||
|
app.storage.DeleteMatrixKey(gc.GetString("jfId"))
|
||||||
|
respondBool(200, true, gc)
|
||||||
|
}
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
"inviteSendToEmail": "Send til",
|
"inviteSendToEmail": "Send til",
|
||||||
"create": "Opret",
|
"create": "Opret",
|
||||||
"apply": "Anvend",
|
"apply": "Anvend",
|
||||||
"delete": "Slet",
|
|
||||||
"select": "Vælg",
|
"select": "Vælg",
|
||||||
"name": "Navn",
|
"name": "Navn",
|
||||||
"date": "Dato",
|
"date": "Dato",
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
"inviteSendToEmail": "Senden an",
|
"inviteSendToEmail": "Senden an",
|
||||||
"create": "Erstellen",
|
"create": "Erstellen",
|
||||||
"apply": "Anwenden",
|
"apply": "Anwenden",
|
||||||
"delete": "Löschen",
|
|
||||||
"name": "Name",
|
"name": "Name",
|
||||||
"date": "Datum",
|
"date": "Datum",
|
||||||
"lastActiveTime": "Zuletzt aktiv",
|
"lastActiveTime": "Zuletzt aktiv",
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
"inviteSendToEmail": "Αποστολή σε",
|
"inviteSendToEmail": "Αποστολή σε",
|
||||||
"create": "Δημιουργία",
|
"create": "Δημιουργία",
|
||||||
"apply": "Εφαρμογή",
|
"apply": "Εφαρμογή",
|
||||||
"delete": "Διαγραφή",
|
|
||||||
"name": "Όνομα",
|
"name": "Όνομα",
|
||||||
"date": "Ημερομηνία",
|
"date": "Ημερομηνία",
|
||||||
"lastActiveTime": "Τελευταία Ενεργός",
|
"lastActiveTime": "Τελευταία Ενεργός",
|
||||||
|
@ -69,7 +69,6 @@
|
|||||||
"inviteInfiniteUsesWarning": "invites with infinite uses can be used abusively",
|
"inviteInfiniteUsesWarning": "invites with infinite uses can be used abusively",
|
||||||
"inviteSendToEmail": "Send to",
|
"inviteSendToEmail": "Send to",
|
||||||
"apply": "Apply",
|
"apply": "Apply",
|
||||||
"delete": "Delete",
|
|
||||||
"updates": "Updates",
|
"updates": "Updates",
|
||||||
"variables": "Variables",
|
"variables": "Variables",
|
||||||
"preview": "Preview",
|
"preview": "Preview",
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
"inviteSendToEmail": "Send to",
|
"inviteSendToEmail": "Send to",
|
||||||
"create": "Create",
|
"create": "Create",
|
||||||
"apply": "Apply",
|
"apply": "Apply",
|
||||||
"delete": "Delete",
|
|
||||||
"select": "Select",
|
"select": "Select",
|
||||||
"name": "Name",
|
"name": "Name",
|
||||||
"date": "Date",
|
"date": "Date",
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
"inviteSendToEmail": "Enviar a",
|
"inviteSendToEmail": "Enviar a",
|
||||||
"create": "Crear",
|
"create": "Crear",
|
||||||
"apply": "Aplicar",
|
"apply": "Aplicar",
|
||||||
"delete": "Eliminar",
|
|
||||||
"name": "Nombre",
|
"name": "Nombre",
|
||||||
"date": "Fecha",
|
"date": "Fecha",
|
||||||
"updates": "Actualizaciones",
|
"updates": "Actualizaciones",
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
"inviteSendToEmail": "Envoyer à",
|
"inviteSendToEmail": "Envoyer à",
|
||||||
"create": "Créer",
|
"create": "Créer",
|
||||||
"apply": "Appliquer",
|
"apply": "Appliquer",
|
||||||
"delete": "Effacer",
|
|
||||||
"name": "Nom",
|
"name": "Nom",
|
||||||
"date": "Date",
|
"date": "Date",
|
||||||
"lastActiveTime": "Dernière activité",
|
"lastActiveTime": "Dernière activité",
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
"inviteSendToEmail": "Címzett",
|
"inviteSendToEmail": "Címzett",
|
||||||
"create": "Létrehozás",
|
"create": "Létrehozás",
|
||||||
"apply": "Alkalmaz",
|
"apply": "Alkalmaz",
|
||||||
"delete": "Törlés",
|
|
||||||
"select": "Kiválasztás",
|
"select": "Kiválasztás",
|
||||||
"name": "Név",
|
"name": "Név",
|
||||||
"date": "Dátum",
|
"date": "Dátum",
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
"inviteSendToEmail": "Dikirim kepada",
|
"inviteSendToEmail": "Dikirim kepada",
|
||||||
"create": "Buat",
|
"create": "Buat",
|
||||||
"apply": "Terapkan",
|
"apply": "Terapkan",
|
||||||
"delete": "Hapus",
|
|
||||||
"name": "Nama",
|
"name": "Nama",
|
||||||
"date": "Tanggal",
|
"date": "Tanggal",
|
||||||
"lastActiveTime": "Terakhir Aktif",
|
"lastActiveTime": "Terakhir Aktif",
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
"inviteSendToEmail": "Stuur naar",
|
"inviteSendToEmail": "Stuur naar",
|
||||||
"create": "Aanmaken",
|
"create": "Aanmaken",
|
||||||
"apply": "Toepassen",
|
"apply": "Toepassen",
|
||||||
"delete": "Verwijderen",
|
|
||||||
"name": "Naam",
|
"name": "Naam",
|
||||||
"date": "Datum",
|
"date": "Datum",
|
||||||
"lastActiveTime": "Laatst actief",
|
"lastActiveTime": "Laatst actief",
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
"inviteSendToEmail": "",
|
"inviteSendToEmail": "",
|
||||||
"create": "",
|
"create": "",
|
||||||
"apply": "",
|
"apply": "",
|
||||||
"delete": "",
|
|
||||||
"select": "",
|
"select": "",
|
||||||
"name": "Imię",
|
"name": "Imię",
|
||||||
"date": "Data",
|
"date": "Data",
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
"inviteSendToEmail": "Enviar para",
|
"inviteSendToEmail": "Enviar para",
|
||||||
"create": "Criar",
|
"create": "Criar",
|
||||||
"apply": "Aplicar",
|
"apply": "Aplicar",
|
||||||
"delete": "Deletar",
|
|
||||||
"name": "Nome",
|
"name": "Nome",
|
||||||
"date": "Data",
|
"date": "Data",
|
||||||
"lastActiveTime": "Ativo pela última vez",
|
"lastActiveTime": "Ativo pela última vez",
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
"inviteSendToEmail": "Skicka till",
|
"inviteSendToEmail": "Skicka till",
|
||||||
"create": "Skapa",
|
"create": "Skapa",
|
||||||
"apply": "Tillämpa",
|
"apply": "Tillämpa",
|
||||||
"delete": "Radera",
|
|
||||||
"name": "Namn",
|
"name": "Namn",
|
||||||
"date": "Datum",
|
"date": "Datum",
|
||||||
"lastActiveTime": "Senast aktiv",
|
"lastActiveTime": "Senast aktiv",
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
"inviteSendToEmail": "Gửi tới",
|
"inviteSendToEmail": "Gửi tới",
|
||||||
"create": "Tạo mới",
|
"create": "Tạo mới",
|
||||||
"apply": "Áp dụng",
|
"apply": "Áp dụng",
|
||||||
"delete": "Xóa",
|
|
||||||
"select": "Chọn",
|
"select": "Chọn",
|
||||||
"name": "Tên",
|
"name": "Tên",
|
||||||
"date": "Ngày",
|
"date": "Ngày",
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
"inviteSendToEmail": "发送到",
|
"inviteSendToEmail": "发送到",
|
||||||
"create": "创建",
|
"create": "创建",
|
||||||
"apply": "申请",
|
"apply": "申请",
|
||||||
"delete": "删除",
|
|
||||||
"select": "选择",
|
"select": "选择",
|
||||||
"name": "名称",
|
"name": "名称",
|
||||||
"date": "日期",
|
"date": "日期",
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
"inviteSendToEmail": "發送到",
|
"inviteSendToEmail": "發送到",
|
||||||
"create": "創建",
|
"create": "創建",
|
||||||
"apply": "應用",
|
"apply": "應用",
|
||||||
"delete": "刪除",
|
|
||||||
"select": "選擇",
|
"select": "選擇",
|
||||||
"name": "帳戶名稱",
|
"name": "帳戶名稱",
|
||||||
"date": "日期",
|
"date": "日期",
|
||||||
|
@ -34,7 +34,8 @@
|
|||||||
"disable": "Deaktiver",
|
"disable": "Deaktiver",
|
||||||
"expiry": "Udløb",
|
"expiry": "Udløb",
|
||||||
"add": "Tilføj",
|
"add": "Tilføj",
|
||||||
"edit": "Rediger"
|
"edit": "Rediger",
|
||||||
|
"delete": "Slet"
|
||||||
},
|
},
|
||||||
"notifications": {
|
"notifications": {
|
||||||
"errorLoginBlank": "Brugernavnet og/eller adgangskoden blev efterladt tomme.",
|
"errorLoginBlank": "Brugernavnet og/eller adgangskoden blev efterladt tomme.",
|
||||||
|
@ -34,7 +34,8 @@
|
|||||||
"disable": "Deaktivieren",
|
"disable": "Deaktivieren",
|
||||||
"expiry": "Ablaufdatum",
|
"expiry": "Ablaufdatum",
|
||||||
"add": "Hinzufügen",
|
"add": "Hinzufügen",
|
||||||
"edit": "Bearbeiten"
|
"edit": "Bearbeiten",
|
||||||
|
"delete": "Löschen"
|
||||||
},
|
},
|
||||||
"notifications": {
|
"notifications": {
|
||||||
"errorLoginBlank": "Der Benutzername und/oder das Passwort wurden nicht ausgefüllt.",
|
"errorLoginBlank": "Der Benutzername und/oder das Passwort wurden nicht ausgefüllt.",
|
||||||
|
@ -24,7 +24,8 @@
|
|||||||
"reEnable": "Επανα-ενεργοποίηση",
|
"reEnable": "Επανα-ενεργοποίηση",
|
||||||
"disable": "Απενεργοποίηση",
|
"disable": "Απενεργοποίηση",
|
||||||
"expiry": "Λήξη",
|
"expiry": "Λήξη",
|
||||||
"edit": "Επεξεργασία"
|
"edit": "Επεξεργασία",
|
||||||
|
"delete": "Διαγραφή"
|
||||||
},
|
},
|
||||||
"notifications": {
|
"notifications": {
|
||||||
"errorLoginBlank": "Το όνομα χρήστη και/ή ο κωδικός ήταν κενά.",
|
"errorLoginBlank": "Το όνομα χρήστη και/ή ο κωδικός ήταν κενά.",
|
||||||
|
@ -34,7 +34,8 @@
|
|||||||
"disable": "Disable",
|
"disable": "Disable",
|
||||||
"expiry": "Expiry",
|
"expiry": "Expiry",
|
||||||
"add": "Add",
|
"add": "Add",
|
||||||
"edit": "Edit"
|
"edit": "Edit",
|
||||||
|
"delete": "Delete"
|
||||||
},
|
},
|
||||||
"notifications": {
|
"notifications": {
|
||||||
"errorLoginBlank": "The username and/or password was left blank.",
|
"errorLoginBlank": "The username and/or password was left blank.",
|
||||||
|
@ -33,13 +33,12 @@
|
|||||||
"reEnable": "Re-enable",
|
"reEnable": "Re-enable",
|
||||||
"disable": "Disable",
|
"disable": "Disable",
|
||||||
"contactMethods": "Contact Methods",
|
"contactMethods": "Contact Methods",
|
||||||
"addContactMethod": "Add Contact Method",
|
|
||||||
"editContactMethod": "Edit Contact Method",
|
|
||||||
"accountStatus": "Account Status",
|
"accountStatus": "Account Status",
|
||||||
"notSet": "Not set",
|
"notSet": "Not set",
|
||||||
"expiry": "Expiry",
|
"expiry": "Expiry",
|
||||||
"add": "Add",
|
"add": "Add",
|
||||||
"edit": "Edit"
|
"edit": "Edit",
|
||||||
|
"delete": "Delete"
|
||||||
},
|
},
|
||||||
"notifications": {
|
"notifications": {
|
||||||
"errorLoginBlank": "The username and/or password were left blank.",
|
"errorLoginBlank": "The username and/or password were left blank.",
|
||||||
|
@ -34,7 +34,8 @@
|
|||||||
"disable": "Desactivar",
|
"disable": "Desactivar",
|
||||||
"expiry": "Expiración",
|
"expiry": "Expiración",
|
||||||
"add": "Agregar",
|
"add": "Agregar",
|
||||||
"edit": "Editar"
|
"edit": "Editar",
|
||||||
|
"delete": "Eliminar"
|
||||||
},
|
},
|
||||||
"notifications": {
|
"notifications": {
|
||||||
"errorLoginBlank": "El nombre de usuario y/o la contraseña se dejaron en blanco.",
|
"errorLoginBlank": "El nombre de usuario y/o la contraseña se dejaron en blanco.",
|
||||||
|
@ -34,7 +34,8 @@
|
|||||||
"disable": "Désactivé",
|
"disable": "Désactivé",
|
||||||
"expiry": "Expiration",
|
"expiry": "Expiration",
|
||||||
"add": "Ajouter",
|
"add": "Ajouter",
|
||||||
"edit": "Éditer"
|
"edit": "Éditer",
|
||||||
|
"delete": "Effacer"
|
||||||
},
|
},
|
||||||
"notifications": {
|
"notifications": {
|
||||||
"errorLoginBlank": "Le nom d'utilisateur et/ou le mot de passe sont vides.",
|
"errorLoginBlank": "Le nom d'utilisateur et/ou le mot de passe sont vides.",
|
||||||
|
@ -12,7 +12,8 @@
|
|||||||
"disable": "Letiltás",
|
"disable": "Letiltás",
|
||||||
"expiry": "Lejárat",
|
"expiry": "Lejárat",
|
||||||
"add": "Hozzáadás",
|
"add": "Hozzáadás",
|
||||||
"edit": "Szerkesztés"
|
"edit": "Szerkesztés",
|
||||||
|
"delete": "Törlés"
|
||||||
},
|
},
|
||||||
"notifications": {},
|
"notifications": {},
|
||||||
"quantityStrings": {}
|
"quantityStrings": {}
|
||||||
|
@ -18,7 +18,8 @@
|
|||||||
"theme": "Tema",
|
"theme": "Tema",
|
||||||
"login": "Masuk",
|
"login": "Masuk",
|
||||||
"logout": "Keluar",
|
"logout": "Keluar",
|
||||||
"edit": "Edit"
|
"edit": "Edit",
|
||||||
|
"delete": "Hapus"
|
||||||
},
|
},
|
||||||
"notifications": {
|
"notifications": {
|
||||||
"errorLoginBlank": "Nama pengguna dan / atau sandi kosong.",
|
"errorLoginBlank": "Nama pengguna dan / atau sandi kosong.",
|
||||||
|
@ -34,7 +34,8 @@
|
|||||||
"disable": "Uitschakelen",
|
"disable": "Uitschakelen",
|
||||||
"expiry": "Verloop",
|
"expiry": "Verloop",
|
||||||
"add": "Voeg toe",
|
"add": "Voeg toe",
|
||||||
"edit": "Bewerken"
|
"edit": "Bewerken",
|
||||||
|
"delete": "Verwijderen"
|
||||||
},
|
},
|
||||||
"notifications": {
|
"notifications": {
|
||||||
"errorLoginBlank": "De gebruikersnaam en/of wachtwoord is leeg.",
|
"errorLoginBlank": "De gebruikersnaam en/of wachtwoord is leeg.",
|
||||||
|
@ -34,7 +34,8 @@
|
|||||||
"disable": "Desativar",
|
"disable": "Desativar",
|
||||||
"expiry": "Expira",
|
"expiry": "Expira",
|
||||||
"add": "Adicionar",
|
"add": "Adicionar",
|
||||||
"edit": "Editar"
|
"edit": "Editar",
|
||||||
|
"delete": "Deletar"
|
||||||
},
|
},
|
||||||
"notifications": {
|
"notifications": {
|
||||||
"errorLoginBlank": "O nome de usuário e/ou senha foram deixados em branco.",
|
"errorLoginBlank": "O nome de usuário e/ou senha foram deixados em branco.",
|
||||||
|
@ -21,7 +21,8 @@
|
|||||||
"enabled": "Aktiverad",
|
"enabled": "Aktiverad",
|
||||||
"disabled": "Inaktiverad",
|
"disabled": "Inaktiverad",
|
||||||
"expiry": "Löper ut",
|
"expiry": "Löper ut",
|
||||||
"edit": "Redigera"
|
"edit": "Redigera",
|
||||||
|
"delete": "Radera"
|
||||||
},
|
},
|
||||||
"notifications": {
|
"notifications": {
|
||||||
"errorLoginBlank": "Användarnamnet och/eller lösenordet lämnades tomt.",
|
"errorLoginBlank": "Användarnamnet och/eller lösenordet lämnades tomt.",
|
||||||
|
@ -12,7 +12,8 @@
|
|||||||
"disable": "Tắt",
|
"disable": "Tắt",
|
||||||
"expiry": "Hết hạn",
|
"expiry": "Hết hạn",
|
||||||
"add": "Thêm",
|
"add": "Thêm",
|
||||||
"edit": "Chỉnh sửa"
|
"edit": "Chỉnh sửa",
|
||||||
|
"delete": "Xóa"
|
||||||
},
|
},
|
||||||
"notifications": {
|
"notifications": {
|
||||||
"errorConnection": "Không thể kết nối với jfa-go.",
|
"errorConnection": "Không thể kết nối với jfa-go.",
|
||||||
|
@ -34,7 +34,8 @@
|
|||||||
"disable": "禁用",
|
"disable": "禁用",
|
||||||
"expiry": "到期",
|
"expiry": "到期",
|
||||||
"add": "添加",
|
"add": "添加",
|
||||||
"edit": "编辑"
|
"edit": "编辑",
|
||||||
|
"delete": "删除"
|
||||||
},
|
},
|
||||||
"notifications": {
|
"notifications": {
|
||||||
"errorLoginBlank": "用户名/密码留空。",
|
"errorLoginBlank": "用户名/密码留空。",
|
||||||
|
@ -34,7 +34,8 @@
|
|||||||
"disable": "禁用",
|
"disable": "禁用",
|
||||||
"expiry": "到期",
|
"expiry": "到期",
|
||||||
"add": "添加",
|
"add": "添加",
|
||||||
"edit": "編輯"
|
"edit": "編輯",
|
||||||
|
"delete": "刪除"
|
||||||
},
|
},
|
||||||
"notifications": {
|
"notifications": {
|
||||||
"errorLoginBlank": "帳戶名稱和/或密碼留空。",
|
"errorLoginBlank": "帳戶名稱和/或密碼留空。",
|
||||||
|
@ -235,6 +235,11 @@ func (app *appContext) loadRoutes(router *gin.Engine) {
|
|||||||
user.GET(p+"/pin/:service", app.GetMyPIN)
|
user.GET(p+"/pin/:service", app.GetMyPIN)
|
||||||
user.GET(p+"/discord/verified/:pin", app.MyDiscordVerifiedInvite)
|
user.GET(p+"/discord/verified/:pin", app.MyDiscordVerifiedInvite)
|
||||||
user.GET(p+"/telegram/verified/:pin", app.MyTelegramVerifiedInvite)
|
user.GET(p+"/telegram/verified/:pin", app.MyTelegramVerifiedInvite)
|
||||||
|
user.POST(p+"/matrix/user", app.MatrixSendMyPIN)
|
||||||
|
user.POST(p+"/matrix/verified/:userID/:pin", app.MatrixCheckMyPIN)
|
||||||
|
user.DELETE(p+"/discord", app.UnlinkMyDiscord)
|
||||||
|
user.DELETE(p+"/telegram", app.UnlinkMyTelegram)
|
||||||
|
user.DELETE(p+"/matrix", app.UnlinkMyMatrix)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,8 +36,9 @@
|
|||||||
"accountStatus": "common",
|
"accountStatus": "common",
|
||||||
"notSet": "common",
|
"notSet": "common",
|
||||||
"expiry": "common",
|
"expiry": "common",
|
||||||
"add": "admin",
|
"add": "common",
|
||||||
"edit": "admin"
|
"edit": "common",
|
||||||
|
"delete": "admin"
|
||||||
},
|
},
|
||||||
"notifications": {
|
"notifications": {
|
||||||
"errorLoginBlank": "common",
|
"errorLoginBlank": "common",
|
||||||
|
@ -63,6 +63,7 @@ func (st *Storage) SetEmailsKey(k string, v EmailAddress) {
|
|||||||
func (st *Storage) DeleteEmailsKey(k string) {
|
func (st *Storage) DeleteEmailsKey(k string) {
|
||||||
st.emailsLock.Lock()
|
st.emailsLock.Lock()
|
||||||
delete(st.emails, k)
|
delete(st.emails, k)
|
||||||
|
st.storeEmails()
|
||||||
st.emailsLock.Unlock()
|
st.emailsLock.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,6 +90,7 @@ func (st *Storage) SetDiscordKey(k string, v DiscordUser) {
|
|||||||
func (st *Storage) DeleteDiscordKey(k string) {
|
func (st *Storage) DeleteDiscordKey(k string) {
|
||||||
st.discordLock.Lock()
|
st.discordLock.Lock()
|
||||||
delete(st.discord, k)
|
delete(st.discord, k)
|
||||||
|
st.storeDiscordUsers()
|
||||||
st.discordLock.Unlock()
|
st.discordLock.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,6 +117,7 @@ func (st *Storage) SetTelegramKey(k string, v TelegramUser) {
|
|||||||
func (st *Storage) DeleteTelegramKey(k string) {
|
func (st *Storage) DeleteTelegramKey(k string) {
|
||||||
st.telegramLock.Lock()
|
st.telegramLock.Lock()
|
||||||
delete(st.telegram, k)
|
delete(st.telegram, k)
|
||||||
|
st.storeTelegramUsers()
|
||||||
st.telegramLock.Unlock()
|
st.telegramLock.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,6 +144,7 @@ func (st *Storage) SetMatrixKey(k string, v MatrixUser) {
|
|||||||
func (st *Storage) DeleteMatrixKey(k string) {
|
func (st *Storage) DeleteMatrixKey(k string) {
|
||||||
st.matrixLock.Lock()
|
st.matrixLock.Lock()
|
||||||
delete(st.matrix, k)
|
delete(st.matrix, k)
|
||||||
|
st.storeMatrixUsers()
|
||||||
st.matrixLock.Unlock()
|
st.matrixLock.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
90
ts/form.ts
90
ts/form.ts
@ -3,7 +3,7 @@ import { notificationBox, whichAnimationEvent } from "./modules/common.js";
|
|||||||
import { _get, _post, toggleLoader, addLoader, removeLoader, toDateString } from "./modules/common.js";
|
import { _get, _post, toggleLoader, addLoader, removeLoader, toDateString } from "./modules/common.js";
|
||||||
import { loadLangSelector } from "./modules/lang.js";
|
import { loadLangSelector } from "./modules/lang.js";
|
||||||
import { initValidator } from "./modules/validator.js";
|
import { initValidator } from "./modules/validator.js";
|
||||||
import { Discord, Telegram, ServiceConfiguration } from "./modules/account-linking.js";
|
import { Discord, Telegram, Matrix, ServiceConfiguration, MatrixConfiguration } from "./modules/account-linking.js";
|
||||||
|
|
||||||
interface formWindow extends Window {
|
interface formWindow extends Window {
|
||||||
invalidPassword: string;
|
invalidPassword: string;
|
||||||
@ -56,7 +56,7 @@ if (window.telegramEnabled) {
|
|||||||
pin: window.telegramPIN,
|
pin: window.telegramPIN,
|
||||||
pinURL: "",
|
pinURL: "",
|
||||||
verifiedURL: "/invite/" + window.code + "/telegram/verified/",
|
verifiedURL: "/invite/" + window.code + "/telegram/verified/",
|
||||||
invalidCodeError: window.messages["errorInvalidCode"],
|
invalidCodeError: window.messages["errorInvalidPIN"],
|
||||||
accountLinkedError: window.messages["errorAccountLinked"],
|
accountLinkedError: window.messages["errorAccountLinked"],
|
||||||
successError: window.messages["verified"],
|
successError: window.messages["verified"],
|
||||||
successFunc: (modalClosed: boolean) => {
|
successFunc: (modalClosed: boolean) => {
|
||||||
@ -88,7 +88,7 @@ if (window.discordEnabled) {
|
|||||||
inviteURL: window.discordInviteLink ? ("/invite/" + window.code + "/discord/invite") : "",
|
inviteURL: window.discordInviteLink ? ("/invite/" + window.code + "/discord/invite") : "",
|
||||||
pinURL: "",
|
pinURL: "",
|
||||||
verifiedURL: "/invite/" + window.code + "/discord/verified/",
|
verifiedURL: "/invite/" + window.code + "/discord/verified/",
|
||||||
invalidCodeError: window.messages["errorInvalidCode"],
|
invalidCodeError: window.messages["errorInvalidPIN"],
|
||||||
accountLinkedError: window.messages["errorAccountLinked"],
|
accountLinkedError: window.messages["errorAccountLinked"],
|
||||||
successError: window.messages["verified"],
|
successError: window.messages["verified"],
|
||||||
successFunc: (modalClosed: boolean) => {
|
successFunc: (modalClosed: boolean) => {
|
||||||
@ -114,69 +114,31 @@ var matrixPIN = "";
|
|||||||
if (window.matrixEnabled) {
|
if (window.matrixEnabled) {
|
||||||
window.matrixModal = new Modal(document.getElementById("modal-matrix"), window.matrixRequired);
|
window.matrixModal = new Modal(document.getElementById("modal-matrix"), window.matrixRequired);
|
||||||
const matrixButton = document.getElementById("link-matrix") as HTMLSpanElement;
|
const matrixButton = document.getElementById("link-matrix") as HTMLSpanElement;
|
||||||
matrixButton.onclick = window.matrixModal.show;
|
|
||||||
const submitButton = document.getElementById("matrix-send") as HTMLSpanElement;
|
const matrixConf: MatrixConfiguration = {
|
||||||
const input = document.getElementById("matrix-userid") as HTMLInputElement;
|
modal: window.matrixModal as Modal,
|
||||||
let userID = "";
|
sendMessageURL: "/invite/" + window.code + "/matrix/user",
|
||||||
submitButton.onclick = () => {
|
verifiedURL: "/invite/" + window.code + "/matrix/verified/",
|
||||||
addLoader(submitButton);
|
invalidCodeError: window.messages["errorInvalidPIN"],
|
||||||
if (userID == "") {
|
accountLinkedError: window.messages["errorAccountLinked"],
|
||||||
const send = {
|
unknownError: window.messages["errorUnknown"],
|
||||||
user_id: input.value
|
successError: window.messages["verified"],
|
||||||
};
|
successFunc: () => {
|
||||||
_post("/invite/" + window.code + "/matrix/user", send, (req: XMLHttpRequest) => {
|
matrixVerified = true;
|
||||||
if (req.readyState == 4) {
|
matrixPIN = matrix.pin;
|
||||||
if (req.status == 400 && req.response["error"] == "errorAccountLinked") {
|
matrixButton.classList.add("unfocused");
|
||||||
window.matrixModal.close();
|
document.getElementById("contact-via").classList.remove("unfocused");
|
||||||
window.notifications.customError("accountLinkedError", window.messages["errorAccountLinked"]);
|
document.getElementById("contact-via-email").parentElement.classList.remove("unfocused");
|
||||||
}
|
const radio = document.getElementById("contact-via-matrix") as HTMLInputElement;
|
||||||
removeLoader(submitButton);
|
radio.parentElement.classList.remove("unfocused");
|
||||||
userID = input.value;
|
radio.checked = true;
|
||||||
if (req.status != 200) {
|
validatorFunc();
|
||||||
window.notifications.customError("errorUnknown", window.messages["errorUnknown"]);
|
|
||||||
window.matrixModal.close();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
submitButton.classList.add("~positive");
|
|
||||||
submitButton.classList.remove("~info");
|
|
||||||
setTimeout(() => {
|
|
||||||
submitButton.classList.add("~info");
|
|
||||||
submitButton.classList.remove("~positive");
|
|
||||||
}, 2000);
|
|
||||||
input.placeholder = "PIN";
|
|
||||||
input.value = "";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
_get("/invite/" + window.code + "/matrix/verified/" + userID + "/" + input.value, null, (req: XMLHttpRequest) => {
|
|
||||||
if (req.readyState == 4) {
|
|
||||||
removeLoader(submitButton)
|
|
||||||
const valid = req.response["success"] as boolean;
|
|
||||||
if (valid) {
|
|
||||||
window.matrixModal.close();
|
|
||||||
window.notifications.customPositive("successVerified", "", window.messages["verified"]);
|
|
||||||
matrixVerified = true;
|
|
||||||
matrixPIN = input.value;
|
|
||||||
matrixButton.classList.add("unfocused");
|
|
||||||
document.getElementById("contact-via").classList.remove("unfocused");
|
|
||||||
document.getElementById("contact-via-email").parentElement.classList.remove("unfocused");
|
|
||||||
const radio = document.getElementById("contact-via-matrix") as HTMLInputElement;
|
|
||||||
radio.parentElement.classList.remove("unfocused");
|
|
||||||
radio.checked = true;
|
|
||||||
validatorFunc();
|
|
||||||
} else {
|
|
||||||
window.notifications.customError("errorInvalidPIN", window.messages["errorInvalidPIN"]);
|
|
||||||
submitButton.classList.add("~critical");
|
|
||||||
submitButton.classList.remove("~info");
|
|
||||||
setTimeout(() => {
|
|
||||||
submitButton.classList.add("~info");
|
|
||||||
submitButton.classList.remove("~critical");
|
|
||||||
}, 800);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const matrix = new Matrix(matrixConf);
|
||||||
|
|
||||||
|
matrixButton.onclick = () => { matrix.show(); };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window.confirmation) {
|
if (window.confirmation) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Modal } from "../modules/modal.js";
|
import { Modal } from "../modules/modal.js";
|
||||||
import { _get, _post, toggleLoader } from "../modules/common.js";
|
import { _get, _post, toggleLoader, addLoader, removeLoader } from "../modules/common.js";
|
||||||
|
|
||||||
interface formWindow extends Window {
|
interface formWindow extends Window {
|
||||||
invalidPassword: string;
|
invalidPassword: string;
|
||||||
@ -172,3 +172,95 @@ export class Telegram extends ServiceLinker {
|
|||||||
this._waiting = document.getElementById("telegram-waiting") as HTMLSpanElement;
|
this._waiting = document.getElementById("telegram-waiting") as HTMLSpanElement;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export interface MatrixConfiguration {
|
||||||
|
modal: Modal;
|
||||||
|
sendMessageURL: string;
|
||||||
|
verifiedURL: string;
|
||||||
|
invalidCodeError: string;
|
||||||
|
accountLinkedError: string;
|
||||||
|
unknownError: string;
|
||||||
|
successError: string;
|
||||||
|
successFunc: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Matrix {
|
||||||
|
private _conf: MatrixConfiguration;
|
||||||
|
private _verified = false;
|
||||||
|
private _name: string = "matrix";
|
||||||
|
private _userID: string = "";
|
||||||
|
private _pin: string = "";
|
||||||
|
private _input: HTMLInputElement;
|
||||||
|
private _submit: HTMLSpanElement;
|
||||||
|
|
||||||
|
get verified(): boolean { return this._verified; }
|
||||||
|
get pin(): string { return this._pin; }
|
||||||
|
|
||||||
|
constructor(conf: MatrixConfiguration) {
|
||||||
|
this._conf = conf;
|
||||||
|
this._input = document.getElementById("matrix-userid") as HTMLInputElement;
|
||||||
|
this._submit = document.getElementById("matrix-send") as HTMLSpanElement;
|
||||||
|
this._submit.onclick = () => { this._onclick(); };
|
||||||
|
}
|
||||||
|
|
||||||
|
private _onclick = () => {
|
||||||
|
addLoader(this._submit);
|
||||||
|
if (this._userID == "") {
|
||||||
|
this._sendMessage();
|
||||||
|
} else {
|
||||||
|
this._verifyCode();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
show = () => {
|
||||||
|
this._input.value = "";
|
||||||
|
this._conf.modal.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private _sendMessage = () => _post(this._conf.sendMessageURL, { "user_id": this._input.value }, (req: XMLHttpRequest) => {
|
||||||
|
if (req.readyState != 4) return;
|
||||||
|
removeLoader(this._submit);
|
||||||
|
if (req.status == 400 && req.response["error"] == "errorAccountLinked") {
|
||||||
|
this._conf.modal.close();
|
||||||
|
window.notifications.customError("accountLinkedError", this._conf.accountLinkedError);
|
||||||
|
return;
|
||||||
|
} else if (req.status != 200) {
|
||||||
|
this._conf.modal.close();
|
||||||
|
window.notifications.customError("unknownError", this._conf.unknownError);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this._userID = this._input.value;
|
||||||
|
this._submit.classList.add("~positive");
|
||||||
|
this._submit.classList.remove("~info");
|
||||||
|
setTimeout(() => {
|
||||||
|
this._submit.classList.add("~info");
|
||||||
|
this._submit.classList.remove("~positive");
|
||||||
|
}, 2000);
|
||||||
|
this._input.placeholder = "PIN";
|
||||||
|
this._input.value = "";
|
||||||
|
});
|
||||||
|
|
||||||
|
private _verifyCode = () => _post(this._conf.verifiedURL + this._userID + "/" + this._input.value, null, (req: XMLHttpRequest) => {
|
||||||
|
if (req.readyState != 4) return;
|
||||||
|
removeLoader(this._submit);
|
||||||
|
const valid = req.response["success"] as boolean;
|
||||||
|
if (valid) {
|
||||||
|
this._conf.modal.close();
|
||||||
|
window.notifications.customPositive(this._name + "Verified", "", this._conf.successError);
|
||||||
|
this._verified = true;
|
||||||
|
this._pin = this._input.value;
|
||||||
|
if (this._conf.successFunc) {
|
||||||
|
this._conf.successFunc();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
window.notifications.customError("invalidCodeError", this._conf.invalidCodeError);
|
||||||
|
this._submit.classList.add("~critical");
|
||||||
|
this._submit.classList.remove("~info");
|
||||||
|
setTimeout(() => {
|
||||||
|
this._submit.classList.add("~info");
|
||||||
|
this._submit.classList.remove("~critical");
|
||||||
|
}, 800);
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
57
ts/user.ts
57
ts/user.ts
@ -1,9 +1,9 @@
|
|||||||
import { ThemeManager } from "./modules/theme.js";
|
import { ThemeManager } from "./modules/theme.js";
|
||||||
import { lang, LangFile, loadLangSelector } from "./modules/lang.js";
|
import { lang, LangFile, loadLangSelector } from "./modules/lang.js";
|
||||||
import { Modal } from "./modules/modal.js";
|
import { Modal } from "./modules/modal.js";
|
||||||
import { _get, _post, notificationBox, whichAnimationEvent, toDateString, toggleLoader } from "./modules/common.js";
|
import { _get, _post, _delete, notificationBox, whichAnimationEvent, toDateString, toggleLoader } from "./modules/common.js";
|
||||||
import { Login } from "./modules/login.js";
|
import { Login } from "./modules/login.js";
|
||||||
import { Discord, Telegram, ServiceConfiguration } from "./modules/account-linking.js";
|
import { Discord, Telegram, Matrix, ServiceConfiguration, MatrixConfiguration } from "./modules/account-linking.js";
|
||||||
|
|
||||||
interface userWindow extends Window {
|
interface userWindow extends Window {
|
||||||
jellyfinID: string;
|
jellyfinID: string;
|
||||||
@ -92,7 +92,7 @@ class ContactMethods {
|
|||||||
this._buttons = {};
|
this._buttons = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
append = (name: string, details: MyDetailsContactMethod, icon: string, addEditFunc?: (add: boolean) => void) => {
|
append = (name: string, details: MyDetailsContactMethod, icon: string, addEditFunc?: (add: boolean) => void, required?: boolean) => {
|
||||||
const row = document.createElement("div");
|
const row = document.createElement("div");
|
||||||
row.classList.add("row", "flex-expand", "my-2");
|
row.classList.add("row", "flex-expand", "my-2");
|
||||||
let innerHTML = `
|
let innerHTML = `
|
||||||
@ -118,6 +118,15 @@ class ContactMethods {
|
|||||||
</button>
|
</button>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!required && details.value != "") {
|
||||||
|
innerHTML += `
|
||||||
|
<button class="user-contact-delete button ~critical ml-2" alt="${window.lang.strings("delete")}" text="${window.lang.strings("delete")}">
|
||||||
|
×
|
||||||
|
</button>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
innerHTML += `
|
innerHTML += `
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
@ -160,6 +169,14 @@ class ContactMethods {
|
|||||||
addEditButton.onclick = () => addEditFunc(details.value == "");
|
addEditButton.onclick = () => addEditFunc(details.value == "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!required && details.value != "") {
|
||||||
|
const deleteButton = row.querySelector(".user-contact-delete") as HTMLButtonElement;
|
||||||
|
deleteButton.onclick = () => _delete("/my/" + name, null, (req: XMLHttpRequest) => {
|
||||||
|
if (req.readyState != 4) return;
|
||||||
|
window.location.reload();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
this._content.appendChild(row);
|
this._content.appendChild(row);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -248,8 +265,6 @@ class ExpiryCard {
|
|||||||
this._interval = window.setInterval(this._drawCountdown, 60*1000);
|
this._interval = window.setInterval(this._drawCountdown, 60*1000);
|
||||||
this._drawCountdown();
|
this._drawCountdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var expiryCard = new ExpiryCard(statusCard);
|
var expiryCard = new ExpiryCard(statusCard);
|
||||||
@ -291,7 +306,7 @@ const discordConf: ServiceConfiguration = {
|
|||||||
inviteURL: window.discordInviteLink ? "/my/discord/invite" : "",
|
inviteURL: window.discordInviteLink ? "/my/discord/invite" : "",
|
||||||
pinURL: "/my/pin/discord",
|
pinURL: "/my/pin/discord",
|
||||||
verifiedURL: "/my/discord/verified/",
|
verifiedURL: "/my/discord/verified/",
|
||||||
invalidCodeError: window.lang.notif("errorInvalidCode"),
|
invalidCodeError: window.lang.notif("errorInvalidPIN"),
|
||||||
accountLinkedError: window.lang.notif("errorAccountLinked"),
|
accountLinkedError: window.lang.notif("errorAccountLinked"),
|
||||||
successError: window.lang.notif("verified"),
|
successError: window.lang.notif("verified"),
|
||||||
successFunc: (modalClosed: boolean) => {
|
successFunc: (modalClosed: boolean) => {
|
||||||
@ -306,7 +321,7 @@ const telegramConf: ServiceConfiguration = {
|
|||||||
pin: "",
|
pin: "",
|
||||||
pinURL: "/my/pin/telegram",
|
pinURL: "/my/pin/telegram",
|
||||||
verifiedURL: "/my/telegram/verified/",
|
verifiedURL: "/my/telegram/verified/",
|
||||||
invalidCodeError: window.lang.notif("errorInvalidCode"),
|
invalidCodeError: window.lang.notif("errorInvalidPIN"),
|
||||||
accountLinkedError: window.lang.notif("errorAccountLinked"),
|
accountLinkedError: window.lang.notif("errorAccountLinked"),
|
||||||
successError: window.lang.notif("verified"),
|
successError: window.lang.notif("verified"),
|
||||||
successFunc: (modalClosed: boolean) => {
|
successFunc: (modalClosed: boolean) => {
|
||||||
@ -316,6 +331,22 @@ const telegramConf: ServiceConfiguration = {
|
|||||||
|
|
||||||
let telegram = new Telegram(telegramConf);
|
let telegram = new Telegram(telegramConf);
|
||||||
|
|
||||||
|
const matrixConf: MatrixConfiguration = {
|
||||||
|
modal: window.modals.matrix as Modal,
|
||||||
|
sendMessageURL: "/my/matrix/user",
|
||||||
|
verifiedURL: "/my/matrix/verified/",
|
||||||
|
invalidCodeError: window.lang.notif("errorInvalidPIN"),
|
||||||
|
accountLinkedError: window.lang.notif("errorAccountLinked"),
|
||||||
|
unknownError: window.lang.notif("errorUnknown"),
|
||||||
|
successError: window.lang.notif("verified"),
|
||||||
|
successFunc: () => {
|
||||||
|
setTimeout(() => window.location.reload(), 1200);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let matrix = new Matrix(matrixConf);
|
||||||
|
|
||||||
|
|
||||||
document.addEventListener("details-reload", () => {
|
document.addEventListener("details-reload", () => {
|
||||||
_get("/my/details", null, (req: XMLHttpRequest) => {
|
_get("/my/details", null, (req: XMLHttpRequest) => {
|
||||||
if (req.readyState == 4) {
|
if (req.readyState == 4) {
|
||||||
@ -343,16 +374,16 @@ document.addEventListener("details-reload", () => {
|
|||||||
// Note the weird format of the functions for discord/telegram:
|
// Note the weird format of the functions for discord/telegram:
|
||||||
// "this" was being redefined within the onclick() method, so
|
// "this" was being redefined within the onclick() method, so
|
||||||
// they had to be wrapped in an anonymous function.
|
// they had to be wrapped in an anonymous function.
|
||||||
const contactMethods: { name: string, icon: string, f: (add: boolean) => void }[] = [
|
const contactMethods: { name: string, icon: string, f: (add: boolean) => void, required: boolean }[] = [
|
||||||
{name: "email", icon: `<i class="ri-mail-fill ri-lg"></i>`, f: addEditEmail},
|
{name: "email", icon: `<i class="ri-mail-fill ri-lg"></i>`, f: addEditEmail, required: true},
|
||||||
{name: "discord", icon: `<i class="ri-discord-fill ri-lg"></i>`, f: (add: boolean) => { discord.onclick(); }},
|
{name: "discord", icon: `<i class="ri-discord-fill ri-lg"></i>`, f: (add: boolean) => { discord.onclick(); }, required: window.discordRequired},
|
||||||
{name: "telegram", icon: `<i class="ri-telegram-fill ri-lg"></i>`, f: (add: boolean) => { telegram.onclick() }},
|
{name: "telegram", icon: `<i class="ri-telegram-fill ri-lg"></i>`, f: (add: boolean) => { telegram.onclick() }, required: window.telegramRequired},
|
||||||
{name: "matrix", icon: `<span class="font-bold">[m]</span>`, f: null}
|
{name: "matrix", icon: `<span class="font-bold">[m]</span>`, f: (add: boolean) => { matrix.show(); }, required: window.matrixRequired}
|
||||||
];
|
];
|
||||||
|
|
||||||
for (let method of contactMethods) {
|
for (let method of contactMethods) {
|
||||||
if (method.name in details) {
|
if (method.name in details) {
|
||||||
contactMethodList.append(method.name, details[method.name], method.icon, method.f);
|
contactMethodList.append(method.name, details[method.name], method.icon, method.f, method.required);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user