jellyseerr: add user modification methods

addded permissions get/set before realizing it already comes as part of
the User object. Split User attributes that will be templated into
UserTemplate struct, which User inherits. ApplyTemplateToUser takes a
UserTemplate, while ModifyUser takes a plain map with some typed fields
(display name and email, for now).
This commit is contained in:
Harvey Tindall
2024-07-29 17:36:29 +01:00
parent 9c34192b4f
commit 73e985c45c
3 changed files with 137 additions and 11 deletions
+23 -6
View File
@@ -2,8 +2,15 @@ package jellyseerr
import "time"
type UserField string
const (
FieldDisplayName UserField = "displayName"
FieldEmail UserField = "email"
)
type User struct {
Permissions int `json:"permissions"`
UserTemplate // Note: You can set this with User.UserTemplate = value.
Warnings []any `json:"warnings"`
ID int `json:"id"`
Email string `json:"email"`
@@ -11,23 +18,27 @@ type User struct {
JellyfinUsername string `json:"jellyfinUsername"`
Username string `json:"username"`
RecoveryLinkExpirationDate any `json:"recoveryLinkExpirationDate"`
UserType int `json:"userType"`
PlexID string `json:"plexId"`
JellyfinUserID string `json:"jellyfinUserId"`
JellyfinDeviceID string `json:"jellyfinDeviceId"`
JellyfinAuthToken string `json:"jellyfinAuthToken"`
PlexToken string `json:"plexToken"`
Avatar string `json:"avatar"`
MovieQuotaLimit any `json:"movieQuotaLimit"`
MovieQuotaDays any `json:"movieQuotaDays"`
TvQuotaLimit any `json:"tvQuotaLimit"`
TvQuotaDays any `json:"tvQuotaDays"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
RequestCount int `json:"requestCount"`
DisplayName string `json:"displayName"`
}
type UserTemplate struct {
Permissions Permissions `json:"permissions"`
UserType int `json:"userType"`
MovieQuotaLimit any `json:"movieQuotaLimit"`
MovieQuotaDays any `json:"movieQuotaDays"`
TvQuotaLimit any `json:"tvQuotaLimit"`
TvQuotaDays any `json:"tvQuotaDays"`
}
type PageInfo struct {
Pages int `json:"pages"`
PageSize int `json:"pageSize"`
@@ -39,3 +50,9 @@ type GetUsersDTO struct {
Page PageInfo `json:"pageInfo"`
Results []User `json:"results"`
}
type permissionsDTO struct {
Permissions Permissions `json:"permissions"`
}
type Permissions int