Repository navigation
Expand file tree
/
Copy pathmodels.go
More file actions
547 lines (455 loc) · 21.8 KB
/
Copy pathmodels.go
File metadata and controls
547 lines (455 loc) · 21.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
package main
import (
"time"
"github.com/hrfee/mediabrowser"
)
type stringResponse struct {
Response string `json:"response" example:"message"`
Error/*Text*/ string `json:"error" example:"No special symbols allowed."`
// ErrorCode string `json:"error_code" example:"errorSpecialSymbols"`
}
type boolResponse struct {
Success bool `json:"success" example:"false"`
Error bool `json:"error" example:"true"`
}
type newUserDTO struct {
Username string `json:"username" example:"jeff" binding:"required"` // User's username
Password string `json:"password" example:"guest" binding:"required"` // User's password
Email string `json:"email" example:"jeff@jellyf.in"` // User's email address
EmailContact bool `json:"email_contact"` // Whether or not to use email for notifications/pwrs
Code string `json:"code" example:"abc0933jncjkcjj"` // Invite code (required on /newUser)
TelegramPIN string `json:"telegram_pin" example:"A1-B2-3C"` // Telegram verification PIN (if used)
TelegramContact bool `json:"telegram_contact"` // Whether or not to use telegram for notifications/pwrs
DiscordPIN string `json:"discord_pin" example:"A1-B2-3C"` // Discord verification PIN (if used)
DiscordContact bool `json:"discord_contact"` // Whether or not to use discord for notifications/pwrs
MatrixPIN string `json:"matrix_pin" example:"A1-B2-3C"` // Matrix verification PIN (if used)
MatrixContact bool `json:"matrix_contact"` // Whether or not to use matrix for notifications/pwrs
CaptchaID string `json:"captcha_id"` // Captcha ID (if enabled)
CaptchaText string `json:"captcha_text"` // Captcha text (if enabled)
Profile string `json:"profile"` // Profile (for admins only)
}
type newUserResponse struct {
User bool `json:"user" binding:"required"` // Whether user was created successfully
Email bool `json:"email"` // Whether welcome email was successfully sent (always true if feature is disabled)
Error string `json:"error"` // Optional error message.
}
type deleteUserDTO struct {
Users []string `json:"users" binding:"required"` // List of user IDs.
Notify bool `json:"notify"` // Whether to notify users of deletion
Reason string `json:"reason"` // Account deletion reason (for notification)
}
type enableDisableUserDTO struct {
Users []string `json:"users" binding:"required"` // List of userIDs.
Enabled bool `json:"enabled"` // True = enable users, False = disable.
Notify bool `json:"notify"` // Whether to notify users of deletion
Reason string `json:"reason"` // Account deletion reason (for notification)
}
type generateInviteDTO struct {
Months int `json:"months" example:"0"` // Number of months
Days int `json:"days" example:"1"` // Number of days
Hours int `json:"hours" example:"2"` // Number of hours
Minutes int `json:"minutes" example:"3"` // Number of minutes
UserExpiry bool `json:"user-expiry"` // Whether or not user expiry is enabled
UserMonths int `json:"user-months,omitempty" example:"1"` // Number of months till user expiry
UserDays int `json:"user-days,omitempty" example:"1"` // Number of days till user expiry
UserHours int `json:"user-hours,omitempty" example:"2"` // Number of hours till user expiry
UserMinutes int `json:"user-minutes,omitempty" example:"3"` // Number of minutes till user expiry
sendInviteDTO
MultipleUses bool `json:"multiple-uses" example:"true"` // Allow multiple uses
NoLimit bool `json:"no-limit" example:"false"` // No invite use limit
RemainingUses int `json:"remaining-uses" example:"5"` // Remaining invite uses
Profile string `json:"profile" example:"DefaultProfile"` // Name of profile to apply on this invite
Label string `json:"label" example:"For Friends"` // Optional label for the invite
UserLabel string `json:"user_label,omitempty" example:"Friend"` // Label to apply to users created w/ this invite.
}
type SendInviteDTO struct {
Invite string `json:"invite" example:"slakdaslkdl2342"` // Invite to apply to
sendInviteDTO
}
type sendInviteDTO struct {
SendTo string `json:"send-to" example:"jeff@jellyf.in"` // Send invite to this address or discord name
}
type profileDTO struct {
Admin bool `json:"admin" example:"false"` // Whether profile has admin rights or not
LibraryAccess string `json:"libraries" example:"all"` // Number of libraries profile has access to
FromUser string `json:"fromUser" example:"jeff"` // The user the profile is based on
Ombi bool `json:"ombi"` // Whether or not Ombi settings are stored in this profile.
Jellyseerr bool `json:"jellyseerr"` // Whether or not Jellyseerr settings are stored in this profile.
ReferralsEnabled bool `json:"referrals_enabled" example:"true"` // Whether or not the profile has referrals enabled, and has a template invite stored.
}
type getProfilesDTO struct {
Profiles map[string]profileDTO `json:"profiles"`
DefaultProfile string `json:"default_profile"`
}
type getProfileNamesDTO struct {
Profiles []string `json:"profiles"` // List of profiles (name only)
}
type profileChangeDTO struct {
Name string `json:"name" example:"DefaultProfile" binding:"required"` // Name of the profile
}
type newProfileDTO struct {
Name string `json:"name" example:"DefaultProfile" binding:"required"` // Name of the profile
ID string `json:"id" example:"ZXhhbXBsZTEyMzQ1Njc4OQo" binding:"required"` // ID of user to source settings from
Homescreen bool `json:"homescreen" example:"true"` // Whether to store homescreen layout or not
OmbiID string `json:"ombi_id" example:"ZXhhbXBsZTEyMzQ1Njc4OQo"` // ID of Ombi user to source settings from (optional)
Jellyseerr bool `json:"jellyseerr"` // Whether or not to generate Jellyseerr profile from user
}
type inviteDTO struct {
EditableInviteDTO
ValidTill int64 `json:"valid_till" example:"1617737207510"` // Unix timestamp of expiry
Created int64 `json:"created" example:"1617737207510"` // Date of creation
UsedBy map[string]int64 `json:"used_by,omitempty"` // Users who have used this invite mapped to their creation time in Epoch/Unix time
NoLimit bool `json:"no_limit"` // If true, invite can be used any number of times
RemainingUses int `json:"remaining_uses,omitempty"` // Remaining number of uses (if applicable)
SendTo string `json:"send_to,omitempty"` // DEPRECATED Email/Discord username the invite was sent to (if applicable)
SentTo SentToList `json:"sent_to,omitempty"` // Email/Discord usernames attempts were made to send this invite to, and a failure reason if failed.
}
type EditableInviteDTO struct {
Code string `json:"code" example:"sajdlj23423j23"` // Invite code
NotifyExpiry *bool `json:"notify_expiry,omitempty"` // Whether to notify the requesting user of expiry or not
NotifyCreation *bool `json:"notify_creation,omitempty"` // Whether to notify the requesting user of account creation or not
Label *string `json:"label,omitempty" example:"For Friends"` // Optional label for the invite
UserLabel *string `json:"user_label,omitempty" example:"Friend"` // Label to apply to users created w/ this invite.
Profile *string `json:"profile" example:"DefaultProfile"` // Profile used on this invite
UserExpiry *bool `json:"user_expiry"` // Whether or not user expiry is enabled
UserMonths *int `json:"user_months,omitempty" example:"1"` // Number of months till user expiry
UserDays *int `json:"user_days,omitempty" example:"1"` // Number of days till user expiry
UserHours *int `json:"user_hours,omitempty" example:"2"` // Number of hours till user expiry
UserMinutes *int `json:"user_minutes,omitempty" example:"3"` // Number of minutes till user expiry
}
type getInvitesDTO struct {
Invites []inviteDTO `json:"invites"` // List of invites
}
// fake DTO, if i actually used this the code would be a lot longer
type setNotifyValues map[string]struct {
NotifyExpiry bool `json:"notify-expiry,omitempty"` // Whether to notify the requesting user of expiry or not
NotifyCreation bool `json:"notify-creation,omitempty"` // Whether to notify the requesting user of account creation or not
}
type setNotifyDTO map[string]setNotifyValues
type deleteInviteDTO struct {
Code string `json:"code" example:"skjadajd43234s"` // Code of invite to delete
}
type respUser struct {
ID string `json:"id" example:"fdgsdfg45534fa"` // userID of user
Name string `json:"name" example:"jeff"` // Username of user
Email string `json:"email,omitempty" example:"jeff@jellyf.in"` // Email address of user (if available)
NotifyThroughEmail bool `json:"notify_email"`
LastActive int64 `json:"last_active" example:"1617737207510"` // Time of last activity on Jellyfin
Admin bool `json:"admin" example:"false"` // Whether or not the user is Administrator
Expiry int64 `json:"expiry" example:"1617737207510"` // Expiry time of user as Epoch/Unix time.
Disabled bool `json:"disabled"` // Whether or not the user is disabled.
Telegram string `json:"telegram"` // Telegram username (if known)
NotifyThroughTelegram bool `json:"notify_telegram"`
Discord string `json:"discord"` // Discord username (if known)
DiscordID string `json:"discord_id"` // Discord user ID for creating links.
NotifyThroughDiscord bool `json:"notify_discord"`
Matrix string `json:"matrix"` // Matrix ID (if known)
NotifyThroughMatrix bool `json:"notify_matrix"`
Label string `json:"label"` // Label of user, shown next to their name.
AccountsAdmin bool `json:"accounts_admin"` // Whether or not the user is a jfa-go admin.
ReferralsEnabled bool `json:"referrals_enabled"`
}
// ServerSearchReqDTO is a usual SortablePaginatedReqDTO with added fields for searching and filtering.
type ServerSearchReqDTO struct {
SortablePaginatedReqDTO
ServerFilterReqDTO
}
// ServerFilterReqDTO provides search terms and queries to a search or count route.
type ServerFilterReqDTO struct {
SearchTerms []string `json:"searchTerms"`
Queries []QueryDTO `json:"queries"`
}
type PaginatedDTO struct {
LastPage bool `json:"last_page"`
}
type SortablePaginatedReqDTO struct {
SortByField string `json:"sortByField"`
Ascending bool `json:"ascending"`
PaginatedReqDTO
}
type PaginatedReqDTO struct {
Limit int `json:"limit"`
Page int `json:"page"` // zero-indexed
}
type getUsersDTO struct {
UserList []*respUser `json:"users"`
LastPage bool `json:"last_page"`
}
type ombiUser struct {
Name string `json:"name,omitempty" example:"jeff"` // Name of Ombi user
ID string `json:"id" example:"djgkjdg7dkjfsj8"` // userID of Ombi user
}
type ombiUsersDTO struct {
Users []ombiUser `json:"users"`
}
type modifyEmailsDTO map[string]string
type userSettingsDTO struct {
From string `json:"from"` // Whether to apply from "user" or "profile"
Profile string `json:"profile"` // Name of profile (if from = "profile")
ApplyTo []string `json:"apply_to"` // Users to apply settings to
ID string `json:"id"` // ID of user (if from = "user")
// Note confusing name: "Configuration" on the admin UI just means it in the sense
// of the account's settings.
Policy bool `json:"configuration"` // Whether to apply jf policy not
Homescreen bool `json:"homescreen"` // Whether to apply homescreen layout or not
Ombi bool `json:"ombi"` // Whether to apply ombi profile or not
Jellyseerr bool `json:"jellyseerr"` // Whether to apply jellyseerr profile or not
}
type announcementDTO struct {
Users []string `json:"users"` // List of User IDs to send announcement to
Subject string `json:"subject"` // Email subject
Message string `json:"message"` // Email content (markdown supported)
}
type announcementTemplate struct {
Name string `json:"name"` // Name of template
Subject string `json:"subject"` // Email subject
Message string `json:"message"` // Email content (markdown supported)
}
type getAnnouncementsDTO struct {
Announcements []string `json:"announcements"` // list of announcement names.
}
type errorListDTO map[string]map[string]string
type configDTO map[string]interface{}
type langDTO map[string]string
type emailListDTO map[string]emailListEl
type emailListEl struct {
Name string `json:"name"`
Enabled bool `json:"enabled"`
Description string `json:"description"`
}
type emailSetDTO struct {
Content string `json:"content"`
}
type emailTestDTO struct {
Address string `json:"address"`
}
type customEmailDTO struct {
Content string `json:"content"`
Variables []string `json:"variables"`
Conditionals []string `json:"conditionals"`
Values map[string]interface{} `json:"values"`
HTML string `json:"html"`
Plaintext string `json:"plaintext"`
}
type extendExpiryDTO struct {
Users []string `json:"users"` // List of user IDs to apply to.
Months int `json:"months,omitempty" example:"1"` // Number of months to add.
Days int `json:"days,omityempty" example:"1"` // Number of days to add.
Hours int `json:"hours,omitempty" example:"2"` // Number of hours to add.
Minutes int `json:"minutes,omitempty" example:"3"` // Number of minutes to add.
Timestamp int64 `json:"timestamp,omitempty"` // Optional, exact time to expire at. Overrides other fields.
Notify bool `json:"notify"` // Whether to message the user(s) about the change.
Reason string `json:"reason,omitempty" example:"i felt like it"` // Optional, reason for adjustment.
TryExtendFromPreviousExpiry bool `json:"try_extend_from_previous_expiry,omitempty"` // If an activity log of the expiry of a disabled user is available, extend the expiry from that instead of the current time.
}
type checkUpdateDTO struct {
New bool `json:"new"` // Whether or not there's a new update.
Update Update `json:"update"`
}
type telegramPinDTO struct {
Token string `json:"token" example:"A1-B2-3C"`
Username string `json:"username"`
}
type telegramSetDTO struct {
Token string `json:"token" example:"A1-B2-3C"`
ID string `json:"id"` // Jellyfin ID of user.
}
type SetContactPreferencesDTO struct {
ID string `json:"id"`
Email bool `json:"email"`
Discord bool `json:"discord"`
Telegram bool `json:"telegram"`
Matrix bool `json:"matrix"`
}
type DiscordUserDTO struct {
Name string `json:"name"`
AvatarURL string `json:"avatar_url"`
ID string `json:"id"`
}
type DiscordUsersDTO struct {
Users []DiscordUserDTO `json:"users"`
}
type DiscordConnectUserDTO struct {
JellyfinID string `json:"jf_id"`
DiscordID string `json:"discord_id"`
}
type DiscordInviteDTO struct {
InviteURL string `json:"invite"`
IconURL string `json:"icon"`
}
type MatrixSendPINDTO struct {
UserID string `json:"user_id"`
}
type MatrixCheckPINDTO struct {
PIN string `json:"pin"`
}
type MatrixConnectUserDTO struct {
JellyfinID string `json:"jf_id"`
UserID string `json:"user_id"`
}
type MatrixLoginDTO struct {
Homeserver string `json:"homeserver"`
Username string `json:"username"`
Password string `json:"password"`
}
type ResetPasswordDTO struct {
PIN string `json:"pin"`
Password string `json:"password"`
CaptchaText string `json:"captcha_text"`
}
type AdminPasswordResetDTO struct {
Users []string `json:"users"` // List of Jellyfin user IDs
}
type AdminPasswordResetRespDTO struct {
Link string `json:"link"` // Only returned if one of the given users doesn't have a contact method set, or only one user was requested.
Manual bool `json:"manual"` // Whether or not the admin has to send the link manually or not.
}
// InternalPWR stores a local version of a password reset PIN used for resets triggered by the admin when reset links are enabled.
type InternalPWR struct {
PIN string `json:"pin"`
Username string `json:"username"`
ID string `json:"id"`
Expiry time.Time `json:"expiry"`
}
type LogDTO struct {
Log string `json:"log"`
}
type setAccountsAdminDTO map[string]bool
type genCaptchaDTO struct {
ID string `json:"id"`
}
type forUserDTO struct {
ID string `json:"id"` // Jellyfin ID
}
// ReCaptchaRequestDTO is sent to /api/siteverify, and includes the identifier of the CAPTCHA data is requested for.
type ReCaptchaRequestDTO struct {
Secret string `json:"secret"`
Response string `json:"response"`
}
// ReCaptchaResponseDTO is returned upon POST to reCAPTCHA /api/siteverify, and gives details upon the use of a CAPTCHA.
type ReCaptchaResponseDTO struct {
Success bool `json:"success"`
ChallengeTimestamp string `json:"challenge_ts"` // ISO yyyy-MM-dd'T'HH:mm:ssZZ
Hostname string `json:"hostname"`
ErrorCodes []string `json:"error-codes"`
}
// MyDetailsDTO is sent to the user page to personalize it for the user.
type MyDetailsDTO struct {
Id string `json:"id"`
Username string `json:"username"`
Expiry int64 `json:"expiry"`
Admin bool `json:"admin"`
AccountsAdmin bool `json:"accounts_admin"`
Disabled bool `json:"disabled"`
Email *MyDetailsContactMethodsDTO `json:"email,omitempty"`
Discord *MyDetailsContactMethodsDTO `json:"discord,omitempty"`
Telegram *MyDetailsContactMethodsDTO `json:"telegram,omitempty"`
Matrix *MyDetailsContactMethodsDTO `json:"matrix,omitempty"`
HasReferrals bool `json:"has_referrals,omitempty"`
}
type MyDetailsContactMethodsDTO struct {
Value string `json:"value"`
Enabled bool `json:"enabled"`
}
type ModifyMyEmailDTO struct {
Email string `json:"email"`
}
type ConfirmationTarget int
const (
UserEmailChange ConfirmationTarget = iota
NoOp
)
type GetMyPINDTO struct {
PIN string `json:"pin"`
}
type ChangeMyPasswordDTO struct {
Old string `json:"old"`
New string `json:"new"`
}
type GetMyReferralRespDTO struct {
Code string `json:"code"`
RemainingUses int `json:"remaining_uses"`
NoLimit bool `json:"no_limit"`
Expiry int64 `json:"expiry"` // Come back after this time to get a new referral (if UseExpiry, a new one can't be made).
UseExpiry bool `json:"use_expiry"`
}
type EnableDisableReferralDTO struct {
Users []string `json:"users"`
}
type ActivityDTO struct {
ID string `json:"id"`
Type string `json:"type"`
UserID string `json:"user_id"`
Username string `json:"username"`
SourceType string `json:"source_type"`
Source string `json:"source"`
SourceUsername string `json:"source_username"`
InviteCode string `json:"invite_code"`
Value string `json:"value"`
Time int64 `json:"time"`
IP string `json:"ip"`
}
type GetActivitiesRespDTO struct {
PaginatedDTO
Activities []ActivityDTO `json:"activities"`
}
type PageCountDTO struct {
Count uint64 `json:"count"`
}
type CreateBackupDTO struct {
Size string `json:"size"`
Name string `json:"name"`
Path string `json:"path"`
Date int64 `json:"date"`
Commit string `json:"commit"`
}
type GetBackupsDTO struct {
Backups []CreateBackupDTO `json:"backups"`
}
type ConfirmationKey struct {
newUserDTO
completeContactMethods []ContactMethodKey
}
type ContactMethodKey struct {
Verified bool
PIN string
User ContactMethodUser
}
type PagePaths struct {
// The base subfolder the app is hosted on.
Base string `json:"Base"`
// Those for other pages
Admin string `json:"Admin"`
MyAccount string `json:"MyAccount"`
Form string `json:"Form"`
}
type PagePathsDTO struct {
PagePaths
// The subdirectory this bit of the app is hosted on (e.g. admin is usually on "/", myacc is usually on "/my/account")
Current string `json:"Current"`
ExternalURI string `json:"ExternalURI"`
// The subdirectory the app is meant to be accessed from ("Reverse proxy subfolder")
TrueBase string `json:"TrueBase"`
}
type TasksDTO struct {
Tasks []TaskDTO `json:"tasks"`
}
type TaskDTO struct {
URL string `json:"url"`
Name string `json:"name"`
Description string `json:"description"`
}
type LabelsDTO struct {
Labels []string `json:'labels"`
}
type ActivityLogEntriesDTO struct {
Entries []ActivityLogEntryDTO `json:"entries"`
}
type PaginatedActivityLogEntriesDTO struct {
ActivityLogEntriesDTO
PaginatedDTO
}
type ActivityLogEntryDTO struct {
mediabrowser.ActivityLogEntry
Date int64 `json:"Date"`
}