Skip to content
This repository was archived by the owner on Jul 19, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/cc/services/flowdock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class Config < CC::Service::Config
end

BASE_URL = "https://api.flowdock.com/v1"
INVALID_PROJECT_CHARACTERS = /[^0-9a-z\-_ ]+/i
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer a blacklist to a whitelist here? Does their system support unicode chars?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get the same validation error if I try something unicode.

I dug a bit deeper and found the official ruby client. It uses the same regex.

https://github.com/flowdock/flowdock-api/blob/master/lib/flowdock.rb#L37

I don't see any reason to do anything else.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


self.description = "Send messages to a Flowdock inbox"

Expand Down Expand Up @@ -45,7 +46,7 @@ def notify(subject, project, content)
from_name: "Code Climate",
format: "html",
subject: subject,
project: project,
project: project.gsub(INVALID_PROJECT_CHARACTERS, ''),
content: content,
link: "https://codeclimate.com"
}
Expand Down
6 changes: 5 additions & 1 deletion service_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@
CC::Service.load_services

def test_service(klass, config)
service = klass.new(:test, config, { repo_name: "Example" })
service = klass.new(:test, config, { repo_name: "Example.org" })
service.receive
end

test_service(CC::Service::Slack, {
webhook_url: "...",
channel: "..."
})

test_service(CC::Service::Flowdock, {
api_token: "..."
})
15 changes: 15 additions & 0 deletions test/flowdock_test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
require File.expand_path('../helper', __FILE__)

class TestFlowdock < CC::Service::TestCase
def test_valid_project_parameter
@stubs.post '/v1/messages/team_inbox/token' do |env|
body = Hash[URI.decode_www_form(env[:body])]
assert_equal "Exampleorg", body["project"]
[200, {}, '']
end

receive(
CC::Service::Flowdock,
:test,
{ api_token: "token" },
{ repo_name: "Example.org" }
)
end

def test_test_hook
assert_flowdock_receives(
:test,
Expand Down