diff --git a/Gemfile b/Gemfile index 6d055702182..4449be837ec 100644 --- a/Gemfile +++ b/Gemfile @@ -97,6 +97,7 @@ gem "rake" gem "thor", require: false gem "diffy", require: false +gem "rinku" gem "sidekiq" gem "mini_scheduler" diff --git a/Gemfile.lock b/Gemfile.lock index 324145995c8..0594b8f1d7f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -436,6 +436,7 @@ GEM request_store (1.7.0) rack (>= 1.4) rexml (3.4.1) + rinku (2.0.6) rotp (6.3.0) rouge (4.5.1) rqrcode (2.2.0) @@ -748,6 +749,7 @@ DEPENDENCIES redcarpet redis (< 5.0) redis-namespace + rinku rotp rqrcode rrule @@ -1002,6 +1004,7 @@ CHECKSUMS reline (0.6.0) sha256=57620375dcbe56ec09bac7192bfb7460c716bbf0054dc94345ecaa5438e539d2 request_store (1.7.0) sha256=e1b75d5346a315f452242a68c937ef8e48b215b9453a77a6c0acdca2934c88cb rexml (3.4.1) sha256=c74527a9a0a04b4ec31dbe0dc4ed6004b960af943d8db42e539edde3a871abca + rinku (2.0.6) sha256=8b60670e3143f3db2b37efa262971ce3619ec23092045498ef9f077d82828d7d rotp (6.3.0) sha256=75d40087e65ed0d8022c33055a6306c1c400d1c12261932533b5d6cbcd868854 rouge (4.5.1) sha256=2ac81c6dee7019bbc6600d4c2d641d730d65c165941400ebd924259067e690dd rqrcode (2.2.0) sha256=23eea88bb44c7ee6d6cab9354d08c287f7ebcdc6112e1fe7bcc2d010d1ffefc1 diff --git a/lib/twitter_api.rb b/lib/twitter_api.rb index c1ffb95c4b0..533c9ec2d9a 100644 --- a/lib/twitter_api.rb +++ b/lib/twitter_api.rb @@ -26,8 +26,7 @@ class TwitterApi end end text = link_hashtags_in link_handles_in text - result = - PrettyText.cook(text, features_override: []).delete_prefix("
").delete_suffix("
") + result = Rinku.auto_link(text, :all, 'target="_blank"').to_s if tweet[:includes] && media = tweet[:includes][:media] media.each do |m| diff --git a/spec/lib/twitter_api_spec.rb b/spec/lib/twitter_api_spec.rb index 2662a723f11..7468470991a 100644 --- a/spec/lib/twitter_api_spec.rb +++ b/spec/lib/twitter_api_spec.rb @@ -16,53 +16,4 @@ RSpec.describe TwitterApi do HTML end end - - describe ".prettify_tweet" do - let(:api_response) do - { - data: { - edit_history_tweet_ids: ["1625192182859632661"], - created_at: "2023-02-13T17:56:25.000Z", - author_id: "29873662", - public_metrics: { - retweet_count: 1460, - reply_count: 2734, - like_count: 46_756, - quote_count: 477, - bookmark_count: 168, - impression_count: 4_017_878, - }, - text: - "Shoutout to @discourse for making online communities thrive! Just launched a new plugin—check it out here: https://example.com/discourse-plugin 🔥 #forum", - entities: { - annotations: [ - { - start: 18, - end: 26, - probability: 0.9807, - type: "Other", - normalized_text: "Minecraft", - }, - ], - }, - id: "1625192182859632661", - }, - includes: { - users: [ - { - name: "Marques Brownlee", - id: "29873662", - profile_image_url: - "https://pbs.twimg.com/profile_images/1468001914302390278/B_Xv_8gu_normal.jpg", - username: "MKBHD", - }, - ], - }, - } - end - - it { expect(described_class.prettify_tweet(api_response)).to eq(<<~HTML.strip) } - Shoutout to @discourse for making online communities thrive! Just launched a new plugin—check it out here: https://example.com/discourse-plugin 🔥 #forum - HTML - end end