logmessages: all log strings in one file
EXCEPT: migrations.go, log strings there aren't gonna be repeated anywhere else, are very specific, and will probably change a lot.
This commit is contained in:
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"time"
|
||||
|
||||
lm "github.com/hrfee/jfa-go/logmessages"
|
||||
"github.com/hrfee/mediabrowser"
|
||||
"github.com/lithammer/shortuuid/v3"
|
||||
)
|
||||
@@ -21,17 +22,17 @@ func (app *appContext) checkUsers() {
|
||||
if len(app.storage.GetUserExpiries()) == 0 {
|
||||
return
|
||||
}
|
||||
app.info.Println("Daemon: Checking for user expiry")
|
||||
app.info.Println(lm.CheckUserExpiries)
|
||||
users, status, err := app.jf.GetUsers(false)
|
||||
if err != nil || status != 200 {
|
||||
app.err.Printf("Failed to get users (%d): %s", status, err)
|
||||
app.err.Printf(lm.FailedGetUsers, lm.Jellyfin, err)
|
||||
return
|
||||
}
|
||||
mode := "disable"
|
||||
term := "Disabling"
|
||||
phrase := lm.DisableExpiredUser
|
||||
if app.config.Section("user_expiry").Key("behaviour").MustString("disable_user") == "delete_user" {
|
||||
mode = "delete"
|
||||
term = "Deleting"
|
||||
phrase = lm.DeleteExpiredUser
|
||||
}
|
||||
contact := false
|
||||
if messagesEnabled && app.config.Section("user_expiry").Key("send_email").MustBool(true) {
|
||||
@@ -45,7 +46,7 @@ func (app *appContext) checkUsers() {
|
||||
for _, expiry := range app.storage.GetUserExpiries() {
|
||||
id := expiry.JellyfinID
|
||||
if _, ok := userExists[id]; !ok {
|
||||
app.info.Printf("Deleting expiry for non-existent user \"%s\"", id)
|
||||
app.info.Printf(lm.DeleteExpiryForOldUser, id)
|
||||
app.storage.DeleteUserExpiryKey(expiry.JellyfinID)
|
||||
} else if time.Now().After(expiry.Expiry) {
|
||||
found := false
|
||||
@@ -58,11 +59,10 @@ func (app *appContext) checkUsers() {
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
app.info.Printf("Expired user already deleted, ignoring.")
|
||||
app.storage.DeleteUserExpiryKey(expiry.JellyfinID)
|
||||
continue
|
||||
}
|
||||
app.info.Printf("%s expired user \"%s\"", term, user.Name)
|
||||
app.info.Printf(phrase, user.Name)
|
||||
|
||||
// Record activity
|
||||
activity := Activity{
|
||||
@@ -83,7 +83,7 @@ func (app *appContext) checkUsers() {
|
||||
activity.Type = ActivityDisabled
|
||||
}
|
||||
if !(status == 200 || status == 204) || err != nil {
|
||||
app.err.Printf("Failed to %s \"%s\" (%d): %s", mode, user.Name, status, err)
|
||||
app.err.Printf(lm.FailedDeleteOrDisableExpiredUser, user.ID, err)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -98,11 +98,11 @@ func (app *appContext) checkUsers() {
|
||||
name := app.getAddressOrName(user.ID)
|
||||
msg, err := app.email.constructUserExpired(app, false)
|
||||
if err != nil {
|
||||
app.err.Printf("Failed to construct expiry message for \"%s\": %s", user.Name, err)
|
||||
app.err.Printf(lm.FailedConstructExpiryMessage, user.ID, err)
|
||||
} else if err := app.sendByID(msg, user.ID); err != nil {
|
||||
app.err.Printf("Failed to send expiry message to \"%s\": %s", name, err)
|
||||
app.err.Printf(lm.FailedConstructExpiryMessage, user.ID, name, err)
|
||||
} else {
|
||||
app.info.Printf("Sent expiry notification to \"%s\"", name)
|
||||
app.err.Printf(lm.SentExpiryMessage, user.ID, name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user