From 3025690b08116d7360b64edba11a5f8e80ff4909 Mon Sep 17 00:00:00 2001 From: Agniva De Sarker Date: Fri, 7 Oct 2022 16:38:21 +0530 Subject: [PATCH] MM-47403: Add hooks to the product (#3962) We do this to get the changes published from the server. https://mattermost.atlassian.net/browse/MM-47403 ```release-note NONE ``` --- mattermost-plugin/product/boards_product.go | 14 ++++++++++++-- mattermost-plugin/server/manifest.go | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/mattermost-plugin/product/boards_product.go b/mattermost-plugin/product/boards_product.go index 97b37e446..1625663b8 100644 --- a/mattermost-plugin/product/boards_product.go +++ b/mattermost-plugin/product/boards_product.go @@ -25,7 +25,7 @@ const ( var errServiceTypeAssert = errors.New("type assertion failed") func init() { - app.RegisterProduct("boards", app.ProductManifest{ + app.RegisterProduct(boardsProductName, app.ProductManifest{ Initializer: newBoardsProduct, Dependencies: map[app.ServiceKey]struct{}{ app.TeamKey: {}, @@ -68,6 +68,7 @@ type boardsProduct struct { storeService product.StoreService systemService product.SystemService preferencesService product.PreferencesService + hooksService product.HooksService boardsApp *boards.BoardsApp } @@ -185,7 +186,12 @@ func newBoardsProduct(_ *app.Server, services map[app.ServiceKey]interface{}) (a return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert) } boards.preferencesService = preferencesService - case app.HooksKey: // not needed + case app.HooksKey: + hooksService, ok := service.(product.HooksService) + if !ok { + return nil, fmt.Errorf("invalid service key '%s': %w", key, errServiceTypeAssert) + } + boards.hooksService = hooksService } } return boards, nil @@ -207,6 +213,10 @@ func (bp *boardsProduct) Start() error { model.LogServerInfo(bp.logger) + if err := bp.hooksService.RegisterHooks(boardsProductName, bp); err != nil { + return fmt.Errorf("failed to register hooks: %w", err) + } + bp.boardsApp = boardsApp if err := bp.boardsApp.Start(); err != nil { return fmt.Errorf("failed to start Boards service: %w", err) diff --git a/mattermost-plugin/server/manifest.go b/mattermost-plugin/server/manifest.go index b7e894974..481a57c9f 100644 --- a/mattermost-plugin/server/manifest.go +++ b/mattermost-plugin/server/manifest.go @@ -20,7 +20,7 @@ const manifestStr = ` "support_url": "https://github.com/mattermost/focalboard/issues", "release_notes_url": "https://github.com/mattermost/focalboard/releases", "icon_path": "assets/starter-template-icon.svg", - "version": "7.4.0", + "version": "7.5.0", "min_server_version": "7.2.0", "server": { "executables": {