Skip to content

Commit

Permalink
Fix: do not unfurl bot events.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Nov 29, 2024
1 parent f331f4b commit 441863a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions slack-strava/api/endpoints/requests/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def user

def unfurl!
return unless event&.links && user
return if user.is_bot

event.links.each do |link|
next unless link.domain == 'strava.com'
Expand Down
13 changes: 13 additions & 0 deletions spec/api/endpoints/slack_endpoint_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,19 @@
expect(last_response.status).to eq 201
end
end

context 'with a bot user' do
before do
user.update_attributes!(is_bot: true)
end

it 'does not unfurl' do
expect_any_instance_of(User).not_to receive(:sync_strava_activity!)
expect_any_instance_of(Slack::Web::Client).not_to receive(:chat_unfurl)
post '/api/slack/event', payload
expect(last_response.status).to eq 201
end
end
end
end
end
Expand Down

0 comments on commit 441863a

Please sign in to comment.