From 9a4963ecb00f1d96ac727864b16de366f94c2cd0 Mon Sep 17 00:00:00 2001 From: Giorgi Bochorishvili Date: Mon, 26 Dec 2022 15:59:49 +0400 Subject: [PATCH] Add session, frontend and command services. --- app/channels.go | 2 ++ app/server.go | 2 ++ product/api.go | 22 ++++++++++++++++++++++ product/service.go | 3 +++ 4 files changed, 29 insertions(+) diff --git a/app/channels.go b/app/channels.go index 7ab024e45a..7f8ae06944 100644 --- a/app/channels.go +++ b/app/channels.go @@ -239,6 +239,8 @@ func NewChannels(services map[product.ServiceKey]any) (*Channels, error) { app: &App{ch: ch}, } + services[product.CommandKey] = &App{ch: ch} + return ch, nil } diff --git a/app/server.go b/app/server.go index c530bae271..7893e1aea4 100644 --- a/app/server.go +++ b/app/server.go @@ -253,6 +253,8 @@ func NewServer(options ...Option) (*Server, error) { product.KVStoreKey: s.platform, product.StoreKey: store.NewStoreServiceAdapter(s.Store()), product.SystemKey: &systemServiceAdapter{server: s}, + product.SessionKey: app, + product.FrontendKey: app, } // Step 4: Initialize products. diff --git a/product/api.go b/product/api.go index 6b37aae0a5..1ea0263b6f 100644 --- a/product/api.go +++ b/product/api.go @@ -231,3 +231,25 @@ type BoardsService interface { DeleteCard(cardID string, userID string) error HasPermissionToBoard(userID, boardID string, permission *model.Permission) bool } + +// SessionService is the API for accessing the session. +// +// The service shall be registered via app.SessionKey service key. +type SessionService interface { + GetSessionById(sessionID string) (*model.Session, *model.AppError) +} + +// FrontendService is the API for interacting with front end. +// +// The service shall be registered via app.FrontendKey service key. +type FrontendService interface { + OpenInteractiveDialog(dialog model.OpenDialogRequest) *model.AppError +} + +// CommandService is the API for interacting with front end. +// +// The service shall be registered via app.CommandKey service key. +type CommandService interface { + ExecuteCommand(c request.CTX, args *model.CommandArgs) (*model.CommandResponse, *model.AppError) + RegisterPluginCommand(pluginID string, command *model.Command) error +} diff --git a/product/service.go b/product/service.go index a0a92e6adc..f8100e789b 100644 --- a/product/service.go +++ b/product/service.go @@ -26,4 +26,7 @@ const ( SystemKey ServiceKey = "systemkey" PreferencesKey ServiceKey = "preferenceskey" BoardsKey ServiceKey = "boards" + SessionKey ServiceKey = "sessionkey" + FrontendKey ServiceKey = "frontendkey" + CommandKey ServiceKey = "commandkey" )