mirror of
https://github.com/hay-kot/homebox.git
synced 2025-07-22 10:30:28 +00:00
new routes for notifiers
This commit is contained in:
parent
d79d0b45bf
commit
882f86f6f4
8 changed files with 741 additions and 5 deletions
|
@ -36,13 +36,13 @@ func NewNotifierRepository(db *ent.Client) *NotifierRepository {
|
|||
type (
|
||||
NotifierCreate struct {
|
||||
Name string `json:"name" validate:"required,min=1,max=255"`
|
||||
IsActive bool `json:"isEnabled" validate:"required,min=1,max=255"`
|
||||
IsActive bool `json:"isActive"`
|
||||
URL string `json:"url" validate:"required"`
|
||||
}
|
||||
|
||||
NotifierUpdate struct {
|
||||
Name string `json:"name" validate:"required,min=1,max=255"`
|
||||
IsActive bool `json:"isEnabled" validate:"required,min=1,max=255"`
|
||||
IsActive bool `json:"isActive"`
|
||||
URL *string `json:"url" extensions:"x-nullable"`
|
||||
}
|
||||
|
||||
|
@ -54,13 +54,13 @@ type (
|
|||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
|
||||
Name string `json:"name"`
|
||||
IsActive bool `json:"isEnabled"`
|
||||
IsActive bool `json:"isActive"`
|
||||
URL string `json:"-"` // URL field is not exposed to the client
|
||||
}
|
||||
)
|
||||
|
||||
func (r *NotifierRepository) GetByUser(ctx context.Context, userID uuid.UUID) ([]NotifierOut, error) {
|
||||
notifier, err := r.db.Notifier.Query().Where(notifier.GroupID(userID)).All(ctx)
|
||||
notifier, err := r.db.Notifier.Query().Where(notifier.UserID(userID)).All(ctx)
|
||||
return r.mapper.MapEachErr(notifier, err)
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ type AllRepos struct {
|
|||
Docs *DocumentRepository
|
||||
Attachments *AttachmentRepo
|
||||
MaintEntry *MaintenanceEntryRepository
|
||||
Notifiers *NotifierRepository
|
||||
}
|
||||
|
||||
func New(db *ent.Client, root string) *AllRepos {
|
||||
|
@ -26,5 +27,6 @@ func New(db *ent.Client, root string) *AllRepos {
|
|||
Docs: &DocumentRepository{db, root},
|
||||
Attachments: &AttachmentRepo{db},
|
||||
MaintEntry: &MaintenanceEntryRepository{db},
|
||||
Notifiers: NewNotifierRepository(db),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue