diff options
| author | mo khan <mo@mokhan.ca> | 2025-07-24 16:59:43 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-07-24 16:59:43 -0600 |
| commit | a3496a1114c6958aa1831af5348d7340e29ebf06 (patch) | |
| tree | e467d6d54a4a16ac0002bad784b7c3a1dd9fe0bd /app/init.go | |
| parent | 0babaa518db6cbdc17779e9c4846a8a277d098b7 (diff) | |
refactor: delegate to GlobalID to provide object references
Diffstat (limited to 'app/init.go')
| -rw-r--r-- | app/init.go | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/app/init.go b/app/init.go index 581944b..c22628c 100644 --- a/app/init.go +++ b/app/init.go @@ -85,12 +85,15 @@ func init() { ioc.MustResolve[*event.TypedAggregator[*domain.Sparkle]](c).SubscribeTo("after.create", func(item *domain.Sparkle) { client := ioc.MustResolve[*authzed.Client](c) + + resource := item.ToGID().ToObjectReference() + response, err := client.WriteRelationships(context.Background(), &v1.WriteRelationshipsRequest{ Updates: []*v1.RelationshipUpdate{ &v1.RelationshipUpdate{ Operation: v1.RelationshipUpdate_OPERATION_CREATE, Relationship: &v1.Relationship{ - Resource: item.ToObjectReference(), + Resource: resource, Relation: "sparkler", Subject: item.Author.ToSubjectReference(), }, @@ -98,7 +101,7 @@ func init() { &v1.RelationshipUpdate{ Operation: v1.RelationshipUpdate_OPERATION_CREATE, Relationship: &v1.Relationship{ - Resource: item.ToObjectReference(), + Resource: resource, Relation: "sparklee", Subject: &v1.SubjectReference{ Object: &v1.ObjectReference{ @@ -111,7 +114,7 @@ func init() { &v1.RelationshipUpdate{ Operation: v1.RelationshipUpdate_OPERATION_CREATE, Relationship: &v1.Relationship{ - Resource: item.ToObjectReference(), + Resource: resource, Relation: "reader", Subject: &v1.SubjectReference{ Object: &v1.ObjectReference{ |
