Fix username collision for shared channels sync update (#25578)

* fix username collision for shared channels sync update

* ensure both return types are handled

* remove unused interface
Этот коммит содержится в:
Doug Lauder
2023-12-01 11:32:14 -05:00
коммит произвёл GitHub
родитель f6d41bcf5b
Коммит 57a87d8ca5
3 изменённых файлов: 22 добавлений и 11 удалений

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

@@ -4,10 +4,12 @@
package sharedchannel
import (
"errors"
"fmt"
"strings"
"github.com/mattermost/mattermost/server/public/model"
"github.com/mattermost/mattermost/server/v8/channels/store"
)
// fixMention replaces any mentions in a post for the user with the user's real username.
@@ -99,3 +101,17 @@ func mungEmail(remotename string, maxLen int) string {
}
return s
}
func isConflictError(err error) (string, bool) {
var errConflict *store.ErrConflict
if errors.As(err, &errConflict) {
return strings.ToLower(errConflict.Resource), true
}
var errInput *store.ErrInvalidInput
if errors.As(err, &errInput) {
_, field, _ := errInput.InvalidInputInfo()
return strings.ToLower(field), true
}
return "", false
}