Changes method name, removes error case. (#11427)

* Changes method name, removes previous error case.

* Fixes test now that the method is idempotent.
This commit is contained in:
Martin Kraft
2019-06-28 07:31:32 -04:00
committed by GitHub
parent 22fb7d9116
commit ab4eaf898b
10 changed files with 69 additions and 74 deletions

View File

@@ -335,7 +335,7 @@ func (s *SqlGroupStore) GetMemberCount(groupID string) store.StoreChannel {
})
}
func (s *SqlGroupStore) CreateOrRestoreMember(groupID string, userID string) store.StoreChannel {
func (s *SqlGroupStore) UpsertMember(groupID string, userID string) store.StoreChannel {
return store.Do(func(result *store.StoreResult) {
member := &model.GroupMember{
@@ -362,11 +362,6 @@ func (s *SqlGroupStore) CreateOrRestoreMember(groupID string, userID string) sto
}
}
if retrievedMember != nil && retrievedMember.DeleteAt == 0 {
result.Err = model.NewAppError("SqlGroupStore.GroupCreateOrRestoreMember", "store.sql_group.uniqueness_error", nil, "group_id="+member.GroupId+", user_id="+member.UserId, http.StatusBadRequest)
return
}
if retrievedMember == nil {
if err := s.GetMaster().Insert(member); err != nil {
if IsUniqueConstraintError(err, []string{"GroupId", "UserId", "groupmembers_pkey", "PRIMARY"}) {