diff options
-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; |