1
0
mirror of https://github.com/mattermost/focalboard.git synced 2025-02-07 19:30:18 +02:00
focalboard/server/ws/plugin_adapter_client.go
Rajat Dabade c8e729b6fe
[Refactor]: updated dependency for focalboard server (#5009)
* refactor: updated dependency for focalboard server

* chore: more dependency fixes

* refactor: removed the unless code

* refactor: added ctx for login and removed unnessary code

* refactor: bump up go version

* refactor: removed the commented code

* chore: upgraded golinter version

* fix: linter issue

* refactor: removed feature flg fix golinter

* refactor: removed feature flag from code

* revert: statistic and it's function

* refactor: removed ProductLimit related code

* refactor: removed isWithinViewsLimit implementation

* refactor: moved function GetUsedCardsCount to statistics.go from cloud.go

* refactor: removed insight code board

* refactor: removed limit dialog

* refactor: updated dependencies for linux

* chore: golinter fix

* chore: updated helper test function to use newLogger

* fix: go test

* refactor: db ping attempts from config

* revert: feature in action

* revert: feature flag in action

* revert: boardsEditor setting

---------

Co-authored-by: Rajat Dabade <rajat@Rajats-MacBook-Pro.local>
2024-06-07 23:30:08 +05:30

87 lines
1.7 KiB
Go

package ws
import (
"sync"
"sync/atomic"
"time"
mmModel "github.com/mattermost/mattermost/server/public/model"
)
type PluginAdapterClient struct {
inactiveAt int64
webConnID string
userID string
teams []string
blocks []string
mu sync.RWMutex
}
func (pac *PluginAdapterClient) isActive() bool {
return atomic.LoadInt64(&pac.inactiveAt) == 0
}
func (pac *PluginAdapterClient) hasExpired(threshold time.Duration) bool {
return !mmModel.GetTimeForMillis(atomic.LoadInt64(&pac.inactiveAt)).Add(threshold).After(time.Now())
}
func (pac *PluginAdapterClient) subscribeToTeam(teamID string) {
pac.mu.Lock()
defer pac.mu.Unlock()
pac.teams = append(pac.teams, teamID)
}
func (pac *PluginAdapterClient) unsubscribeFromTeam(teamID string) {
pac.mu.Lock()
defer pac.mu.Unlock()
newClientTeams := []string{}
for _, id := range pac.teams {
if id != teamID {
newClientTeams = append(newClientTeams, id)
}
}
pac.teams = newClientTeams
}
func (pac *PluginAdapterClient) unsubscribeFromBlock(blockID string) {
pac.mu.Lock()
defer pac.mu.Unlock()
newClientBlocks := []string{}
for _, id := range pac.blocks {
if id != blockID {
newClientBlocks = append(newClientBlocks, id)
}
}
pac.blocks = newClientBlocks
}
func (pac *PluginAdapterClient) isSubscribedToTeam(teamID string) bool {
pac.mu.RLock()
defer pac.mu.RUnlock()
for _, id := range pac.teams {
if id == teamID {
return true
}
}
return false
}
//nolint:unused
func (pac *PluginAdapterClient) isSubscribedToBlock(blockID string) bool {
pac.mu.RLock()
defer pac.mu.RUnlock()
for _, id := range pac.blocks {
if id == blockID {
return true
}
}
return false
}