mirror of
https://github.com/hrfee/jfa-go.git
synced 2025-01-06 00:10:11 +00:00
Compare commits
3 Commits
3730775018
...
dd8dfcb2b1
Author | SHA1 | Date | |
---|---|---|---|
|
dd8dfcb2b1 | ||
73c7f22bd1 | |||
e7ca335d83 |
55
api.go
55
api.go
@ -129,10 +129,18 @@ func (app *appContext) checkInvites() {
|
|||||||
msg, err := app.email.constructExpiry(code, data, app, false)
|
msg, err := app.email.constructExpiry(code, data, app, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.err.Printf("%s: Failed to construct expiry notification: %v", code, err)
|
app.err.Printf("%s: Failed to construct expiry notification: %v", code, err)
|
||||||
} else if err := app.email.send(msg, addr); err != nil {
|
|
||||||
app.err.Printf("%s: Failed to send expiry notification: %v", code, err)
|
|
||||||
} else {
|
} else {
|
||||||
app.info.Printf("Sent expiry notification to %s", addr)
|
// Check whether notify "address" is an email address of Jellyfin ID
|
||||||
|
if strings.Contains(addr, "@") {
|
||||||
|
err = app.email.send(msg, addr)
|
||||||
|
} else {
|
||||||
|
err = app.sendByID(msg, addr)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
app.err.Printf("%s: Failed to send expiry notification: %v", code, err)
|
||||||
|
} else {
|
||||||
|
app.info.Printf("Sent expiry notification to %s", addr)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}(address)
|
}(address)
|
||||||
}
|
}
|
||||||
@ -171,10 +179,18 @@ func (app *appContext) checkInvite(code string, used bool, username string) bool
|
|||||||
msg, err := app.email.constructExpiry(code, inv, app, false)
|
msg, err := app.email.constructExpiry(code, inv, app, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.err.Printf("%s: Failed to construct expiry notification: %v", code, err)
|
app.err.Printf("%s: Failed to construct expiry notification: %v", code, err)
|
||||||
} else if err := app.email.send(msg, addr); err != nil {
|
|
||||||
app.err.Printf("%s: Failed to send expiry notification: %v", code, err)
|
|
||||||
} else {
|
} else {
|
||||||
app.info.Printf("Sent expiry notification to %s", addr)
|
// Check whether notify "address" is an email address of Jellyfin ID
|
||||||
|
if strings.Contains(addr, "@") {
|
||||||
|
err = app.email.send(msg, addr)
|
||||||
|
} else {
|
||||||
|
err = app.sendByID(msg, addr)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
app.err.Printf("%s: Failed to send expiry notification: %v", code, err)
|
||||||
|
} else {
|
||||||
|
app.info.Printf("Sent expiry notification to %s", addr)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}(address)
|
}(address)
|
||||||
}
|
}
|
||||||
@ -470,10 +486,18 @@ func (app *appContext) newUser(req newUserDTO, confirmed bool) (f errorFunc, suc
|
|||||||
msg, err := app.email.constructCreated(req.Code, req.Username, req.Email, invite, app, false)
|
msg, err := app.email.constructCreated(req.Code, req.Username, req.Email, invite, app, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.err.Printf("%s: Failed to construct user creation notification: %v", req.Code, err)
|
app.err.Printf("%s: Failed to construct user creation notification: %v", req.Code, err)
|
||||||
} else if err := app.email.send(msg, address); err != nil {
|
|
||||||
app.err.Printf("%s: Failed to send user creation notification: %v", req.Code, err)
|
|
||||||
} else {
|
} else {
|
||||||
app.info.Printf("%s: Sent user creation notification to %v", req.Code, address)
|
// Check whether notify "address" is an email address of Jellyfin ID
|
||||||
|
if strings.Contains(address, "@") {
|
||||||
|
err = app.email.send(msg, address)
|
||||||
|
} else {
|
||||||
|
err = app.sendByID(msg, address)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
app.err.Printf("%s: Failed to send user creation notification: %v", req.Code, err)
|
||||||
|
} else {
|
||||||
|
app.info.Printf("Sent user creation notification to %s", address)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
@ -1340,15 +1364,16 @@ func (app *appContext) SetNotify(gc *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
var address string
|
var address string
|
||||||
if app.config.Section("ui").Key("jellyfin_login").MustBool(false) {
|
jellyfinLogin := app.config.Section("ui").Key("jellyfin_login").MustBool(false)
|
||||||
addr, ok := app.storage.emails[gc.GetString("jfId")]
|
if jellyfinLogin {
|
||||||
if !ok {
|
var addressAvailable bool = app.getAddressOrName(gc.GetString("jfId")) != ""
|
||||||
app.err.Printf("%s: Couldn't find email address. Make sure it's set", code)
|
if !addressAvailable {
|
||||||
|
app.err.Printf("%s: Couldn't find contact method for admin. Make sure one is set.", code)
|
||||||
app.debug.Printf("%s: User ID \"%s\"", code, gc.GetString("jfId"))
|
app.debug.Printf("%s: User ID \"%s\"", code, gc.GetString("jfId"))
|
||||||
respond(500, "Missing user email", gc)
|
respond(500, "Missing user contact method", gc)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
address = addr.Addr
|
address = gc.GetString("jfId")
|
||||||
} else {
|
} else {
|
||||||
address = app.config.Section("ui").Key("email").String()
|
address = app.config.Section("ui").Key("email").String()
|
||||||
}
|
}
|
||||||
|
@ -96,6 +96,11 @@ func (app *appContext) loadConfig() error {
|
|||||||
app.MustSetValue("user_expiry", "email_text", "jfa-go:"+"user-expired.txt")
|
app.MustSetValue("user_expiry", "email_text", "jfa-go:"+"user-expired.txt")
|
||||||
|
|
||||||
app.MustSetValue("matrix", "topic", "Jellyfin notifications")
|
app.MustSetValue("matrix", "topic", "Jellyfin notifications")
|
||||||
|
app.MustSetValue("matrix", "show_on_reg", "true")
|
||||||
|
|
||||||
|
app.MustSetValue("discord", "show_on_reg", "true")
|
||||||
|
|
||||||
|
app.MustSetValue("telegram", "show_on_reg", "true")
|
||||||
|
|
||||||
app.config.Section("jellyfin").Key("version").SetValue(version)
|
app.config.Section("jellyfin").Key("version").SetValue(version)
|
||||||
app.config.Section("jellyfin").Key("device").SetValue("jfa-go")
|
app.config.Section("jellyfin").Key("device").SetValue("jfa-go")
|
||||||
|
@ -579,10 +579,19 @@
|
|||||||
"value": false,
|
"value": false,
|
||||||
"description": "Enable signup verification through Discord and the sending of notifications through it.\nSee the jfa-go wiki for setting up a bot."
|
"description": "Enable signup verification through Discord and the sending of notifications through it.\nSee the jfa-go wiki for setting up a bot."
|
||||||
},
|
},
|
||||||
|
"show_on_reg": {
|
||||||
|
"name": "Show on user registration",
|
||||||
|
"required": false,
|
||||||
|
"requires_restart": true,
|
||||||
|
"type": "bool",
|
||||||
|
"depends_true": "enabled",
|
||||||
|
"value": true,
|
||||||
|
"description": "Allow users to link their Discord on the registration page."
|
||||||
|
},
|
||||||
"required": {
|
"required": {
|
||||||
"name": "Require on sign-up",
|
"name": "Require on sign-up",
|
||||||
"required": false,
|
"required": false,
|
||||||
"required_restart": true,
|
"requires_restart": true,
|
||||||
"depends_true": "enabled",
|
"depends_true": "enabled",
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"value": false,
|
"value": false,
|
||||||
@ -662,6 +671,15 @@
|
|||||||
"value": false,
|
"value": false,
|
||||||
"description": "Enable signup verification through Telegram and the sending of notifications through it.\nSee the jfa-go wiki for setting up a bot."
|
"description": "Enable signup verification through Telegram and the sending of notifications through it.\nSee the jfa-go wiki for setting up a bot."
|
||||||
},
|
},
|
||||||
|
"show_on_reg": {
|
||||||
|
"name": "Show on user registration",
|
||||||
|
"required": false,
|
||||||
|
"requires_restart": true,
|
||||||
|
"type": "bool",
|
||||||
|
"depends_true": "enabled",
|
||||||
|
"value": true,
|
||||||
|
"description": "Allow users to link their Telegram on the registration page."
|
||||||
|
},
|
||||||
"required": {
|
"required": {
|
||||||
"name": "Require on sign-up",
|
"name": "Require on sign-up",
|
||||||
"required": false,
|
"required": false,
|
||||||
@ -709,6 +727,15 @@
|
|||||||
"value": false,
|
"value": false,
|
||||||
"description": "Enable signup verification through Matrix and the sending of notifications through it.\nSee the jfa-go wiki for setting up a bot."
|
"description": "Enable signup verification through Matrix and the sending of notifications through it.\nSee the jfa-go wiki for setting up a bot."
|
||||||
},
|
},
|
||||||
|
"show_on_reg": {
|
||||||
|
"name": "Show on user registration",
|
||||||
|
"required": false,
|
||||||
|
"requires_restart": true,
|
||||||
|
"type": "bool",
|
||||||
|
"depends_true": "enabled",
|
||||||
|
"value": true,
|
||||||
|
"description": "Allow users to link their Matrix on the registration page."
|
||||||
|
},
|
||||||
"required": {
|
"required": {
|
||||||
"name": "Require on sign-up",
|
"name": "Require on sign-up",
|
||||||
"required": false,
|
"required": false,
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
"settingsRequiredOrRestartMessage": "Opmerking: {n} is een verplicht veld, {n} geeft aan dat na wijzigen een herstart nodig is.",
|
"settingsRequiredOrRestartMessage": "Opmerking: {n} is een verplicht veld, {n} geeft aan dat na wijzigen een herstart nodig is.",
|
||||||
"settingsSave": "Opslaan",
|
"settingsSave": "Opslaan",
|
||||||
"ombiUserDefaults": "Ombi gebruiker standaardinstellingen",
|
"ombiUserDefaults": "Ombi gebruiker standaardinstellingen",
|
||||||
"ombiUserDefaultsDescription": "Maak een Ombi gebruiker aan met de gewenste instellingen, en selecteer deze hieronder. Deze instellingen/rechten worden opgeslagen en toegepast voor nieuwe Ombi gebruikers die jfa-go aanmaakt",
|
"ombiUserDefaultsDescription": "Maak een Ombi gebruiker aan met de gewenste instellingen, en selecteer deze hieronder. Deze instellingen/rechten worden opgeslagen en toegepast voor nieuwe Ombi gebruikers die jfa-go aanmaakt als dit profiel is geselecteerd.",
|
||||||
"userProfiles": "Gebruikersprofielen",
|
"userProfiles": "Gebruikersprofielen",
|
||||||
"userProfilesDescription": "Profielen worden toegepast op gebruikers wanneer ze een account aanmaken. Een profiel bevat rechten voor bibliotheken en indeling van de startpagina.",
|
"userProfilesDescription": "Profielen worden toegepast op gebruikers wanneer ze een account aanmaken. Een profiel bevat rechten voor bibliotheken en indeling van de startpagina.",
|
||||||
"userProfilesIsDefault": "Standaard",
|
"userProfilesIsDefault": "Standaard",
|
||||||
@ -110,7 +110,8 @@
|
|||||||
"sendPWRSuccessManual": "Als de gebruiker hem niet heeft ontvangen, druk dan op kopiëren om een link te krijgen die je handmatig kunt sturen.",
|
"sendPWRSuccessManual": "Als de gebruiker hem niet heeft ontvangen, druk dan op kopiëren om een link te krijgen die je handmatig kunt sturen.",
|
||||||
"sendPWR": "Verstuur wachtwoordreset",
|
"sendPWR": "Verstuur wachtwoordreset",
|
||||||
"sendPWRSuccess": "Wachtwoordreset-link verstuurd.",
|
"sendPWRSuccess": "Wachtwoordreset-link verstuurd.",
|
||||||
"sendPWRValidFor": "De link is 30m geldig."
|
"sendPWRValidFor": "De link is 30m geldig.",
|
||||||
|
"ombiProfile": "Ombi gebruikersprofiel"
|
||||||
},
|
},
|
||||||
"notifications": {
|
"notifications": {
|
||||||
"changedEmailAddress": "E-mailadres van {n} gewijzigd.",
|
"changedEmailAddress": "E-mailadres van {n} gewijzigd.",
|
||||||
@ -151,7 +152,9 @@
|
|||||||
"telegramVerified": "Telegram-account goedgekeurd.",
|
"telegramVerified": "Telegram-account goedgekeurd.",
|
||||||
"updateAppliedRefresh": "Update toegepast, ververs alsjeblieft.",
|
"updateAppliedRefresh": "Update toegepast, ververs alsjeblieft.",
|
||||||
"accountConnected": "Account gekoppeld.",
|
"accountConnected": "Account gekoppeld.",
|
||||||
"savedAnnouncement": "Aankondiging opgeslagen."
|
"savedAnnouncement": "Aankondiging opgeslagen.",
|
||||||
|
"setOmbiProfile": "Opgeslagen ombi-profiel.",
|
||||||
|
"errorSetOmbiProfile": "Opslaan van ombi-profiel mislukt."
|
||||||
},
|
},
|
||||||
"quantityStrings": {
|
"quantityStrings": {
|
||||||
"modifySettingsFor": {
|
"modifySettingsFor": {
|
||||||
|
@ -12,14 +12,14 @@
|
|||||||
"title": "Notice: User created",
|
"title": "Notice: User created",
|
||||||
"aUserWasCreated": "A user was created using code {code}.",
|
"aUserWasCreated": "A user was created using code {code}.",
|
||||||
"time": "Time",
|
"time": "Time",
|
||||||
"notificationNotice": "Note: Notification emails can be toggled on the admin dashboard."
|
"notificationNotice": "Note: Notification messages can be toggled on the admin dashboard."
|
||||||
},
|
},
|
||||||
"inviteExpiry": {
|
"inviteExpiry": {
|
||||||
"name": "Invite expiry",
|
"name": "Invite expiry",
|
||||||
"title": "Notice: Invite expired",
|
"title": "Notice: Invite expired",
|
||||||
"inviteExpired": "Invite expired.",
|
"inviteExpired": "Invite expired.",
|
||||||
"expiredAt": "Code {code} expired at {time}.",
|
"expiredAt": "Code {code} expired at {time}.",
|
||||||
"notificationNotice": "Note: Notification emails can be toggled on the admin dashboard."
|
"notificationNotice": "Note: Notification messages can be toggled on the admin dashboard."
|
||||||
},
|
},
|
||||||
"passwordReset": {
|
"passwordReset": {
|
||||||
"name": "Password reset",
|
"name": "Password reset",
|
||||||
|
@ -13,6 +13,7 @@ func runMigrations(app *appContext) {
|
|||||||
migrateProfiles(app)
|
migrateProfiles(app)
|
||||||
migrateBootstrap(app)
|
migrateBootstrap(app)
|
||||||
migrateEmailStorage(app)
|
migrateEmailStorage(app)
|
||||||
|
migrateNotificationMethods(app)
|
||||||
// migrateHyphens(app)
|
// migrateHyphens(app)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,6 +124,40 @@ func migrateEmailStorage(app *appContext) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pre-0.3.10, Admin notifications for invites were indexed by and only sent to email addresses. Now, when Jellyfin Login is enabled, They are indexed by the admin's Jellyfin ID, and send by any method enabled for them. This migrates storage to that format.
|
||||||
|
func migrateNotificationMethods(app *appContext) error {
|
||||||
|
if !app.config.Section("ui").Key("jellyfin_login").MustBool(false) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
changes := false
|
||||||
|
for code, invite := range app.storage.invites {
|
||||||
|
if invite.Notify == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
for address, notifyPrefs := range invite.Notify {
|
||||||
|
if !strings.Contains(address, "@") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
for id, email := range app.storage.emails {
|
||||||
|
if email.Addr == address {
|
||||||
|
invite.Notify[id] = notifyPrefs
|
||||||
|
delete(invite.Notify, address)
|
||||||
|
changes = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if changes {
|
||||||
|
app.storage.invites[code] = invite
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if changes {
|
||||||
|
app.info.Printf("Migrated to modified invite storage format.")
|
||||||
|
return app.storage.storeInvites()
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Migrate between hyphenated & non-hyphenated user IDs. Doesn't seem to happen anymore, so disabled.
|
// Migrate between hyphenated & non-hyphenated user IDs. Doesn't seem to happen anymore, so disabled.
|
||||||
// func migrateHyphens(app *appContext) {
|
// func migrateHyphens(app *appContext) {
|
||||||
// checkVersion := func(version string) int {
|
// checkVersion := func(version string) int {
|
||||||
|
@ -32,7 +32,7 @@ interface Setting {
|
|||||||
const splitDependant = (section: string, dep: string): string[] => {
|
const splitDependant = (section: string, dep: string): string[] => {
|
||||||
let parts = dep.split("|");
|
let parts = dep.split("|");
|
||||||
if (parts.length == 1) {
|
if (parts.length == 1) {
|
||||||
parts = [section, parts[0]];
|
parts = [section, dep];
|
||||||
}
|
}
|
||||||
return parts
|
return parts
|
||||||
};
|
};
|
||||||
|
16
views.go
16
views.go
@ -327,6 +327,10 @@ func (app *appContext) InviteProxy(gc *gin.Context) {
|
|||||||
if strings.Contains(email, "Failed") || !strings.Contains(email, "@") {
|
if strings.Contains(email, "Failed") || !strings.Contains(email, "@") {
|
||||||
email = ""
|
email = ""
|
||||||
}
|
}
|
||||||
|
telegram := telegramEnabled && app.config.Section("telegram").Key("show_on_reg").MustBool(true)
|
||||||
|
discord := discordEnabled && app.config.Section("discord").Key("show_on_reg").MustBool(true)
|
||||||
|
matrix := matrixEnabled && app.config.Section("matrix").Key("show_on_reg").MustBool(true)
|
||||||
|
|
||||||
data := gin.H{
|
data := gin.H{
|
||||||
"urlBase": app.getURLBase(gc),
|
"urlBase": app.getURLBase(gc),
|
||||||
"cssClass": app.cssClass,
|
"cssClass": app.cssClass,
|
||||||
@ -351,21 +355,21 @@ func (app *appContext) InviteProxy(gc *gin.Context) {
|
|||||||
"userExpiryMessage": app.storage.lang.Form[lang].Strings.get("yourAccountIsValidUntil"),
|
"userExpiryMessage": app.storage.lang.Form[lang].Strings.get("yourAccountIsValidUntil"),
|
||||||
"langName": lang,
|
"langName": lang,
|
||||||
"passwordReset": false,
|
"passwordReset": false,
|
||||||
"telegramEnabled": telegramEnabled,
|
"telegramEnabled": telegram,
|
||||||
"discordEnabled": discordEnabled,
|
"discordEnabled": discord,
|
||||||
"matrixEnabled": matrixEnabled,
|
"matrixEnabled": matrix,
|
||||||
}
|
}
|
||||||
if telegramEnabled {
|
if telegram {
|
||||||
data["telegramPIN"] = app.telegram.NewAuthToken()
|
data["telegramPIN"] = app.telegram.NewAuthToken()
|
||||||
data["telegramUsername"] = app.telegram.username
|
data["telegramUsername"] = app.telegram.username
|
||||||
data["telegramURL"] = app.telegram.link
|
data["telegramURL"] = app.telegram.link
|
||||||
data["telegramRequired"] = app.config.Section("telegram").Key("required").MustBool(false)
|
data["telegramRequired"] = app.config.Section("telegram").Key("required").MustBool(false)
|
||||||
}
|
}
|
||||||
if matrixEnabled {
|
if matrix {
|
||||||
data["matrixRequired"] = app.config.Section("matrix").Key("required").MustBool(false)
|
data["matrixRequired"] = app.config.Section("matrix").Key("required").MustBool(false)
|
||||||
data["matrixUser"] = app.matrix.userID
|
data["matrixUser"] = app.matrix.userID
|
||||||
}
|
}
|
||||||
if discordEnabled {
|
if discord {
|
||||||
data["discordPIN"] = app.discord.NewAuthToken()
|
data["discordPIN"] = app.discord.NewAuthToken()
|
||||||
data["discordUsername"] = app.discord.username
|
data["discordUsername"] = app.discord.username
|
||||||
data["discordRequired"] = app.config.Section("discord").Key("required").MustBool(false)
|
data["discordRequired"] = app.config.Section("discord").Key("required").MustBool(false)
|
||||||
|
Loading…
Reference in New Issue
Block a user