Plugin API for Shared Channels: support auto invite (#25834)
* option for auto inviting plugin to all shared channels. * auto-invite remotes to shared channels when flag set * fix unit test --------- Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
@@ -22,7 +22,8 @@ const (
|
||||
RemoteNameMinLength = 1
|
||||
RemoteNameMaxLength = 64
|
||||
|
||||
BitflagOptionAutoShareDMs Bitmask = 1 << iota
|
||||
BitflagOptionAutoShareDMs Bitmask = 1 << iota // Any new DM/GM is automatically shared
|
||||
BitflagOptionAutoInvited // Remote is automatically invited to all shared channels
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -31,6 +32,18 @@ var (
|
||||
|
||||
type Bitmask uint32
|
||||
|
||||
func (bm *Bitmask) IsBitSet(flag Bitmask) bool {
|
||||
return *bm != 0
|
||||
}
|
||||
|
||||
func (bm *Bitmask) SetBit(flag Bitmask) {
|
||||
*bm |= flag
|
||||
}
|
||||
|
||||
func (bm *Bitmask) UnsetBit(flag Bitmask) {
|
||||
*bm &= ^flag
|
||||
}
|
||||
|
||||
type RemoteCluster struct {
|
||||
RemoteId string `json:"remote_id"`
|
||||
RemoteTeamId string `json:"remote_team_id"`
|
||||
@@ -105,15 +118,15 @@ func (rc *RemoteCluster) IsValid() *AppError {
|
||||
}
|
||||
|
||||
func (rc *RemoteCluster) IsOptionFlagSet(flag Bitmask) bool {
|
||||
return rc.Options&flag != 0
|
||||
return rc.Options.IsBitSet(flag)
|
||||
}
|
||||
|
||||
func (rc *RemoteCluster) SetOptionFlag(flag Bitmask) {
|
||||
rc.Options |= flag
|
||||
rc.Options.SetBit(flag)
|
||||
}
|
||||
|
||||
func (rc *RemoteCluster) UnsetOptionFlag(flag Bitmask) {
|
||||
rc.Options &= ^flag
|
||||
rc.Options.UnsetBit(flag)
|
||||
}
|
||||
|
||||
func IsValidRemoteName(s string) bool {
|
||||
@@ -340,4 +353,5 @@ type RemoteClusterQueryFilter struct {
|
||||
CreatorId string
|
||||
OnlyConfirmed bool
|
||||
PluginID string
|
||||
RequireOptions Bitmask
|
||||
}
|
||||
|
||||
@@ -305,6 +305,7 @@ type RegisterPluginOpts struct {
|
||||
PluginID string // id of this plugin registering
|
||||
CreatorID string // id of the user/bot registering
|
||||
AutoShareDMs bool // when true, all DMs are automatically shared to this remote
|
||||
AutoInvited bool // when true, the plugin is automatically invited and sync'd with all shared channels.
|
||||
}
|
||||
|
||||
// GetOptionFlags returns a Bitmask of option flags as specified by the boolean options.
|
||||
@@ -313,5 +314,8 @@ func (po RegisterPluginOpts) GetOptionFlags() Bitmask {
|
||||
if po.AutoShareDMs {
|
||||
flags |= BitflagOptionAutoShareDMs
|
||||
}
|
||||
if po.AutoInvited {
|
||||
flags |= BitflagOptionAutoInvited
|
||||
}
|
||||
return flags
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user