summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Lawrence <dkl@mozilla.com>2016-07-25 20:44:18 +0200
committerDavid Lawrence <dkl@mozilla.com>2016-07-25 20:44:18 +0200
commit6e47481f190a18107449a56ffb93d21ab725e10f (patch)
tree3839b37b47dbdb1342c1a465e97031b82ce595f7
parent7bc7cd39d95562778f20bdd39f7abc1533870f72 (diff)
downloadbugzilla-6e47481f190a18107449a56ffb93d21ab725e10f.tar.gz
bugzilla-6e47481f190a18107449a56ffb93d21ab725e10f.tar.xz
Bug 1286988 - Cisco Spark BMO bot configured to lookup room name; consider using room identifier
-rw-r--r--extensions/Push/lib/Connector/Spark.pm28
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;