From 930c645e60c257bccd1a2485e08d2a986d502fc4 Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Sun, 24 Nov 2024 11:51:38 -0500 Subject: [PATCH] Unfurl into blocks. --- .rubocop_todo.yml | 2 +- slack-strava/api/endpoints/requests/event.rb | 8 +++++--- spec/api/endpoints/slack_endpoint_spec.rb | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 9dde99d..82ba662 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2024-11-24 16:41:14 UTC using RuboCop version 1.68.0. +# on 2024-11-24 16:50:24 UTC using RuboCop version 1.68.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new diff --git a/slack-strava/api/endpoints/requests/event.rb b/slack-strava/api/endpoints/requests/event.rb index 9fd1e38..b2befde 100644 --- a/slack-strava/api/endpoints/requests/event.rb +++ b/slack-strava/api/endpoints/requests/event.rb @@ -44,12 +44,14 @@ def unfurl! next unless activity logger.info "UNFURL: #{link.url}, #{activity}" + + unfurls = { link.url => { blocks: activity.to_slack_blocks } } + logger.debug(unfurls) + team.activated_user_slack_client.chat_unfurl( channel: event.channel, ts: event.message_ts, - unfurls: { - link.url => activity.to_slack_attachment - }.to_json + unfurls: unfurls.to_json ) activity.update_attributes!(bragged_at: Time.now.utc) diff --git a/spec/api/endpoints/slack_endpoint_spec.rb b/spec/api/endpoints/slack_endpoint_spec.rb index a4f6fdc..efc7a93 100644 --- a/spec/api/endpoints/slack_endpoint_spec.rb +++ b/spec/api/endpoints/slack_endpoint_spec.rb @@ -471,7 +471,7 @@ channel: 'C1', ts: '1547842100.001400', unfurls: { - activity.strava_url => activity.to_slack_attachment + activity.strava_url => { 'blocks' => activity.to_slack_blocks } }.to_json )