MM-60980: Add RemoteClusterInvite.IsValid (#28624)
Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
73fc99b577
Коммит
e6d6881917
@@ -13,6 +13,7 @@ import (
|
||||
"errors"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
@@ -368,6 +369,22 @@ type RemoteClusterInvite struct {
|
||||
Token string `json:"token"`
|
||||
}
|
||||
|
||||
func (rci *RemoteClusterInvite) IsValid() *AppError {
|
||||
if !IsValidId(rci.RemoteId) {
|
||||
return NewAppError("RemoteClusterInvite.IsValid", "model.remote_cluster_invite.is_valid.remote_id.app_error", nil, "id="+rci.RemoteId, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if rci.Token == "" {
|
||||
return NewAppError("RemoteClusterInvite.IsValid", "model.remote_cluster_invite.is_valid.token.app_error", nil, "Token empty", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if _, err := url.ParseRequestURI(rci.SiteURL); err != nil {
|
||||
return NewAppError("RemoteClusterInvite.IsValid", "model.remote_cluster_invite.is_valid.site_url.app_error", nil, "", http.StatusBadRequest).Wrap(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (rci *RemoteClusterInvite) Encrypt(password string) ([]byte, error) {
|
||||
raw, err := json.Marshal(&rci)
|
||||
if err != nil {
|
||||
|
||||
Ссылка в новой задаче
Block a user