It was a good decision in hindsight to keep the public module as 0.x because this would have been a breaking change again. https://mattermost.atlassian.net/browse/MM-53032 ```release-note Changed the Go module path from github.com/mattermost/mattermost-server/server/v8 to github.com/mattermost/mattermost/server/v8. For the public facing module, it's path is also changed from github.com/mattermost/mattermost-server/server/public to github.com/mattermost/mattermost/server/public ```
56 строки
1.5 KiB
Go
56 строки
1.5 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package app
|
|
|
|
import (
|
|
"github.com/mattermost/mattermost/server/v8/boards/model"
|
|
"github.com/mattermost/mattermost/server/v8/boards/utils"
|
|
|
|
"github.com/mattermost/mattermost/server/public/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)
|
|
}
|