snapshot of https://github.com/cortezaproject/corteza.git (2024.9.x, 2026-09-18; blobs > 131072B omitted)
Some checks failed
SonarQube / SonarQube (push) Failing after 5m28s
E2e test on main branch push / server and client test (map[name:admin port:8080]) (push) Failing after 3m33s
Server and lib tests / Library test (js) (push) Failing after 1m36s
Server and lib tests / Library test (vue) (push) Successful in 2m24s
Server and lib tests / Web client test (admin) (push) Successful in 2m52s
Server and lib tests / Web client test (compose) (push) Successful in 3m23s
Server and lib tests / Web client test (discovery) (push) Successful in 2m49s
Server and lib tests / Web client test (one) (push) Successful in 2m52s
Server and lib tests / Web client test (privacy) (push) Successful in 2m44s
Server and lib tests / Web client test (reporter) (push) Successful in 2m56s
Server and lib tests / Web client test (workflow) (push) Successful in 3m0s
Server and lib tests / Server tests (push) Failing after 4m55s
E2e test on main branch push / notify-failure (push) Failing after 9s
Server and lib tests / Send matrix testing notification (push) Successful in 2s
Mark stale issues and pull requests / stale (push) Successful in 40s
Some checks failed
SonarQube / SonarQube (push) Failing after 5m28s
E2e test on main branch push / server and client test (map[name:admin port:8080]) (push) Failing after 3m33s
Server and lib tests / Library test (js) (push) Failing after 1m36s
Server and lib tests / Library test (vue) (push) Successful in 2m24s
Server and lib tests / Web client test (admin) (push) Successful in 2m52s
Server and lib tests / Web client test (compose) (push) Successful in 3m23s
Server and lib tests / Web client test (discovery) (push) Successful in 2m49s
Server and lib tests / Web client test (one) (push) Successful in 2m52s
Server and lib tests / Web client test (privacy) (push) Successful in 2m44s
Server and lib tests / Web client test (reporter) (push) Successful in 2m56s
Server and lib tests / Web client test (workflow) (push) Successful in 3m0s
Server and lib tests / Server tests (push) Failing after 4m55s
E2e test on main branch push / notify-failure (push) Failing after 9s
Server and lib tests / Send matrix testing notification (push) Successful in 2s
Mark stale issues and pull requests / stale (push) Successful in 40s
This commit is contained in:
112
server/system/rest/reminder.go
Normal file
112
server/system/rest/reminder.go
Normal file
@@ -0,0 +1,112 @@
|
||||
package rest
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/cortezaproject/corteza/server/pkg/api"
|
||||
"github.com/cortezaproject/corteza/server/pkg/auth"
|
||||
"github.com/cortezaproject/corteza/server/pkg/filter"
|
||||
"github.com/cortezaproject/corteza/server/system/rest/request"
|
||||
"github.com/cortezaproject/corteza/server/system/service"
|
||||
"github.com/cortezaproject/corteza/server/system/types"
|
||||
"time"
|
||||
)
|
||||
|
||||
type (
|
||||
Reminder struct {
|
||||
reminder service.ReminderService
|
||||
}
|
||||
|
||||
reminderSetPayload struct {
|
||||
Filter types.ReminderFilter `json:"filter"`
|
||||
Set types.ReminderSet `json:"set,omitempty"`
|
||||
}
|
||||
)
|
||||
|
||||
func (Reminder) New() *Reminder {
|
||||
ctrl := &Reminder{}
|
||||
ctrl.reminder = service.DefaultReminder
|
||||
return ctrl
|
||||
}
|
||||
|
||||
func (ctrl *Reminder) List(ctx context.Context, r *request.ReminderList) (interface{}, error) {
|
||||
var (
|
||||
err error
|
||||
f = types.ReminderFilter{
|
||||
AssignedTo: r.AssignedTo,
|
||||
Resource: r.Resource,
|
||||
ScheduledFrom: r.ScheduledFrom,
|
||||
ScheduledUntil: r.ScheduledUntil,
|
||||
ExcludeDismissed: r.ExcludeDismissed,
|
||||
IncludeDeleted: r.IncludeDeleted,
|
||||
ScheduledOnly: r.ScheduledOnly,
|
||||
}
|
||||
)
|
||||
|
||||
if f.Paging, err = filter.NewPaging(r.Limit, r.PageCursor); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if f.Sorting, err = filter.NewSorting(r.Sort); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
set, f, err := ctrl.reminder.Find(ctx, f)
|
||||
return ctrl.makeFilterPayload(ctx, set, f, err)
|
||||
}
|
||||
|
||||
func (ctrl *Reminder) Create(ctx context.Context, r *request.ReminderCreate) (interface{}, error) {
|
||||
ntf := &types.Reminder{
|
||||
AssignedAt: time.Now(),
|
||||
AssignedBy: auth.GetIdentityFromContext(ctx).Identity(),
|
||||
|
||||
AssignedTo: r.AssignedTo,
|
||||
Payload: r.Payload,
|
||||
Resource: r.Resource,
|
||||
RemindAt: r.RemindAt,
|
||||
}
|
||||
|
||||
return ctrl.reminder.Create(ctx, ntf)
|
||||
}
|
||||
|
||||
func (ctrl *Reminder) Update(ctx context.Context, r *request.ReminderUpdate) (interface{}, error) {
|
||||
ntf := &types.Reminder{
|
||||
ID: r.ReminderID,
|
||||
AssignedAt: time.Now(),
|
||||
AssignedBy: auth.GetIdentityFromContext(ctx).Identity(),
|
||||
|
||||
AssignedTo: r.AssignedTo,
|
||||
Payload: r.Payload,
|
||||
Resource: r.Resource,
|
||||
RemindAt: r.RemindAt,
|
||||
}
|
||||
|
||||
return ctrl.reminder.Update(ctx, ntf)
|
||||
}
|
||||
|
||||
func (ctrl *Reminder) Read(ctx context.Context, r *request.ReminderRead) (interface{}, error) {
|
||||
return ctrl.reminder.FindByID(ctx, r.ReminderID)
|
||||
}
|
||||
|
||||
func (ctrl *Reminder) Delete(ctx context.Context, r *request.ReminderDelete) (interface{}, error) {
|
||||
return api.OK(), ctrl.reminder.Delete(ctx, r.ReminderID)
|
||||
}
|
||||
|
||||
func (ctrl *Reminder) Dismiss(ctx context.Context, r *request.ReminderDismiss) (interface{}, error) {
|
||||
return api.OK(), ctrl.reminder.Dismiss(ctx, r.ReminderID)
|
||||
}
|
||||
|
||||
func (ctrl *Reminder) Undismiss(ctx context.Context, r *request.ReminderUndismiss) (interface{}, error) {
|
||||
return api.OK(), ctrl.reminder.Undismiss(ctx, r.ReminderID)
|
||||
}
|
||||
|
||||
func (ctrl *Reminder) Snooze(ctx context.Context, r *request.ReminderSnooze) (interface{}, error) {
|
||||
return api.OK(), ctrl.reminder.Snooze(ctx, r.ReminderID, r.RemindAt)
|
||||
}
|
||||
|
||||
func (ctrl *Reminder) makeFilterPayload(ctx context.Context, nn types.ReminderSet, f types.ReminderFilter, err error) (*reminderSetPayload, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &reminderSetPayload{Filter: f, Set: nn}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user