userpage: make pwr accept username too

This commit is contained in:
Harvey Tindall
2023-06-22 12:33:40 +01:00
parent 3ec3e9672e
commit 22c91be127
5 changed files with 13 additions and 7 deletions
+7 -1
View File
@@ -872,7 +872,13 @@ func (app *appContext) getAddressOrName(jfID string) string {
return ""
}
func (app *appContext) reverseUserSearch(address string) string {
// ReverseUserSearch returns the jellyfin ID of the user with the given username, email, or contact method username.
// returns "" if none found. returns only the first match, might be an issue if there are users with the same contact method usernames.
func (app *appContext) ReverseUserSearch(address string) string {
user, status, err := app.jf.UserByName(address, false)
if status == 200 && err == nil {
return user.ID
}
for id, email := range app.storage.GetEmails() {
if strings.ToLower(address) == strings.ToLower(email.Addr) {
return id