[MM-53968] Includes mattermost-plugin-api into the mono repo (#24235)
Include https://github.com/mattermost/mattermost-plugin-api into the mono repo Co-authored-by: Jesse Hallam <jesse.hallam@gmail.com> Co-authored-by: Michael Kochell <mjkochell@gmail.com> Co-authored-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com> Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com> Co-authored-by: Alex Dovenmuehle <alex.dovenmuehle@mattermost.com> Co-authored-by: Michael Kochell <6913320+mickmister@users.noreply.github.com> Co-authored-by: Christopher Poile <cpoile@gmail.com> Co-authored-by: İlker Göktuğ Öztürk <ilkergoktugozturk@gmail.com> Co-authored-by: Shota Gvinepadze <wineson@gmail.com> Co-authored-by: Ali Farooq <ali.farooq0@pm.me> Co-authored-by: Maria A Nunez <maria.nunez@mattermost.com> Co-authored-by: Daniel Espino García <larkox@gmail.com> Co-authored-by: Christopher Speller <crspeller@gmail.com> Co-authored-by: Alex Dovenmuehle <adovenmuehle@gmail.com> Co-authored-by: Szymon Gibała <szymongib@gmail.com> Co-authored-by: Lev <1187448+levb@users.noreply.github.com> Co-authored-by: Jason Frerich <jason.frerich@mattermost.com> Co-authored-by: Agniva De Sarker <agnivade@yahoo.co.in> Co-authored-by: Artur M. Wolff <artur.m.wolff@gmail.com> Co-authored-by: Madhav Hugar <16546715+madhavhugar@users.noreply.github.com> Co-authored-by: Joe <security.joe@pm.me> Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com> Co-authored-by: José Peso <trilopin@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
bc11b29807
Коммит
3ee5432664
79
server/public/pluginapi/client.go
Обычный файл
79
server/public/pluginapi/client.go
Обычный файл
@@ -0,0 +1,79 @@
|
||||
package pluginapi
|
||||
|
||||
import (
|
||||
"github.com/blang/semver/v4"
|
||||
"github.com/mattermost/mattermost/server/public/plugin"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// Client is a streamlined wrapper over the mattermost plugin API.
|
||||
type Client struct {
|
||||
api plugin.API
|
||||
|
||||
Bot BotService
|
||||
Channel ChannelService
|
||||
Cluster ClusterService
|
||||
Configuration ConfigurationService
|
||||
SlashCommand SlashCommandService
|
||||
OAuth OAuthService
|
||||
Emoji EmojiService
|
||||
File FileService
|
||||
Frontend FrontendService
|
||||
Group GroupService
|
||||
KV KVService
|
||||
Log LogService
|
||||
Mail MailService
|
||||
Plugin PluginService
|
||||
Post PostService
|
||||
Session SessionService
|
||||
Store *StoreService
|
||||
System SystemService
|
||||
Team TeamService
|
||||
User UserService
|
||||
}
|
||||
|
||||
// NewClient creates a new instance of Client.
|
||||
//
|
||||
// This client must only be created once per plugin to
|
||||
// prevent reacquiring of resources.
|
||||
func NewClient(api plugin.API, driver plugin.Driver) *Client {
|
||||
return &Client{
|
||||
api: api,
|
||||
|
||||
Bot: BotService{api: api},
|
||||
Channel: ChannelService{api: api},
|
||||
Cluster: ClusterService{api: api},
|
||||
Configuration: ConfigurationService{api: api},
|
||||
SlashCommand: SlashCommandService{api: api},
|
||||
OAuth: OAuthService{api: api},
|
||||
Emoji: EmojiService{api: api},
|
||||
File: FileService{api: api},
|
||||
Frontend: FrontendService{api: api},
|
||||
Group: GroupService{api: api},
|
||||
KV: KVService{api: api},
|
||||
Log: LogService{api: api},
|
||||
Mail: MailService{api: api},
|
||||
Plugin: PluginService{api: api},
|
||||
Post: PostService{api: api},
|
||||
Session: SessionService{api: api},
|
||||
Store: &StoreService{
|
||||
api: api,
|
||||
driver: driver,
|
||||
},
|
||||
System: SystemService{api: api},
|
||||
Team: TeamService{api: api},
|
||||
User: UserService{api: api},
|
||||
}
|
||||
}
|
||||
|
||||
func ensureServerVersion(api plugin.API, required string) error {
|
||||
serverVersion := api.GetServerVersion()
|
||||
currentVersion := semver.MustParse(serverVersion)
|
||||
requiredVersion := semver.MustParse(required)
|
||||
|
||||
if currentVersion.LT(requiredVersion) {
|
||||
return errors.Errorf("incompatible server version for plugin, minimum required version: %s, current version: %s", required, serverVersion)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Ссылка в новой задаче
Block a user