mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 11:34:26 +00:00
6b3f5b984c
* refactor: switch from opencensus to opentelemetry * tempo works as designed nooooot * fix: log traceids * with grafana agent * fix: http tracing * fix: cleanup files * chore: remove todo * fix: bad test * fix: ignore methods in grpc interceptors * fix: remove test log * clean up * typo * fix(config): configure tracing endpoint * fix(span): add error id to span * feat: metrics package * feat: metrics package * fix: counter * fix: metric * try metrics * fix: coutner metrics * fix: active sessin counter * fix: active sessin counter * fix: change current Sequence table * fix: change current Sequence table * fix: current sequences * fix: spooler div metrics * fix: console view * fix: merge master * fix: Last spool run on search result instead of eventtimestamp * fix: go mod * Update console/src/assets/i18n/de.json Co-authored-by: Livio Amstutz <livio.a@gmail.com> * fix: pr review * fix: map * update oidc pkg * fix: handlers * fix: value observer * fix: remove fmt * fix: handlers * fix: tests * fix: handler minimum cycle duration 1s * fix(spooler): handler channel buffer * fix interceptors Co-authored-by: adlerhurst <silvan.reusser@gmail.com> Co-authored-by: Livio Amstutz <livio.a@gmail.com>
98 lines
3.8 KiB
Go
98 lines
3.8 KiB
Go
package view
|
|
|
|
import (
|
|
usr_model "github.com/caos/zitadel/internal/user/model"
|
|
"github.com/caos/zitadel/internal/user/repository/view"
|
|
"github.com/caos/zitadel/internal/user/repository/view/model"
|
|
"github.com/caos/zitadel/internal/view/repository"
|
|
"time"
|
|
)
|
|
|
|
const (
|
|
userMembershipTable = "auth.user_memberships"
|
|
)
|
|
|
|
func (v *View) UserMembershipByIDs(userID, aggregateID, objectID string, memberType usr_model.MemberType) (*model.UserMembershipView, error) {
|
|
return view.UserMembershipByIDs(v.Db, userMembershipTable, userID, aggregateID, objectID, memberType)
|
|
}
|
|
|
|
func (v *View) UserMembershipsByAggregateID(aggregateID string) ([]*model.UserMembershipView, error) {
|
|
return view.UserMembershipsByAggregateID(v.Db, userMembershipTable, aggregateID)
|
|
}
|
|
|
|
func (v *View) UserMembershipsByResourceOwner(resourceOwner string) ([]*model.UserMembershipView, error) {
|
|
return view.UserMembershipsByResourceOwner(v.Db, userMembershipTable, resourceOwner)
|
|
}
|
|
|
|
func (v *View) SearchUserMemberships(request *usr_model.UserMembershipSearchRequest) ([]*model.UserMembershipView, uint64, error) {
|
|
return view.SearchUserMemberships(v.Db, userMembershipTable, request)
|
|
}
|
|
|
|
func (v *View) PutUserMembership(membership *model.UserMembershipView, sequence uint64, eventTimestamp time.Time) error {
|
|
err := view.PutUserMembership(v.Db, userMembershipTable, membership)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return v.ProcessedUserMembershipSequence(sequence, eventTimestamp)
|
|
}
|
|
|
|
func (v *View) BulkPutUserMemberships(memberships []*model.UserMembershipView, sequence uint64, eventTimestamp time.Time) error {
|
|
err := view.PutUserMemberships(v.Db, userMembershipTable, memberships...)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return v.ProcessedUserMembershipSequence(sequence, eventTimestamp)
|
|
}
|
|
|
|
func (v *View) DeleteUserMembership(userID, aggregateID, objectID string, memberType usr_model.MemberType, eventSequence uint64, eventTimestamp time.Time) error {
|
|
err := view.DeleteUserMembership(v.Db, userMembershipTable, userID, aggregateID, objectID, memberType)
|
|
if err != nil {
|
|
return nil
|
|
}
|
|
return v.ProcessedUserMembershipSequence(eventSequence, eventTimestamp)
|
|
}
|
|
|
|
func (v *View) DeleteUserMembershipsByUserID(userID string, eventSequence uint64, eventTimestamp time.Time) error {
|
|
err := view.DeleteUserMembershipsByUserID(v.Db, userMembershipTable, userID)
|
|
if err != nil {
|
|
return nil
|
|
}
|
|
return v.ProcessedUserMembershipSequence(eventSequence, eventTimestamp)
|
|
}
|
|
|
|
func (v *View) DeleteUserMembershipsByAggregateID(aggregateID string, eventSequence uint64, eventTimestamp time.Time) error {
|
|
err := view.DeleteUserMembershipsByAggregateID(v.Db, userMembershipTable, aggregateID)
|
|
if err != nil {
|
|
return nil
|
|
}
|
|
return v.ProcessedUserMembershipSequence(eventSequence, eventTimestamp)
|
|
}
|
|
|
|
func (v *View) DeleteUserMembershipsByAggregateIDAndObjectID(aggregateID, objectID string, eventSequence uint64, eventTimestamp time.Time) error {
|
|
err := view.DeleteUserMembershipsByAggregateIDAndObjectID(v.Db, userMembershipTable, aggregateID, objectID)
|
|
if err != nil {
|
|
return nil
|
|
}
|
|
return v.ProcessedUserMembershipSequence(eventSequence, eventTimestamp)
|
|
}
|
|
|
|
func (v *View) GetLatestUserMembershipSequence() (*repository.CurrentSequence, error) {
|
|
return v.latestSequence(userMembershipTable)
|
|
}
|
|
|
|
func (v *View) ProcessedUserMembershipSequence(eventSequence uint64, eventTimestamp time.Time) error {
|
|
return v.saveCurrentSequence(userMembershipTable, eventSequence, eventTimestamp)
|
|
}
|
|
|
|
func (v *View) UpdateUserMembershipSpoolerRunTimestamp() error {
|
|
return v.updateSpoolerRunSequence(userMembershipTable)
|
|
}
|
|
|
|
func (v *View) GetLatestUserMembershipFailedEvent(sequence uint64) (*repository.FailedEvent, error) {
|
|
return v.latestFailedEvent(userMembershipTable, sequence)
|
|
}
|
|
|
|
func (v *View) ProcessedUserMembershipFailedEvent(failedEvent *repository.FailedEvent) error {
|
|
return v.saveFailedEvent(failedEvent)
|
|
}
|