Skip to content
This repository has been archived by the owner on Jun 28, 2023. It is now read-only.

Commit

Permalink
Join rooms when registering rss service
Browse files Browse the repository at this point in the history
  • Loading branch information
kegsay committed Oct 12, 2016
1 parent b903860 commit 5f015e2
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/github.com/matrix-org/go-neb/services/rssbot/rssbot.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,30 @@ func (s *rssBotService) Register(oldService types.Service, client *matrix.Client
return fmt.Errorf("Feed %s has no rooms to send updates to", feedURL)
}
}

s.joinRooms(client)
return nil
}

func (s *rssBotService) joinRooms(client *matrix.Client) {
roomSet := make(map[string]bool)
for _, feedInfo := range s.Feeds {
for _, roomID := range feedInfo.Rooms {
roomSet[roomID] = true
}
}

for roomID := range roomSet {
if _, err := client.JoinRoom(roomID, "", ""); err != nil {
log.WithFields(log.Fields{
log.ErrorKey: err,
"room_id": roomID,
"user_id": client.UserID,
}).Error("Failed to join room")
}
}
}

func (s *rssBotService) PostRegister(oldService types.Service) {
if len(s.Feeds) == 0 { // bye-bye :(
logger := log.WithFields(log.Fields{
Expand Down

0 comments on commit 5f015e2

Please sign in to comment.