From efe04d791701bc0973ea724e46a765b8711fac2b Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Thu, 1 Dec 2016 15:23:34 +0000 Subject: [PATCH] Keep doing the Inviter hack when joining rooms so non-ops can kick the bot they invited --- src/github.com/matrix-org/go-neb/clients/clients.go | 6 +++++- .../matrix-org/go-neb/services/github/github_webhook.go | 2 +- src/github.com/matrix-org/go-neb/services/rssbot/rssbot.go | 2 +- .../matrix-org/go-neb/services/travisci/travisci.go | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/github.com/matrix-org/go-neb/clients/clients.go b/src/github.com/matrix-org/go-neb/clients/clients.go index 6989bde..3a7d816 100644 --- a/src/github.com/matrix-org/go-neb/clients/clients.go +++ b/src/github.com/matrix-org/go-neb/clients/clients.go @@ -311,7 +311,11 @@ func (c *Clients) onRoomMemberEvent(client *gomatrix.Client, event *gomatrix.Eve }) logger.Print("Accepting invite from user") - if _, err := client.JoinRoom(event.RoomID, "", event.Sender); err != nil { + content := struct { + Inviter string `json:"inviter"` + }{event.Sender} + + if _, err := client.JoinRoom(event.RoomID, "", content); err != nil { logger.WithError(err).Print("Failed to join room") } else { logger.Print("Joined room") diff --git a/src/github.com/matrix-org/go-neb/services/github/github_webhook.go b/src/github.com/matrix-org/go-neb/services/github/github_webhook.go index 7a2a0cd..6951874 100644 --- a/src/github.com/matrix-org/go-neb/services/github/github_webhook.go +++ b/src/github.com/matrix-org/go-neb/services/github/github_webhook.go @@ -253,7 +253,7 @@ func (s *WebhookService) PostRegister(oldService types.Service) { func (s *WebhookService) joinWebhookRooms(client *gomatrix.Client) error { for roomID := range s.Rooms { - if _, err := client.JoinRoom(roomID, "", ""); err != nil { + if _, err := client.JoinRoom(roomID, "", nil); err != nil { // TODO: Leave the rooms we successfully joined? return err } diff --git a/src/github.com/matrix-org/go-neb/services/rssbot/rssbot.go b/src/github.com/matrix-org/go-neb/services/rssbot/rssbot.go index 9708ab7..a0112af 100644 --- a/src/github.com/matrix-org/go-neb/services/rssbot/rssbot.go +++ b/src/github.com/matrix-org/go-neb/services/rssbot/rssbot.go @@ -109,7 +109,7 @@ func (s *Service) joinRooms(client *gomatrix.Client) { } for roomID := range roomSet { - if _, err := client.JoinRoom(roomID, "", ""); err != nil { + if _, err := client.JoinRoom(roomID, "", nil); err != nil { log.WithFields(log.Fields{ log.ErrorKey: err, "room_id": roomID, diff --git a/src/github.com/matrix-org/go-neb/services/travisci/travisci.go b/src/github.com/matrix-org/go-neb/services/travisci/travisci.go index 9248d72..62a0565 100644 --- a/src/github.com/matrix-org/go-neb/services/travisci/travisci.go +++ b/src/github.com/matrix-org/go-neb/services/travisci/travisci.go @@ -275,7 +275,7 @@ func (s *Service) PostRegister(oldService types.Service) { func (s *Service) joinRooms(client *gomatrix.Client) { for roomID := range s.Rooms { - if _, err := client.JoinRoom(roomID, "", ""); err != nil { + if _, err := client.JoinRoom(roomID, "", nil); err != nil { log.WithFields(log.Fields{ log.ErrorKey: err, "room_id": roomID,