File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 99 "github.com/modernice/goes/aggregate"
1010 "github.com/modernice/goes/event"
1111 "github.com/modernice/goes/helper/pick"
12+ "github.com/modernice/goes/internal/slice"
1213 "github.com/modernice/goes/projection"
1314)
1415
@@ -161,7 +162,7 @@ func (perms *Permissions) revoked(evt event.Of[PermissionRevokedData]) {
161162}
162163
163164func (perms * Permissions ) roleGiven (evt event.Of [[]uuid.UUID ]) {
164- if perms . ActorID != pick . AggregateID (evt ) {
165+ if ! slices . Contains (evt . Data (), perms . ActorID ) {
165166 return
166167 }
167168
@@ -170,7 +171,7 @@ func (perms *Permissions) roleGiven(evt event.Of[[]uuid.UUID]) {
170171}
171172
172173func (perms * Permissions ) roleRemoved (evt event.Of [[]uuid.UUID ]) {
173- if perms . ActorID != pick . AggregateID (evt ) {
174+ if ! slices . Contains (evt . Data (), perms . ActorID ) {
174175 return
175176 }
176177
@@ -185,9 +186,12 @@ func (perms *Permissions) roleRemoved(evt event.Of[[]uuid.UUID]) {
185186}
186187
187188func (perms * Permissions ) finalize (ctx context.Context , roles RoleRepository ) error {
189+ perms .Roles = slice .Unique (perms .Roles )
190+
188191 if ! perms .rolesHaveChanged {
189192 return nil
190193 }
194+
191195 perms .rolesHaveChanged = false
192196 perms .OfRoles = make (Actions )
193197
You can’t perform that action at this time.
0 commit comments