[MM-44168] Add feature to restore archived user groups (#20369)
* Add undelete feature, add mocks, tests * Rename undelete->restore * make store-layers * make app-layers * Store -> Store() * Lint fixes Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
17332035fa
Коммит
5be8557247
@@ -360,6 +360,25 @@ func (s *SqlGroupStore) Delete(groupID string) (*model.Group, error) {
|
||||
return &group, nil
|
||||
}
|
||||
|
||||
func (s *SqlGroupStore) Restore(groupID string) (*model.Group, error) {
|
||||
var group model.Group
|
||||
if err := s.GetReplicaX().Get(&group, "SELECT * from UserGroups WHERE Id = ? AND DeleteAt != 0", groupID); err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
return nil, store.NewErrNotFound("Group", groupID)
|
||||
}
|
||||
return nil, errors.Wrapf(err, "failed to get Group with id=%s", groupID)
|
||||
}
|
||||
|
||||
time := model.GetMillis()
|
||||
if _, err := s.GetMasterX().Exec(`UPDATE UserGroups
|
||||
SET DeleteAt=0, UpdateAt=?
|
||||
WHERE Id=? AND DeleteAt!=0`, time, groupID); err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to update Group with id=%s", groupID)
|
||||
}
|
||||
|
||||
return &group, nil
|
||||
}
|
||||
|
||||
func (s *SqlGroupStore) GetMember(groupID, userID string) (*model.GroupMember, error) {
|
||||
query, args, err := s.getQueryBuilder().
|
||||
Select("*").
|
||||
|
||||
Ссылка в новой задаче
Block a user