From efc8a324b4bd6d77e16212538eb570f2db0f4ba6 Mon Sep 17 00:00:00 2001 From: Vivek Patel Date: Wed, 7 Sep 2022 16:14:20 +0530 Subject: [PATCH] Fix system data-privacy connection endpoint - There was nil pointer due to dalConnection was not initialised in data-privacy struct. - Update PrivacyDataConnection struct as per DalConnection struct, and responses accordingly --- system/service/data_privacy.go | 31 ++++++++++++++++++------------- system/types/data_privacy.go | 21 ++++++++++++++++----- 2 files changed, 34 insertions(+), 18 deletions(-) diff --git a/system/service/data_privacy.go b/system/service/data_privacy.go index ca582f49a..dd86ad926 100644 --- a/system/service/data_privacy.go +++ b/system/service/data_privacy.go @@ -52,6 +52,7 @@ func DataPrivacy(s store.Storer, ac dataPrivacyAccessController, al actionlog.Re store: s, ac: ac, eventbus: eb, + dalConn: DefaultDalConnection, } } @@ -71,19 +72,23 @@ func (svc dataPrivacy) FindConnections(ctx context.Context, filter types.DalConn err = cc.Walk(func(c *types.DalConnection) error { pc := types.PrivacyDalConnection{ - ID: c.ID, - Name: c.Meta.Name, - Handle: c.Handle, - Type: c.Type, - Location: c.Meta.Location, - Ownership: c.Meta.Ownership, - SensitivityLevel: c.Config.Privacy.SensitivityLevelID, - CreatedAt: c.CreatedAt, - CreatedBy: c.CreatedBy, - UpdatedAt: c.UpdatedAt, - UpdatedBy: c.UpdatedBy, - DeletedAt: c.DeletedAt, - DeletedBy: c.DeletedBy, + ID: c.ID, + Handle: c.Handle, + Type: c.Type, + Meta: types.PrivacyDalConnectionMeta{ + Name: c.Meta.Name, + Ownership: c.Meta.Ownership, + Location: c.Meta.Location, + }, + Config: types.PrivacyDalConnectionConfig{ + Privacy: c.Config.Privacy, + }, + CreatedAt: c.CreatedAt, + CreatedBy: c.CreatedBy, + UpdatedAt: c.UpdatedAt, + UpdatedBy: c.UpdatedBy, + DeletedAt: c.DeletedAt, + DeletedBy: c.DeletedBy, } out = append(out, &pc) return nil diff --git a/system/types/data_privacy.go b/system/types/data_privacy.go index 3a54afd2f..a0647e3f4 100644 --- a/system/types/data_privacy.go +++ b/system/types/data_privacy.go @@ -102,14 +102,15 @@ type ( PrivacyDalConnection struct { ID uint64 `json:"connectionID,string"` - Name string `json:"name"` Handle string `json:"handle"` + Type string `json:"type"` - Type string `json:"type"` + // descriptions, notes, and other user-provided meta-data + Meta PrivacyDalConnectionMeta `json:"meta"` - Location geolocation.Full `json:"location"` - Ownership string `json:"ownership"` - SensitivityLevel uint64 `json:"sensitivityLevel,string,omitempty"` + // collection of configurations for various subsystems that + // use this connection and how it affects their behaviour + Config PrivacyDalConnectionConfig `json:"config"` CreatedAt time.Time `json:"createdAt,omitempty"` CreatedBy uint64 `json:"createdBy,string" ` @@ -119,6 +120,16 @@ type ( DeletedBy uint64 `json:"deletedBy,string,omitempty" ` } + PrivacyDalConnectionMeta struct { + Name string `json:"name"` + Ownership string `json:"ownership"` + Location geolocation.Full `json:"location"` + } + + PrivacyDalConnectionConfig struct { + Privacy ConnectionConfigPrivacy `json:"privacy"` + } + RequestStatus string RequestKind string )