diff --git a/pkg/mocks/things.go b/pkg/mocks/things.go index b95eb2bf5..919d49251 100644 --- a/pkg/mocks/things.go +++ b/pkg/mocks/things.go @@ -234,7 +234,7 @@ func (svc *mainfluxThings) ListChannelsByGroup(_ context.Context, token, groupID panic("not implemented") } -func (svc *mainfluxThings) CreateRolesByGroup(_ context.Context, token, groupID string, gps ...things.GroupRoles) error { +func (svc *mainfluxThings) CreateRolesByGroup(_ context.Context, token string, gms ...things.GroupMember) error { panic("not implemented") } @@ -242,7 +242,7 @@ func (svc *mainfluxThings) ListRolesByGroup(_ context.Context, token, groupID st panic("not implemented") } -func (svc *mainfluxThings) UpdateRolesByGroup(_ context.Context, token, groupID string, gps ...things.GroupRoles) error { +func (svc *mainfluxThings) UpdateRolesByGroup(_ context.Context, token string, gms ...things.GroupMember) error { panic("not implemented") } diff --git a/things/api/http/endpoint.go b/things/api/http/endpoint.go index 9c0a52688..bed5d39a4 100644 --- a/things/api/http/endpoint.go +++ b/things/api/http/endpoint.go @@ -941,16 +941,17 @@ func createRolesByGroupEndpoint(svc things.Service) endpoint.Endpoint { return nil, err } - var gps []things.GroupRoles + var gms []things.GroupMember for _, g := range req.GroupMembers { - gp := things.GroupRoles{ + gp := things.GroupMember{ MemberID: g.ID, + GroupID: req.groupID, Role: g.Role, } - gps = append(gps, gp) + gms = append(gms, gp) } - if err := svc.CreateRolesByGroup(ctx, req.token, req.groupID, gps...); err != nil { + if err := svc.CreateRolesByGroup(ctx, req.token, gms...); err != nil { return nil, err } @@ -965,16 +966,17 @@ func updateRolesByGroupEndpoint(svc things.Service) endpoint.Endpoint { return nil, err } - var gps []things.GroupRoles + var gms []things.GroupMember for _, g := range req.GroupMembers { - gp := things.GroupRoles{ + gp := things.GroupMember{ MemberID: g.ID, + GroupID: req.groupID, Role: g.Role, } - gps = append(gps, gp) + gms = append(gms, gp) } - if err := svc.UpdateRolesByGroup(ctx, req.token, req.groupID, gps...); err != nil { + if err := svc.UpdateRolesByGroup(ctx, req.token, gms...); err != nil { return nil, err } diff --git a/things/api/logging.go b/things/api/logging.go index 464cfb322..6d663b015 100644 --- a/things/api/logging.go +++ b/things/api/logging.go @@ -453,16 +453,16 @@ func (lm *loggingMiddleware) ListChannelsByGroup(ctx context.Context, token, gro return lm.svc.ListChannelsByGroup(ctx, token, groupID, pm) } -func (lm *loggingMiddleware) CreateRolesByGroup(ctx context.Context, token, groupID string, gps ...things.GroupRoles) (err error) { +func (lm *loggingMiddleware) CreateRolesByGroup(ctx context.Context, token string, gms ...things.GroupMember) (err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method create_roles_by_group for id %s took %s to complete", groupID, time.Since(begin)) + message := fmt.Sprintf("Method create_roles_by_group took %s to complete", time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) return } }(time.Now()) - return lm.svc.CreateRolesByGroup(ctx, token, groupID, gps...) + return lm.svc.CreateRolesByGroup(ctx, token, gms...) } func (lm *loggingMiddleware) ListRolesByGroup(ctx context.Context, token, groupID string, pm things.PageMetadata) (gpp things.GroupMembersPage, err error) { @@ -477,16 +477,16 @@ func (lm *loggingMiddleware) ListRolesByGroup(ctx context.Context, token, groupI return lm.svc.ListRolesByGroup(ctx, token, groupID, pm) } -func (lm *loggingMiddleware) UpdateRolesByGroup(ctx context.Context, token, groupID string, gps ...things.GroupRoles) (err error) { +func (lm *loggingMiddleware) UpdateRolesByGroup(ctx context.Context, token string, gms ...things.GroupMember) (err error) { defer func(begin time.Time) { - message := fmt.Sprintf("Method update_roles_by_group for id %s took %s to complete", groupID, time.Since(begin)) + message := fmt.Sprintf("Method update_roles_by_group took %s to complete", time.Since(begin)) if err != nil { lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err)) return } }(time.Now()) - return lm.svc.UpdateRolesByGroup(ctx, token, groupID, gps...) + return lm.svc.UpdateRolesByGroup(ctx, token, gms...) } func (lm *loggingMiddleware) RemoveRolesByGroup(ctx context.Context, token, groupID string, memberIDs ...string) (err error) { diff --git a/things/api/metrics.go b/things/api/metrics.go index 7426deeaa..5ab2c676f 100644 --- a/things/api/metrics.go +++ b/things/api/metrics.go @@ -327,13 +327,13 @@ func (ms *metricsMiddleware) ViewGroupByChannel(ctx context.Context, token, chan return ms.svc.ViewGroupByChannel(ctx, token, channelID) } -func (ms *metricsMiddleware) CreateRolesByGroup(ctx context.Context, token, groupID string, gps ...things.GroupRoles) error { +func (ms *metricsMiddleware) CreateRolesByGroup(ctx context.Context, token string, gms ...things.GroupMember) error { defer func(begin time.Time) { ms.counter.With("method", "create_roles_by_group").Add(1) ms.latency.With("method", "create_roles_by_group").Observe(time.Since(begin).Seconds()) }(time.Now()) - return ms.svc.CreateRolesByGroup(ctx, token, groupID, gps...) + return ms.svc.CreateRolesByGroup(ctx, token, gms...) } func (ms *metricsMiddleware) ListRolesByGroup(ctx context.Context, token, groupID string, pm things.PageMetadata) (things.GroupMembersPage, error) { @@ -345,13 +345,13 @@ func (ms *metricsMiddleware) ListRolesByGroup(ctx context.Context, token, groupI return ms.svc.ListRolesByGroup(ctx, token, groupID, pm) } -func (ms *metricsMiddleware) UpdateRolesByGroup(ctx context.Context, token, groupID string, gps ...things.GroupRoles) error { +func (ms *metricsMiddleware) UpdateRolesByGroup(ctx context.Context, token string, gms ...things.GroupMember) error { defer func(begin time.Time) { ms.counter.With("method", "update_roles_by_group").Add(1) ms.latency.With("method", "update_roles_by_group").Observe(time.Since(begin).Seconds()) }(time.Now()) - return ms.svc.UpdateRolesByGroup(ctx, token, groupID, gps...) + return ms.svc.UpdateRolesByGroup(ctx, token, gms...) } func (ms *metricsMiddleware) RemoveRolesByGroup(ctx context.Context, token, groupID string, memberIDs ...string) error { diff --git a/things/groups.go b/things/groups.go index cce5d9c46..1f821be44 100644 --- a/things/groups.go +++ b/things/groups.go @@ -121,12 +121,13 @@ func (ts *thingsService) CreateGroups(ctx context.Context, token string, groups return []Group{}, err } - role := GroupRoles{ + role := GroupMember{ MemberID: ownerID, + GroupID: gr.ID, Role: Admin, } - if err := ts.roles.SaveRolesByGroup(ctx, gr.ID, role); err != nil { + if err := ts.roles.SaveRolesByGroup(ctx, role); err != nil { return []Group{}, err } diff --git a/things/mocks/roles.go b/things/mocks/roles.go index 10dc78a16..7d001fc5d 100644 --- a/things/mocks/roles.go +++ b/things/mocks/roles.go @@ -12,27 +12,24 @@ var _ things.RolesRepository = (*rolesRepositoryMock)(nil) type rolesRepositoryMock struct { mu sync.Mutex groupRoles map[string]things.GroupMember - groupRolesByID map[string]things.GroupRoles + groupRolesByID map[string]things.GroupMember } // NewRolesRepository returns mock of roles repository func NewRolesRepository() things.RolesRepository { return &rolesRepositoryMock{ groupRoles: make(map[string]things.GroupMember), - groupRolesByID: make(map[string]things.GroupRoles), + groupRolesByID: make(map[string]things.GroupMember), } } -func (mrm *rolesRepositoryMock) SaveRolesByGroup(_ context.Context, groupID string, gps ...things.GroupRoles) error { +func (mrm *rolesRepositoryMock) SaveRolesByGroup(_ context.Context, gms ...things.GroupMember) error { mrm.mu.Lock() defer mrm.mu.Unlock() - for _, gp := range gps { - mrm.groupRoles[groupID] = things.GroupMember{ - MemberID: gp.MemberID, - Role: gp.Role, - } - mrm.groupRolesByID[gp.MemberID] = gp + for _, g := range gms { + mrm.groupRoles[g.GroupID] = g + mrm.groupRolesByID[g.MemberID] = g } return nil @@ -74,7 +71,7 @@ func (mrm *rolesRepositoryMock) RetrieveAllRolesByGroup(_ context.Context) ([]th return gps, nil } -func (mrm *rolesRepositoryMock) UpdateRolesByGroup(_ context.Context, groupID string, gps ...things.GroupRoles) error { +func (mrm *rolesRepositoryMock) UpdateRolesByGroup(_ context.Context, gms ...things.GroupMember) error { panic("not implemented") } diff --git a/things/postgres/roles.go b/things/postgres/roles.go index 0f83e93a6..a9c54c696 100644 --- a/things/postgres/roles.go +++ b/things/postgres/roles.go @@ -22,7 +22,7 @@ func NewRolesRepository(db Database) things.RolesRepository { } } -func (pr rolesRepository) SaveRolesByGroup(ctx context.Context, groupID string, gps ...things.GroupRoles) error { +func (pr rolesRepository) SaveRolesByGroup(ctx context.Context, gms ...things.GroupMember) error { tx, err := pr.db.BeginTxx(ctx, nil) if err != nil { return err @@ -30,15 +30,9 @@ func (pr rolesRepository) SaveRolesByGroup(ctx context.Context, groupID string, q := `INSERT INTO group_roles (member_id, group_id, role) VALUES (:member_id, :group_id, :role);` - for _, g := range gps { - gp := things.GroupMember{ - MemberID: g.MemberID, - GroupID: groupID, - Role: g.Role, - } - dbgp := toDBGroupMembers(gp) - - if _, err := pr.db.NamedExecContext(ctx, q, dbgp); err != nil { + for _, g := range gms { + dbgm := toDBGroupMembers(g) + if _, err := pr.db.NamedExecContext(ctx, q, dbgm); err != nil { tx.Rollback() pgErr, ok := err.(*pgconn.PgError) if ok { @@ -182,18 +176,12 @@ func (pr rolesRepository) RemoveRolesByGroup(ctx context.Context, groupID string return nil } -func (pr rolesRepository) UpdateRolesByGroup(ctx context.Context, groupID string, gps ...things.GroupRoles) error { +func (pr rolesRepository) UpdateRolesByGroup(ctx context.Context, gms ...things.GroupMember) error { q := `UPDATE group_roles SET role = :role WHERE member_id = :member_id AND group_id = :group_id;` - for _, g := range gps { - gp := things.GroupMember{ - MemberID: g.MemberID, - GroupID: groupID, - Role: g.Role, - } - dbgp := toDBGroupMembers(gp) - - row, err := pr.db.NamedExecContext(ctx, q, dbgp) + for _, g := range gms { + dbgm := toDBGroupMembers(g) + row, err := pr.db.NamedExecContext(ctx, q, dbgm) if err != nil { pgErr, ok := err.(*pgconn.PgError) if ok { diff --git a/things/postgres/roles_test.go b/things/postgres/roles_test.go index f93243fdb..fbb19b53a 100644 --- a/things/postgres/roles_test.go +++ b/things/postgres/roles_test.go @@ -30,62 +30,74 @@ func TestSaveRolesByGroup(t *testing.T) { memberID := generateUUID(t) memberID1 := generateUUID(t) - gps := []things.GroupRoles{ + gms := []things.GroupMember{ { MemberID: memberID, + GroupID: group.ID, Role: things.Viewer, }, { MemberID: memberID1, + GroupID: group.ID, Role: things.Viewer, }, } - gpsWithoutMemberIDs := []things.GroupRoles{ + gmsWithoutMemberIDs := []things.GroupMember{ { MemberID: "", + GroupID: group.ID, Role: things.Viewer, }, { MemberID: "", + GroupID: group.ID, + Role: things.Viewer, + }, + } + + gmsWithoutGroupIDs := []things.GroupMember{ + { + MemberID: memberID, + GroupID: "", + Role: things.Viewer, + }, + { + MemberID: memberID1, + GroupID: "", Role: things.Viewer, }, } cases := []struct { - desc string - groupID string - gps []things.GroupRoles - err error + desc string + gms []things.GroupMember + err error }{ { - desc: "save group roles", - gps: gps, - groupID: group.ID, - err: nil, + desc: "save group roles", + gms: gms, + err: nil, }, { - desc: "save group roles without group ids", - gps: gps, - groupID: "", - err: errors.ErrMalformedEntity, + desc: "save group roles without group ids", + gms: gmsWithoutGroupIDs, + err: errors.ErrMalformedEntity, }, { - desc: "save group roles without member id", - gps: gpsWithoutMemberIDs, - groupID: group.ID, - err: errors.ErrMalformedEntity, + desc: "save group roles without member id", + gms: gmsWithoutMemberIDs, + err: errors.ErrMalformedEntity, }, { - desc: "save existing group roles", - gps: gps, - groupID: group.ID, - err: errors.ErrConflict, + desc: "save existing group roles", + gms: gms, + err: errors.ErrConflict, }, } for _, tc := range cases { - err := rolesRepo.SaveRolesByGroup(context.Background(), tc.groupID, tc.gps...) + err := rolesRepo.SaveRolesByGroup(context.Background(), tc.gms...) assert.True(t, errors.Contains(err, tc.err), fmt.Sprintf("%s: expected %s got %s\n", tc.desc, tc.err, err)) } } @@ -107,18 +119,13 @@ func TestRetrieveRole(t *testing.T) { memberID := generateUUID(t) - gp := things.GroupMember{ + gm := things.GroupMember{ GroupID: group.ID, Role: things.Viewer, MemberID: memberID, } - gpByID := things.GroupRoles{ - MemberID: memberID, - Role: things.Viewer, - } - - err = rolesRepo.SaveRolesByGroup(context.Background(), group.ID, gpByID) + err = rolesRepo.SaveRolesByGroup(context.Background(), gm) require.Nil(t, err, fmt.Sprintf("got unexpected error: %s", err)) cases := []struct { @@ -129,7 +136,7 @@ func TestRetrieveRole(t *testing.T) { }{ { desc: "retrieve group role", - gp: gp, + gp: gm, role: things.Viewer, err: nil, }, @@ -178,11 +185,12 @@ func TestRetrieveRolesByGroup(t *testing.T) { for i := uint64(0); i < n; i++ { memberID, err := idProvider.ID() require.Nil(t, err, fmt.Sprintf("got unexpected error: %s", err)) - gp := things.GroupRoles{ + gm := things.GroupMember{ MemberID: memberID, + GroupID: gr.ID, Role: things.Viewer, } - err = rolesRepo.SaveRolesByGroup(context.Background(), group.ID, gp) + err = rolesRepo.SaveRolesByGroup(context.Background(), gm) require.Nil(t, err, fmt.Sprintf("got unexpected error: %s", err)) } @@ -267,12 +275,13 @@ func TestRemoveRolesByGroup(t *testing.T) { memberID, err := idProvider.ID() require.Nil(t, err, fmt.Sprintf("got unexpected error: %s", err)) - gp := things.GroupRoles{ + gp := things.GroupMember{ MemberID: memberID, + GroupID: group.ID, Role: things.Viewer, } - err = rolesRepo.SaveRolesByGroup(context.Background(), group.ID, gp) + err = rolesRepo.SaveRolesByGroup(context.Background(), gp) require.Nil(t, err, fmt.Sprintf("got unexpected error: %s", err)) memberIDs = append(memberIDs, memberID) @@ -328,49 +337,50 @@ func TestUpdateRolesByGroup(t *testing.T) { group, err := groupRepo.Save(context.Background(), gr) require.Nil(t, err, fmt.Sprintf("group save got unexpected error: %s", err)) - gpByIDs := []things.GroupRoles{ + gpByIDs := []things.GroupMember{ { MemberID: memberID, + GroupID: gr.ID, Role: things.Viewer, }, { MemberID: memberID1, + GroupID: gr.ID, Role: things.Viewer, }, } - err = rolesRepo.SaveRolesByGroup(context.Background(), group.ID, gpByIDs...) + err = rolesRepo.SaveRolesByGroup(context.Background(), gpByIDs...) require.Nil(t, err, fmt.Sprintf("got unexpected error: %s", err)) cases := []struct { - desc string - groupID string - gpByID things.GroupRoles - err error + desc string + gpByID things.GroupMember + err error }{ { - desc: "update group roles without group id", - groupID: "", - gpByID: things.GroupRoles{ - MemberID: "", + desc: "update group roles without group id", + gpByID: things.GroupMember{ + MemberID: memberID, + GroupID: "", Role: things.Viewer, }, err: errors.ErrMalformedEntity, }, { - desc: "update group roles without member id", - groupID: group.ID, - gpByID: things.GroupRoles{ + desc: "update group roles without member id", + gpByID: things.GroupMember{ MemberID: "", + GroupID: group.ID, Role: things.Viewer, }, err: errors.ErrMalformedEntity, }, { - desc: "update group roles", - groupID: group.ID, - gpByID: things.GroupRoles{ + desc: "update group roles", + gpByID: things.GroupMember{ MemberID: memberID, + GroupID: group.ID, Role: things.Viewer, }, err: nil, @@ -378,7 +388,7 @@ func TestUpdateRolesByGroup(t *testing.T) { } for _, tc := range cases { - err := rolesRepo.UpdateRolesByGroup(context.Background(), tc.groupID, tc.gpByID) + err := rolesRepo.UpdateRolesByGroup(context.Background(), tc.gpByID) assert.True(t, errors.Contains(err, tc.err), fmt.Sprintf("%s: expected %s got %s\n", tc.desc, tc.err, err)) } } diff --git a/things/redis/streams.go b/things/redis/streams.go index 83bc75f3c..5a3fc4b99 100644 --- a/things/redis/streams.go +++ b/things/redis/streams.go @@ -303,16 +303,16 @@ func (es eventStore) ViewGroupByChannel(ctx context.Context, token string, chann return es.svc.ViewGroupByChannel(ctx, token, channelID) } -func (es eventStore) CreateRolesByGroup(ctx context.Context, token, groupID string, gps ...things.GroupRoles) error { - return es.svc.CreateRolesByGroup(ctx, token, groupID, gps...) +func (es eventStore) CreateRolesByGroup(ctx context.Context, token string, gms ...things.GroupMember) error { + return es.svc.CreateRolesByGroup(ctx, token, gms...) } func (es eventStore) ListRolesByGroup(ctx context.Context, token, groupID string, pm things.PageMetadata) (things.GroupMembersPage, error) { return es.svc.ListRolesByGroup(ctx, token, groupID, pm) } -func (es eventStore) UpdateRolesByGroup(ctx context.Context, token, groupID string, gps ...things.GroupRoles) error { - return es.svc.UpdateRolesByGroup(ctx, token, groupID, gps...) +func (es eventStore) UpdateRolesByGroup(ctx context.Context, token string, gms ...things.GroupMember) error { + return es.svc.UpdateRolesByGroup(ctx, token, gms...) } func (es eventStore) RemoveRolesByGroup(ctx context.Context, token, groupID string, memberIDs ...string) error { diff --git a/things/roles.go b/things/roles.go index db8a80fe4..c5f487a0a 100644 --- a/things/roles.go +++ b/things/roles.go @@ -14,10 +14,6 @@ type GroupMember struct { Role string } -type GroupRoles struct { - MemberID string - Role string -} type GroupMembersPage struct { PageMetadata GroupMembers []GroupMember @@ -25,7 +21,7 @@ type GroupMembersPage struct { type RolesRepository interface { // SaveRolesByGroup saves group roles by group ID. - SaveRolesByGroup(ctx context.Context, groupID string, gps ...GroupRoles) error + SaveRolesByGroup(ctx context.Context, gms ...GroupMember) error // RetrieveRole retrieves group role by group ID. RetrieveRole(ctc context.Context, gp GroupMember) (string, error) @@ -43,27 +39,28 @@ type RolesRepository interface { RemoveRolesByGroup(ctx context.Context, groupID string, memberIDs ...string) error // UpdateRolesByGroup updates group roles by group ID. - UpdateRolesByGroup(ctx context.Context, groupID string, gps ...GroupRoles) error + UpdateRolesByGroup(ctx context.Context, gms ...GroupMember) error } type Roles interface { // CreateRolesByGroup creates roles of the group identified by the provided ID. - CreateRolesByGroup(ctx context.Context, token, groupID string, gps ...GroupRoles) error + CreateRolesByGroup(ctx context.Context, token string, gms ...GroupMember) error // ListRolesByGroup retrieves a page of roles for a group that is identified by the provided ID. ListRolesByGroup(ctx context.Context, token, groupID string, pm PageMetadata) (GroupMembersPage, error) // UpdateRolesByGroup updates roles of the group identified by the provided ID. - UpdateRolesByGroup(ctx context.Context, token, groupID string, gps ...GroupRoles) error + UpdateRolesByGroup(ctx context.Context, token string, gms ...GroupMember) error // RemoveRolesByGroup removes roles of the group identified by the provided ID. RemoveRolesByGroup(ctx context.Context, token, groupID string, memberIDs ...string) error } -func (ts *thingsService) CreateRolesByGroup(ctx context.Context, token, groupID string, gps ...GroupRoles) error { +func (ts *thingsService) CreateRolesByGroup(ctx context.Context, token string, gms ...GroupMember) error { + grID := gms[0].GroupID ar := AuthorizeReq{ Token: token, - Object: groupID, + Object: grID, Subject: GroupSub, Action: Admin, } @@ -72,7 +69,7 @@ func (ts *thingsService) CreateRolesByGroup(ctx context.Context, token, groupID return err } - if err := ts.roles.SaveRolesByGroup(ctx, groupID, gps...); err != nil { + if err := ts.roles.SaveRolesByGroup(ctx, gms...); err != nil { return err } @@ -142,10 +139,11 @@ func (ts *thingsService) ListRolesByGroup(ctx context.Context, token, groupID st return page, nil } -func (ts *thingsService) UpdateRolesByGroup(ctx context.Context, token, groupID string, gps ...GroupRoles) error { +func (ts *thingsService) UpdateRolesByGroup(ctx context.Context, token string, gms ...GroupMember) error { + grID := gms[0].GroupID ar := AuthorizeReq{ Token: token, - Object: groupID, + Object: grID, Subject: GroupSub, Action: Admin, } @@ -154,18 +152,18 @@ func (ts *thingsService) UpdateRolesByGroup(ctx context.Context, token, groupID return err } - group, err := ts.groups.RetrieveByID(ctx, groupID) + group, err := ts.groups.RetrieveByID(ctx, grID) if err != nil { return err } - for _, gp := range gps { - if gp.MemberID == group.OrgID { + for _, gp := range gms { + if gp.MemberID == group.OwnerID { return errors.ErrAuthorization } } - if err := ts.roles.UpdateRolesByGroup(ctx, groupID, gps...); err != nil { + if err := ts.roles.UpdateRolesByGroup(ctx, gms...); err != nil { return err } diff --git a/things/service.go b/things/service.go index f0eb6a9c0..5944fab85 100644 --- a/things/service.go +++ b/things/service.go @@ -698,12 +698,13 @@ func (ts *thingsService) Restore(ctx context.Context, token string, backup Backu } for _, g := range backup.GroupRoles { - gp := GroupRoles{ + gm := GroupMember{ MemberID: g.MemberID, + GroupID: g.GroupID, Role: g.Role, } - if err := ts.roles.SaveRolesByGroup(ctx, g.GroupID, gp); err != nil { + if err := ts.roles.SaveRolesByGroup(ctx, gm); err != nil { return err } } diff --git a/things/tracing/roles.go b/things/tracing/roles.go index f707838c5..98cba54c1 100644 --- a/things/tracing/roles.go +++ b/things/tracing/roles.go @@ -36,12 +36,12 @@ func RolesRepositoryMiddleware(tracer opentracing.Tracer, pr things.RolesReposit } } -func (prm rolesRepositoryMiddleware) SaveRolesByGroup(ctx context.Context, groupID string, gps ...things.GroupRoles) error { +func (prm rolesRepositoryMiddleware) SaveRolesByGroup(ctx context.Context, gms ...things.GroupMember) error { span := createSpan(ctx, prm.tracer, saveRolesByGroup) defer span.Finish() ctx = opentracing.ContextWithSpan(ctx, span) - return prm.repo.SaveRolesByGroup(ctx, groupID, gps...) + return prm.repo.SaveRolesByGroup(ctx, gms...) } func (prm rolesRepositoryMiddleware) RetrieveRole(ctx context.Context, gp things.GroupMember) (string, error) { @@ -76,12 +76,12 @@ func (prm rolesRepositoryMiddleware) RetrieveAllRolesByGroup(ctx context.Context return prm.repo.RetrieveAllRolesByGroup(ctx) } -func (prm rolesRepositoryMiddleware) UpdateRolesByGroup(ctx context.Context, groupID string, gps ...things.GroupRoles) error { +func (prm rolesRepositoryMiddleware) UpdateRolesByGroup(ctx context.Context, gms ...things.GroupMember) error { span := createSpan(ctx, prm.tracer, updateRolesByGroup) defer span.Finish() ctx = opentracing.ContextWithSpan(ctx, span) - return prm.repo.UpdateRolesByGroup(ctx, groupID, gps...) + return prm.repo.UpdateRolesByGroup(ctx, gms...) } func (prm rolesRepositoryMiddleware) RemoveRolesByGroup(ctx context.Context, groupID string, memberIDs ...string) error {