mirror of
https://github.com/mattermost/focalboard.git
synced 2024-12-21 13:38:56 +02:00
11bd3720f1
* remove unneeded store interfaces * - reduce dependencies for notifications service - notifications service no longer concerned with web socket notifications gnored, and an empty message aborts the commit. * use app to add member to board * remove unneeded API * remove dependency on app package * fix webapp jest Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
53 lines
1.3 KiB
Go
53 lines
1.3 KiB
Go
package app
|
|
|
|
import (
|
|
"github.com/mattermost/focalboard/server/model"
|
|
"github.com/mattermost/focalboard/server/utils"
|
|
|
|
"github.com/mattermost/mattermost-server/v6/shared/mlog"
|
|
)
|
|
|
|
func (a *App) CreateSubscription(sub *model.Subscription) (*model.Subscription, error) {
|
|
sub, err := a.store.CreateSubscription(sub)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
a.notifySubscriptionChanged(sub)
|
|
|
|
return sub, nil
|
|
}
|
|
|
|
func (a *App) DeleteSubscription(blockID string, subscriberID string) (*model.Subscription, error) {
|
|
sub, err := a.store.GetSubscription(blockID, subscriberID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if err := a.store.DeleteSubscription(blockID, subscriberID); err != nil {
|
|
return nil, err
|
|
}
|
|
sub.DeleteAt = utils.GetMillis()
|
|
a.notifySubscriptionChanged(sub)
|
|
|
|
return sub, nil
|
|
}
|
|
|
|
func (a *App) GetSubscriptions(subscriberID string) ([]*model.Subscription, error) {
|
|
return a.store.GetSubscriptions(subscriberID)
|
|
}
|
|
|
|
func (a *App) notifySubscriptionChanged(subscription *model.Subscription) {
|
|
if a.notifications == nil {
|
|
return
|
|
}
|
|
|
|
board, err := a.getBoardForBlock(subscription.BlockID)
|
|
if err != nil {
|
|
a.logger.Error("Error notifying subscription change",
|
|
mlog.String("subscriber_id", subscription.SubscriberID),
|
|
mlog.String("block_id", subscription.BlockID),
|
|
mlog.Err(err),
|
|
)
|
|
}
|
|
a.wsAdapter.BroadcastSubscriptionChange(board.TeamID, subscription)
|
|
}
|