snapshot of https://github.com/traggo/server.git (master, 2026-09-16; blobs > 131072B omitted)
Some checks failed
build / build (push) Failing after 3s
Some checks failed
build / build (push) Failing after 3s
This commit is contained in:
28
dashboard/remove.go
Normal file
28
dashboard/remove.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package dashboard
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/traggo/server/dashboard/convert"
|
||||
"github.com/traggo/server/dashboard/util"
|
||||
|
||||
"github.com/traggo/server/auth"
|
||||
"github.com/traggo/server/generated/gqlmodel"
|
||||
"github.com/traggo/server/model"
|
||||
)
|
||||
|
||||
// RemoveDashboard removes a dashboard.
|
||||
func (r *ResolverForDashboard) RemoveDashboard(ctx context.Context, id int) (*gqlmodel.Dashboard, error) {
|
||||
userID := auth.GetUser(ctx).ID
|
||||
|
||||
dashboard, err := util.FindDashboard(r.DB, userID, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := r.DB.Where(&model.Dashboard{UserID: userID, ID: id}).Delete(&model.Dashboard{}).Error; err != nil {
|
||||
return &gqlmodel.Dashboard{}, err
|
||||
}
|
||||
|
||||
return convert.ToExternalDashboard(dashboard)
|
||||
}
|
||||
Reference in New Issue
Block a user