summaryrefslogtreecommitdiffstats
path: root/bridge/bridge.go
diff options
context:
space:
mode:
Diffstat (limited to 'bridge/bridge.go')
-rw-r--r--bridge/bridge.go34
1 files changed, 23 insertions, 11 deletions
diff --git a/bridge/bridge.go b/bridge/bridge.go
index 336e2e2c..6b955a9e 100644
--- a/bridge/bridge.go
+++ b/bridge/bridge.go
@@ -5,6 +5,7 @@ import (
"github.com/42wim/matterbridge/bridge/config"
"github.com/sirupsen/logrus"
+ "sync"
)
type Bridger interface {
@@ -16,14 +17,16 @@ type Bridger interface {
type Bridge struct {
Bridger
- Name string
- Account string
- Protocol string
- Channels map[string]config.ChannelInfo
- Joined map[string]bool
- Log *logrus.Entry
- Config config.Config
- General *config.Protocol
+ Name string
+ Account string
+ Protocol string
+ Channels map[string]config.ChannelInfo
+ Joined map[string]bool
+ ChannelMembers *config.ChannelMembers
+ Log *logrus.Entry
+ Config config.Config
+ General *config.Protocol
+ *sync.RWMutex
}
type Config struct {
@@ -37,15 +40,17 @@ type Config struct {
type Factory func(*Config) Bridger
func New(bridge *config.Bridge) *Bridge {
- b := new(Bridge)
- b.Channels = make(map[string]config.ChannelInfo)
+ b := &Bridge{
+ Channels: make(map[string]config.ChannelInfo),
+ RWMutex: new(sync.RWMutex),
+ Joined: make(map[string]bool),
+ }
accInfo := strings.Split(bridge.Account, ".")
protocol := accInfo[0]
name := accInfo[1]
b.Name = name
b.Protocol = protocol
b.Account = bridge.Account
- b.Joined = make(map[string]bool)
return b
}
@@ -54,6 +59,13 @@ func (b *Bridge) JoinChannels() error {
return err
}
+// SetChannelMembers sets the newMembers to the bridge ChannelMembers
+func (b *Bridge) SetChannelMembers(newMembers *config.ChannelMembers) {
+ b.Lock()
+ b.ChannelMembers = newMembers
+ b.Unlock()
+}
+
func (b *Bridge) joinChannels(channels map[string]config.ChannelInfo, exists map[string]bool) error {
for ID, channel := range channels {
if !exists[ID] {