diff options
author | David Lawrence <dkl@mozilla.com> | 2016-07-25 20:44:18 +0200 |
---|---|---|
committer | David Lawrence <dkl@mozilla.com> | 2016-07-25 20:44:18 +0200 |
commit | 6e47481f190a18107449a56ffb93d21ab725e10f (patch) | |
tree | 3839b37b47dbdb1342c1a465e97031b82ce595f7 /extensions/Push/lib/Connector | |
parent | 7bc7cd39d95562778f20bdd39f7abc1533870f72 (diff) | |
download | bugzilla-6e47481f190a18107449a56ffb93d21ab725e10f.tar.gz bugzilla-6e47481f190a18107449a56ffb93d21ab725e10f.tar.xz |
Bug 1286988 - Cisco Spark BMO bot configured to lookup room name; consider using room identifier
Diffstat (limited to 'extensions/Push/lib/Connector')
-rw-r--r-- | extensions/Push/lib/Connector/Spark.pm | 28 |
1 files changed, 3 insertions, 25 deletions
diff --git a/extensions/Push/lib/Connector/Spark.pm b/extensions/Push/lib/Connector/Spark.pm index 548b2ab54..a65567916 100644 --- a/extensions/Push/lib/Connector/Spark.pm +++ b/extensions/Push/lib/Connector/Spark.pm @@ -33,8 +33,8 @@ sub options { required => 1, }, { - name => 'spark_room', - label => 'Spark Room Name', + name => 'spark_room_id', + label => 'Spark Room ID', type => 'string', default => 'bugzilla', required => 1, @@ -109,7 +109,7 @@ sub send { } $text .= correct_urlbase() . "show_bug.cgi?id=" . $bug->id; - my $room_id = $self->_get_spark_room_id; + my $room_id = $self->config->{spark_room_id}; my $message_uri = $self->_spark_uri('messages'); my $json_data = { roomId => $room_id, text => $text }; @@ -170,26 +170,4 @@ sub _spark_uri { return URI->new($self->config->{spark_endpoint} . "/" . $path); } -sub _get_spark_room_id { - my ($self) = @_; - my $rooms_uri = $self->_spark_uri('rooms'); - my $resp = $self->_user_agent->get($rooms_uri); - - if ($resp->code == 200) { - my $result = eval { decode_json($resp->content) }; - if ($@ || !exists $result->{items}) { - die "Unable to parse JSON: $result"; - } - foreach my $item (@{ $result->{items} }) { - if ($item->{title} eq $self->config->{spark_room}) { - return $item->{id}; - } - } - die "Room ID not found"; - } - else { - die "Expected HTTP 200 response, got " . $resp->code; - } -} - 1; |