Fabi 74688394d8
feat: set private labeling setting on project (#2184)
* docs: add scope to request private labeling

* feat: add enum to project

* fix: remove unused code, add private labeling setting to query side

* fix: set private labeling depending on setting

* fix: private labeling depending on project setting

* Update proto/zitadel/management.proto

Co-authored-by: Livio Amstutz <livio.a@gmail.com>

* fix: rename sql file

* fix: private labeling setting

Co-authored-by: Livio Amstutz <livio.a@gmail.com>
2021-08-24 08:34:10 +02:00

52 lines
1.3 KiB
Go

package model
import (
"encoding/json"
"reflect"
"github.com/caos/logging"
es_models "github.com/caos/zitadel/internal/eventstore/v1/models"
)
type ProjectGrant struct {
es_models.ObjectRoot
State int32 `json:"-"`
GrantID string `json:"grantId,omitempty"`
GrantedOrgID string `json:"grantedOrgId,omitempty"`
RoleKeys []string `json:"roleKeys,omitempty"`
Members []*ProjectGrantMember `json:"-"`
}
type ProjectGrantID struct {
es_models.ObjectRoot
GrantID string `json:"grantId"`
}
func GetProjectGrant(grants []*ProjectGrant, id string) (int, *ProjectGrant) {
for i, g := range grants {
if g.GrantID == id {
return i, g
}
}
return -1, nil
}
func (g *ProjectGrant) Changes(changed *ProjectGrant) map[string]interface{} {
changes := make(map[string]interface{}, 1)
changes["grantId"] = g.GrantID
if !reflect.DeepEqual(g.RoleKeys, changed.RoleKeys) {
changes["roleKeys"] = changed.RoleKeys
}
return changes
}
func (g *ProjectGrant) getData(event *es_models.Event) error {
g.ObjectRoot.AppendEvent(event)
if err := json.Unmarshal(event.Data, g); err != nil {
logging.Log("EVEN-4h6gd").WithError(err).Error("could not unmarshal event data")
return err
}
return nil
}