Skip to content

Commit 903272b

Browse files
authored
fix: use org title for capturing audit records (#1257)
1 parent 6464e6b commit 903272b

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

internal/store/postgres/audit_record_repository.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ var (
6565
)
6666

6767
func buildOrgNameQuery(orgID interface{}) (string, []interface{}, error) {
68-
return dialect.Select("name").
68+
return dialect.Select("title").
6969
From(TABLE_ORGANIZATIONS).
7070
Where(goqu.Ex{"id": orgID}).
7171
ToSQL()

internal/store/postgres/invitation_repository.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func (s *InvitationRepository) Set(ctx context.Context, invite invitation.Invita
6161
}
6262

6363
orgNameSubquery := dialect.From(TABLE_ORGANIZATIONS).
64-
Select("name").
64+
Select("title").
6565
Where(goqu.Ex{"id": invite.OrgID})
6666

6767
query, params, err := dialect.Insert(TABLE_INVITATIONS).Rows(

internal/store/postgres/kyc_repository.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,15 @@ func (r OrgKycRepository) Upsert(ctx context.Context, input kyc.KYC) (kyc.KYC, e
105105
).
106106
Returning(
107107
goqu.I(TABLE_ORGANIZATIONS_KYC+".*"),
108-
goqu.I(TABLE_ORGANIZATIONS+".name").As("org_name"),
108+
goqu.I(TABLE_ORGANIZATIONS+".title").As("org_name"),
109109
).ToSQL()
110110
if err != nil {
111111
return kyc.KYC{}, fmt.Errorf("%w: %w", queryErr, err)
112112
}
113113
} else if err.Error() == kyc.ErrNotExist.Error() {
114114
// kyc for org doesn't exist, prepare INSERT query with subquery for org name
115115
orgNameSubquery := dialect.From(TABLE_ORGANIZATIONS).
116-
Select("name").
116+
Select("title").
117117
Where(goqu.Ex{"id": input.OrgID})
118118

119119
query, params, err = dialect.Insert(TABLE_ORGANIZATIONS_KYC).

internal/store/postgres/organization_repository.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ func (r OrganizationRepository) Create(ctx context.Context, org organization.Org
187187
AuditResource{
188188
ID: orgModel.ID,
189189
Type: auditrecord.OrganizationType,
190-
Name: orgModel.Name,
190+
Name: nullStringToString(orgModel.Title),
191191
Metadata: org.Metadata,
192192
},
193193
nil,
@@ -319,7 +319,7 @@ func (r OrganizationRepository) UpdateByID(ctx context.Context, org organization
319319
AuditResource{
320320
ID: orgModel.ID,
321321
Type: auditrecord.OrganizationType,
322-
Name: orgModel.Name,
322+
Name: nullStringToString(orgModel.Title),
323323
Metadata: org.Metadata,
324324
},
325325
nil,
@@ -389,7 +389,7 @@ func (r OrganizationRepository) UpdateByName(ctx context.Context, org organizati
389389
AuditResource{
390390
ID: orgModel.ID,
391391
Type: auditrecord.OrganizationType,
392-
Name: orgModel.Name,
392+
Name: nullStringToString(orgModel.Title),
393393
Metadata: org.Metadata,
394394
},
395395
nil,
@@ -446,7 +446,7 @@ func (r OrganizationRepository) SetState(ctx context.Context, id string, state o
446446
AuditResource{
447447
ID: orgModel.ID,
448448
Type: auditrecord.OrganizationType,
449-
Name: orgModel.Name,
449+
Name: nullStringToString(orgModel.Title),
450450
Metadata: map[string]interface{}{
451451
"state": state.String(),
452452
},
@@ -494,7 +494,7 @@ func (r OrganizationRepository) Delete(ctx context.Context, id string) error {
494494
AuditResource{
495495
ID: orgModel.ID,
496496
Type: auditrecord.OrganizationType,
497-
Name: orgModel.Name,
497+
Name: nullStringToString(orgModel.Title),
498498
},
499499
nil,
500500
orgModel.ID,

internal/store/postgres/serviceuser_repository.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func (s ServiceUserRepository) Create(ctx context.Context, serviceUser serviceus
9595
var result serviceUserWithContext
9696

9797
orgNameSubquery := dialect.From(TABLE_ORGANIZATIONS).
98-
Select("name").
98+
Select("title").
9999
Where(goqu.Ex{"id": serviceUser.OrgID})
100100

101101
query, params, err := dialect.Insert(TABLE_SERVICEUSER).Rows(
@@ -227,7 +227,7 @@ func (s ServiceUserRepository) Delete(ctx context.Context, id string) error {
227227
var result serviceUserWithContext
228228

229229
orgNameSubquery := dialect.From(TABLE_ORGANIZATIONS).
230-
Select("name").
230+
Select("title").
231231
Where(goqu.Ex{"id": goqu.I(TABLE_SERVICEUSER + ".org_id")})
232232

233233
query, params, err := dialect.Delete(TABLE_SERVICEUSER).

0 commit comments

Comments
 (0)