mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #12407 from rainzm/subsriber/change
Fix changing of subscribers
This commit is contained in:
@@ -284,6 +284,9 @@ func (s *SSubscriber) PerformChange(ctx context.Context, userCred mcclient.Token
|
||||
case api.SUBSCRIBER_TYPE_ROLE:
|
||||
_, err := db.Update(s, func() error {
|
||||
s.Identification = input.Role
|
||||
if input.RoleScope != "" {
|
||||
s.RoleScope = input.RoleScope
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
@@ -353,7 +356,7 @@ func (sm *SSubscriberManager) FetchCustomizeColumns(ctx context.Context, userCre
|
||||
log.Errorf("unable get robotIdentification for subscriber %q: %v", s.Id, err)
|
||||
}
|
||||
case api.SUBSCRIBER_TYPE_ROLE:
|
||||
rows[i].Role, err = s.roleIdentification()
|
||||
rows[i].Role, err = s.roleIdentification(ctx)
|
||||
if err != nil {
|
||||
log.Errorf("unable to get roleIdentification for subscriber %q: %v", s.Id, err)
|
||||
}
|
||||
@@ -404,13 +407,14 @@ func (s *SSubscriber) robotIdentification() (api.Identification, error) {
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (s *SSubscriber) roleIdentification() (api.Identification, error) {
|
||||
func (s *SSubscriber) roleIdentification(ctx context.Context) (api.Identification, error) {
|
||||
var ret api.Identification
|
||||
q := db.RoleCacheManager.Query("id", "name").Equals("id", s.Identification)
|
||||
err := q.First(&ret)
|
||||
roleCache, err := db.RoleCacheManager.FetchRoleById(ctx, s.Identification)
|
||||
if err != nil {
|
||||
return ret, err
|
||||
return ret, errors.Wrapf(err, "unable to find role %q", s.Identification)
|
||||
}
|
||||
ret.ID = s.Identification
|
||||
ret.Name = roleCache.Name
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -79,5 +79,6 @@ func (srm *SSubscriberReceiverManager) delete(sId, receiverId string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
sr.SetModelManager(srm, &sr)
|
||||
return sr.Delete(context.Background(), nil)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user