From b45afac270d629fa0eccfcef33654e041f55b230 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Fri, 19 Aug 2016 13:15:17 +0100 Subject: [PATCH] Add flags to control if the GH Service should handle expansions/commands --- .../matrix-org/go-neb/services/github/github.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/github.com/matrix-org/go-neb/services/github/github.go b/src/github.com/matrix-org/go-neb/services/github/github.go index c628b26..6d65e87 100644 --- a/src/github.com/matrix-org/go-neb/services/github/github.go +++ b/src/github.com/matrix-org/go-neb/services/github/github.go @@ -29,6 +29,8 @@ type githubService struct { ClientUserID string RealmID string SecretToken string + HandleCommands bool + HandleExpansions bool Rooms map[string]struct { // room_id => {} Repos map[string]struct { // owner/repo => { events: ["push","issue","pull_request"] } Events []string @@ -48,6 +50,9 @@ func (s *githubService) RoomIDs() []string { } func (s *githubService) cmdGithubCreate(roomID, userID string, args []string) (interface{}, error) { + if !s.HandleCommands { + return nil, nil + } cli := s.githubClientFor(userID, false) if cli == nil { r, err := database.GetServiceDB().LoadAuthRealm(s.RealmID) @@ -104,6 +109,9 @@ func (s *githubService) cmdGithubCreate(roomID, userID string, args []string) (i } func (s *githubService) expandIssue(roomID, userID string, matchingGroups []string) interface{} { + if !s.HandleExpansions { + return nil + } // matchingGroups => ["foo/bar#11", "foo", "bar", "11"] if len(matchingGroups) != 4 { log.WithField("groups", matchingGroups).Print("Unexpected number of groups")