[MM-34303] Add team ID to response when linking a channel to a group (#17576)

* add team ID to channel group response

Co-authored-by: Benjamin Cooke <benjamincooke@Benjamins-MacBook-Pro.local>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Ben Cooke
2021-05-26 10:12:34 -04:00
коммит произвёл GitHub
родитель 4f0f038e0b
Коммит 3960d29bb4
3 изменённых файлов: 37 добавлений и 13 удалений

Просмотреть файл

@@ -479,11 +479,13 @@ func (s *SqlGroupStore) CreateGroupSyncable(groupSyncable *model.GroupSyncable)
insertErr = s.GetMaster().Insert(groupSyncableToGroupTeam(groupSyncable))
case model.GroupSyncableTypeChannel:
if _, err := s.Channel().Get(groupSyncable.SyncableId, false); err != nil {
var channel *model.Channel
channel, err := s.Channel().Get(groupSyncable.SyncableId, false)
if err != nil {
return nil, err
}
insertErr = s.GetMaster().Insert(groupSyncableToGroupChannel(groupSyncable))
groupSyncable.TeamID = channel.TeamId
default:
return nil, fmt.Errorf("invalid GroupSyncableType: %s", groupSyncable.Type)
}
@@ -661,7 +663,16 @@ func (s *SqlGroupStore) UpdateGroupSyncable(groupSyncable *model.GroupSyncable)
case model.GroupSyncableTypeTeam:
_, err = s.GetMaster().Update(groupSyncableToGroupTeam(groupSyncable))
case model.GroupSyncableTypeChannel:
// We need to get the TeamId so redux can manage channels when teams are unlinked
var channel *model.Channel
channel, channelErr := s.Channel().Get(groupSyncable.SyncableId, false)
if channelErr != nil {
return nil, channelErr
}
_, err = s.GetMaster().Update(groupSyncableToGroupChannel(groupSyncable))
groupSyncable.TeamID = channel.TeamId
default:
return nil, fmt.Errorf("invalid GroupSyncableType: %s", groupSyncable.Type)
}