https://community.mattermost.com/boards/workspace/zyoahc9uapdn3xdptac6jb69ic/285b80a3-257d-41f6-8cf4-ed80ca9d92e5/495cdb4d-c13a-4992-8eb9-80cfee2819a4?c=65b44de0-1a9c-4643-84c1-5d803593f314 This PR improves on two things at once: - It fixes the race condition by removing global variables. - But instead of moving them to Server, it moves them inside Channels, thereby making one more step towards the multi-product architecture. ```release-note NONE ```
45 строки
960 B
Go
45 строки
960 B
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package app
|
|
|
|
import (
|
|
"github.com/mattermost/mattermost-server/v6/model"
|
|
"github.com/mattermost/mattermost-server/v6/services/imageproxy"
|
|
)
|
|
|
|
// Channels contains all channels related state.
|
|
type Channels struct {
|
|
srv *Server
|
|
|
|
imageProxy *imageproxy.ImageProxy
|
|
|
|
// cached counts that are used during notice condition validation
|
|
cachedPostCount int64
|
|
cachedUserCount int64
|
|
cachedDBMSVersion string
|
|
// previously fetched notices
|
|
cachedNotices model.ProductNotices
|
|
}
|
|
|
|
func init() {
|
|
RegisterProduct("channels", func(s *Server) (Product, error) {
|
|
return NewChannels(s)
|
|
})
|
|
}
|
|
|
|
func NewChannels(s *Server) (*Channels, error) {
|
|
return &Channels{
|
|
srv: s,
|
|
imageProxy: imageproxy.MakeImageProxy(s, s.httpService, s.Log),
|
|
}, nil
|
|
}
|
|
|
|
func (c *Channels) Start() error {
|
|
return nil
|
|
}
|
|
|
|
func (c *Channels) Stop() error {
|
|
return nil
|
|
}
|