MM-57786 Fix Shared Channels plugin api (#26753)
* always ping on plugin registration; SharedChannel.IsValid allow no team for GM * wait for services to start before ping * ping plugin remotes synchronously on startup * remove the waitForInterClusterServices stuff * don't set remoteid when inviting remote to channel * Update server/public/model/remote_cluster_test.go Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com> * address review comments --------- Co-authored-by: Mattermost Build <build@mattermost.com> Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>
Этот коммит содержится в:
@@ -6,7 +6,9 @@ package model
|
||||
import (
|
||||
"crypto/aes"
|
||||
"crypto/cipher"
|
||||
"crypto/md5"
|
||||
"crypto/rand"
|
||||
"encoding/base32"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
@@ -80,7 +82,11 @@ func (rc *RemoteCluster) Auditable() map[string]interface{} {
|
||||
|
||||
func (rc *RemoteCluster) PreSave() {
|
||||
if rc.RemoteId == "" {
|
||||
rc.RemoteId = NewId()
|
||||
if rc.PluginID != "" {
|
||||
rc.RemoteId = newIDFromBytes([]byte(rc.PluginID))
|
||||
} else {
|
||||
rc.RemoteId = NewId()
|
||||
}
|
||||
}
|
||||
|
||||
if rc.DisplayName == "" {
|
||||
@@ -120,6 +126,16 @@ func (rc *RemoteCluster) IsValid() *AppError {
|
||||
return nil
|
||||
}
|
||||
|
||||
func newIDFromBytes(b []byte) string {
|
||||
hash := md5.New()
|
||||
_, _ = hash.Write(b)
|
||||
buf := hash.Sum(nil)
|
||||
|
||||
var encoding = base32.NewEncoding("ybndrfg8ejkmcpqxot1uwisza345h769").WithPadding(base32.NoPadding)
|
||||
id := encoding.EncodeToString(buf)
|
||||
return id[:26]
|
||||
}
|
||||
|
||||
func (rc *RemoteCluster) IsOptionFlagSet(flag Bitmask) bool {
|
||||
return rc.Options.IsBitSet(flag)
|
||||
}
|
||||
@@ -385,5 +401,6 @@ type RemoteClusterQueryFilter struct {
|
||||
CreatorId string
|
||||
OnlyConfirmed bool
|
||||
PluginID string
|
||||
OnlyPlugins bool
|
||||
RequireOptions Bitmask
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user