mirror of
https://github.com/sysadminsmedia/homebox.git
synced 2025-12-25 06:49:18 +01:00
* ent re-generation
* add oidc integration
* document oidc integration
* go fmt
* address backend linter findings
* run prettier on index.vue
* State cookie domain can mismatch when Hostname override is used (breaks CSRF check). Add SameSite.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* Delete state cookie with matching domain and MaxAge; add SameSite.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* Fix endpoint path in comments and error to include /api/v1.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* Also use request context when verifying the ID token.
* Do not return raw auth errors to clients (user-enumeration risk).
* consistently set cookie the same way across function
* remove baseURL after declaration
* only enable OIDC routes if OIDC is enabled
* swagger doc for failure
* Only block when provider=local; move the check after parsing provider
* fix extended session comment
* reduce pii logging
* futher reduce pii logging
* remove unused DiscoveryDocument
* remove unused offline_access from default oidc scopes
* remove offline access from AuthCodeURL
* support host from X-Forwarded-Host
* set sane default claim names if unset
* error strings should not be capitalized
* Revert "run prettier on index.vue"
This reverts commit aa22330a23.
* Add timeout to provider discovery
* Split scopes robustly
* refactor hostname calculation
* address frontend prettier findings
* add property oidc on type APISummary
* LoginOIDC: Normalize inputs, only create if not found
* add oidc email verification
* oidc handleCallback: clear state cookie before each return
* add support for oidc nonce parameter
* Harden first-login race: handle concurrent creates gracefully and fix log key.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* support email verified claim as bool or string
* fail fast on empty email
* PKCE verifier
* fix: add timing delay to attachment test to resolve CI race condition
The attachment test was failing intermittently in CI due to a race condition
between attachment creation and retrieval. Adding a small 100ms delay after
attachment creation ensures the file system and database operations complete
before the test attempts to verify the attachment exists.
* Revert "fix: add timing delay to attachment test to resolve CI race condition"
This reverts commit 4aa8b2a0d829753e8d2dd1ba76f4b1e04e28c45e.
* oidc error state, use ref
* rename oidc.force to oidc.authRedirect
* remove hardcoded oidc error timeout
* feat: sub/iss based identity matching and userinfo endpoint collection
---------
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Matthew Kilgore <matthew@kilgore.dev>
582 lines
16 KiB
Go
Generated
582 lines
16 KiB
Go
Generated
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
"github.com/google/uuid"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/group"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/notifier"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/predicate"
|
|
"github.com/sysadminsmedia/homebox/backend/internal/data/ent/user"
|
|
)
|
|
|
|
// NotifierUpdate is the builder for updating Notifier entities.
|
|
type NotifierUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *NotifierMutation
|
|
}
|
|
|
|
// Where appends a list predicates to the NotifierUpdate builder.
|
|
func (_u *NotifierUpdate) Where(ps ...predicate.Notifier) *NotifierUpdate {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_u *NotifierUpdate) SetUpdatedAt(v time.Time) *NotifierUpdate {
|
|
_u.mutation.SetUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetGroupID sets the "group_id" field.
|
|
func (_u *NotifierUpdate) SetGroupID(v uuid.UUID) *NotifierUpdate {
|
|
_u.mutation.SetGroupID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableGroupID sets the "group_id" field if the given value is not nil.
|
|
func (_u *NotifierUpdate) SetNillableGroupID(v *uuid.UUID) *NotifierUpdate {
|
|
if v != nil {
|
|
_u.SetGroupID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (_u *NotifierUpdate) SetUserID(v uuid.UUID) *NotifierUpdate {
|
|
_u.mutation.SetUserID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUserID sets the "user_id" field if the given value is not nil.
|
|
func (_u *NotifierUpdate) SetNillableUserID(v *uuid.UUID) *NotifierUpdate {
|
|
if v != nil {
|
|
_u.SetUserID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (_u *NotifierUpdate) SetName(v string) *NotifierUpdate {
|
|
_u.mutation.SetName(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableName sets the "name" field if the given value is not nil.
|
|
func (_u *NotifierUpdate) SetNillableName(v *string) *NotifierUpdate {
|
|
if v != nil {
|
|
_u.SetName(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetURL sets the "url" field.
|
|
func (_u *NotifierUpdate) SetURL(v string) *NotifierUpdate {
|
|
_u.mutation.SetURL(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableURL sets the "url" field if the given value is not nil.
|
|
func (_u *NotifierUpdate) SetNillableURL(v *string) *NotifierUpdate {
|
|
if v != nil {
|
|
_u.SetURL(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetIsActive sets the "is_active" field.
|
|
func (_u *NotifierUpdate) SetIsActive(v bool) *NotifierUpdate {
|
|
_u.mutation.SetIsActive(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableIsActive sets the "is_active" field if the given value is not nil.
|
|
func (_u *NotifierUpdate) SetNillableIsActive(v *bool) *NotifierUpdate {
|
|
if v != nil {
|
|
_u.SetIsActive(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetGroup sets the "group" edge to the Group entity.
|
|
func (_u *NotifierUpdate) SetGroup(v *Group) *NotifierUpdate {
|
|
return _u.SetGroupID(v.ID)
|
|
}
|
|
|
|
// SetUser sets the "user" edge to the User entity.
|
|
func (_u *NotifierUpdate) SetUser(v *User) *NotifierUpdate {
|
|
return _u.SetUserID(v.ID)
|
|
}
|
|
|
|
// Mutation returns the NotifierMutation object of the builder.
|
|
func (_u *NotifierUpdate) Mutation() *NotifierMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// ClearGroup clears the "group" edge to the Group entity.
|
|
func (_u *NotifierUpdate) ClearGroup() *NotifierUpdate {
|
|
_u.mutation.ClearGroup()
|
|
return _u
|
|
}
|
|
|
|
// ClearUser clears the "user" edge to the User entity.
|
|
func (_u *NotifierUpdate) ClearUser() *NotifierUpdate {
|
|
_u.mutation.ClearUser()
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (_u *NotifierUpdate) Save(ctx context.Context) (int, error) {
|
|
_u.defaults()
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *NotifierUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_u *NotifierUpdate) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *NotifierUpdate) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (_u *NotifierUpdate) defaults() {
|
|
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
|
v := notifier.UpdateDefaultUpdatedAt()
|
|
_u.mutation.SetUpdatedAt(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *NotifierUpdate) check() error {
|
|
if v, ok := _u.mutation.Name(); ok {
|
|
if err := notifier.NameValidator(v); err != nil {
|
|
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Notifier.name": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.URL(); ok {
|
|
if err := notifier.URLValidator(v); err != nil {
|
|
return &ValidationError{Name: "url", err: fmt.Errorf(`ent: validator failed for field "Notifier.url": %w`, err)}
|
|
}
|
|
}
|
|
if _u.mutation.GroupCleared() && len(_u.mutation.GroupIDs()) > 0 {
|
|
return errors.New(`ent: clearing a required unique edge "Notifier.group"`)
|
|
}
|
|
if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 {
|
|
return errors.New(`ent: clearing a required unique edge "Notifier.user"`)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_u *NotifierUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(notifier.Table, notifier.Columns, sqlgraph.NewFieldSpec(notifier.FieldID, field.TypeUUID))
|
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(notifier.FieldUpdatedAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := _u.mutation.Name(); ok {
|
|
_spec.SetField(notifier.FieldName, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.URL(); ok {
|
|
_spec.SetField(notifier.FieldURL, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.IsActive(); ok {
|
|
_spec.SetField(notifier.FieldIsActive, field.TypeBool, value)
|
|
}
|
|
if _u.mutation.GroupCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: notifier.GroupTable,
|
|
Columns: []string{notifier.GroupColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.GroupIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: notifier.GroupTable,
|
|
Columns: []string{notifier.GroupColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.UserCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: notifier.UserTable,
|
|
Columns: []string{notifier.UserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.UserIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: notifier.UserTable,
|
|
Columns: []string{notifier.UserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{notifier.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
// NotifierUpdateOne is the builder for updating a single Notifier entity.
|
|
type NotifierUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *NotifierMutation
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_u *NotifierUpdateOne) SetUpdatedAt(v time.Time) *NotifierUpdateOne {
|
|
_u.mutation.SetUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetGroupID sets the "group_id" field.
|
|
func (_u *NotifierUpdateOne) SetGroupID(v uuid.UUID) *NotifierUpdateOne {
|
|
_u.mutation.SetGroupID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableGroupID sets the "group_id" field if the given value is not nil.
|
|
func (_u *NotifierUpdateOne) SetNillableGroupID(v *uuid.UUID) *NotifierUpdateOne {
|
|
if v != nil {
|
|
_u.SetGroupID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUserID sets the "user_id" field.
|
|
func (_u *NotifierUpdateOne) SetUserID(v uuid.UUID) *NotifierUpdateOne {
|
|
_u.mutation.SetUserID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableUserID sets the "user_id" field if the given value is not nil.
|
|
func (_u *NotifierUpdateOne) SetNillableUserID(v *uuid.UUID) *NotifierUpdateOne {
|
|
if v != nil {
|
|
_u.SetUserID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetName sets the "name" field.
|
|
func (_u *NotifierUpdateOne) SetName(v string) *NotifierUpdateOne {
|
|
_u.mutation.SetName(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableName sets the "name" field if the given value is not nil.
|
|
func (_u *NotifierUpdateOne) SetNillableName(v *string) *NotifierUpdateOne {
|
|
if v != nil {
|
|
_u.SetName(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetURL sets the "url" field.
|
|
func (_u *NotifierUpdateOne) SetURL(v string) *NotifierUpdateOne {
|
|
_u.mutation.SetURL(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableURL sets the "url" field if the given value is not nil.
|
|
func (_u *NotifierUpdateOne) SetNillableURL(v *string) *NotifierUpdateOne {
|
|
if v != nil {
|
|
_u.SetURL(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetIsActive sets the "is_active" field.
|
|
func (_u *NotifierUpdateOne) SetIsActive(v bool) *NotifierUpdateOne {
|
|
_u.mutation.SetIsActive(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableIsActive sets the "is_active" field if the given value is not nil.
|
|
func (_u *NotifierUpdateOne) SetNillableIsActive(v *bool) *NotifierUpdateOne {
|
|
if v != nil {
|
|
_u.SetIsActive(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetGroup sets the "group" edge to the Group entity.
|
|
func (_u *NotifierUpdateOne) SetGroup(v *Group) *NotifierUpdateOne {
|
|
return _u.SetGroupID(v.ID)
|
|
}
|
|
|
|
// SetUser sets the "user" edge to the User entity.
|
|
func (_u *NotifierUpdateOne) SetUser(v *User) *NotifierUpdateOne {
|
|
return _u.SetUserID(v.ID)
|
|
}
|
|
|
|
// Mutation returns the NotifierMutation object of the builder.
|
|
func (_u *NotifierUpdateOne) Mutation() *NotifierMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// ClearGroup clears the "group" edge to the Group entity.
|
|
func (_u *NotifierUpdateOne) ClearGroup() *NotifierUpdateOne {
|
|
_u.mutation.ClearGroup()
|
|
return _u
|
|
}
|
|
|
|
// ClearUser clears the "user" edge to the User entity.
|
|
func (_u *NotifierUpdateOne) ClearUser() *NotifierUpdateOne {
|
|
_u.mutation.ClearUser()
|
|
return _u
|
|
}
|
|
|
|
// Where appends a list predicates to the NotifierUpdate builder.
|
|
func (_u *NotifierUpdateOne) Where(ps ...predicate.Notifier) *NotifierUpdateOne {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
|
// The default is selecting all fields defined in the entity schema.
|
|
func (_u *NotifierUpdateOne) Select(field string, fields ...string) *NotifierUpdateOne {
|
|
_u.fields = append([]string{field}, fields...)
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the updated Notifier entity.
|
|
func (_u *NotifierUpdateOne) Save(ctx context.Context) (*Notifier, error) {
|
|
_u.defaults()
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *NotifierUpdateOne) SaveX(ctx context.Context) *Notifier {
|
|
node, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (_u *NotifierUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *NotifierUpdateOne) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (_u *NotifierUpdateOne) defaults() {
|
|
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
|
v := notifier.UpdateDefaultUpdatedAt()
|
|
_u.mutation.SetUpdatedAt(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *NotifierUpdateOne) check() error {
|
|
if v, ok := _u.mutation.Name(); ok {
|
|
if err := notifier.NameValidator(v); err != nil {
|
|
return &ValidationError{Name: "name", err: fmt.Errorf(`ent: validator failed for field "Notifier.name": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.URL(); ok {
|
|
if err := notifier.URLValidator(v); err != nil {
|
|
return &ValidationError{Name: "url", err: fmt.Errorf(`ent: validator failed for field "Notifier.url": %w`, err)}
|
|
}
|
|
}
|
|
if _u.mutation.GroupCleared() && len(_u.mutation.GroupIDs()) > 0 {
|
|
return errors.New(`ent: clearing a required unique edge "Notifier.group"`)
|
|
}
|
|
if _u.mutation.UserCleared() && len(_u.mutation.UserIDs()) > 0 {
|
|
return errors.New(`ent: clearing a required unique edge "Notifier.user"`)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_u *NotifierUpdateOne) sqlSave(ctx context.Context) (_node *Notifier, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(notifier.Table, notifier.Columns, sqlgraph.NewFieldSpec(notifier.FieldID, field.TypeUUID))
|
|
id, ok := _u.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Notifier.id" for update`)}
|
|
}
|
|
_spec.Node.ID.Value = id
|
|
if fields := _u.fields; len(fields) > 0 {
|
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
|
_spec.Node.Columns = append(_spec.Node.Columns, notifier.FieldID)
|
|
for _, f := range fields {
|
|
if !notifier.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
}
|
|
if f != notifier.FieldID {
|
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
|
}
|
|
}
|
|
}
|
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(notifier.FieldUpdatedAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := _u.mutation.Name(); ok {
|
|
_spec.SetField(notifier.FieldName, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.URL(); ok {
|
|
_spec.SetField(notifier.FieldURL, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.IsActive(); ok {
|
|
_spec.SetField(notifier.FieldIsActive, field.TypeBool, value)
|
|
}
|
|
if _u.mutation.GroupCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: notifier.GroupTable,
|
|
Columns: []string{notifier.GroupColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.GroupIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: notifier.GroupTable,
|
|
Columns: []string{notifier.GroupColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(group.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.UserCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: notifier.UserTable,
|
|
Columns: []string{notifier.UserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.UserIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: notifier.UserTable,
|
|
Columns: []string{notifier.UserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeUUID),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
_node = &Notifier{config: _u.config}
|
|
_spec.Assign = _node.assignValues
|
|
_spec.ScanValues = _node.scanValues
|
|
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{notifier.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|