remove tumblr

Resolves #274
This commit is contained in:
Georg Gadinger 2022-01-05 18:32:30 +01:00
parent bbe5325ba5
commit 3c58257d21
11 changed files with 19 additions and 125 deletions

View File

@ -55,13 +55,10 @@ gem 'httparty'
# OmniAuth and providers # OmniAuth and providers
gem 'omniauth' gem 'omniauth'
gem 'omniauth-twitter' gem 'omniauth-twitter'
gem 'omniauth-tumblr'
# OAuth clients # OAuth clients
gem 'twitter' gem 'twitter'
gem 'twitter-text' gem 'twitter-text'
# To use a more recent Faraday version, a fork of this gem is required.
gem 'tumblr_client', git: 'https://github.com/amplifr/tumblr_client'
gem 'redis' gem 'redis'

View File

@ -6,18 +6,6 @@ GIT
hcaptcha (6.0.2) hcaptcha (6.0.2)
json json
GIT
remote: https://github.com/amplifr/tumblr_client
revision: 3927ee366598a9b70b095933ded32e45f730b652
specs:
tumblr_client (0.8.5)
faraday
faraday_middleware
json
mime-types
oauth
simple_oauth
GIT GIT
remote: https://github.com/mltnhm/carrierwave_backgrounder.git remote: https://github.com/mltnhm/carrierwave_backgrounder.git
revision: 8fe468957f047ad7039f07679e5952a534d07b6d revision: 8fe468957f047ad7039f07679e5952a534d07b6d
@ -187,8 +175,6 @@ GEM
faraday-net_http_persistent (1.2.0) faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0) faraday-patron (1.0.0)
faraday-rack (1.0.0) faraday-rack (1.0.0)
faraday_middleware (1.2.0)
faraday (~> 1.0)
ffi (1.15.4) ffi (1.15.4)
ffi-compiler (1.0.1) ffi-compiler (1.0.1)
ffi (>= 1.0.0) ffi (>= 1.0.0)
@ -339,9 +325,6 @@ GEM
omniauth-rails_csrf_protection (1.0.0) omniauth-rails_csrf_protection (1.0.0)
actionpack (>= 4.2) actionpack (>= 4.2)
omniauth (~> 2.0) omniauth (~> 2.0)
omniauth-tumblr (1.2)
multi_json
omniauth-oauth (~> 1.0)
omniauth-twitter (1.4.0) omniauth-twitter (1.4.0)
omniauth-oauth (~> 1.1) omniauth-oauth (~> 1.1)
rack rack
@ -625,7 +608,6 @@ DEPENDENCIES
mini_magick mini_magick
omniauth omniauth
omniauth-rails_csrf_protection (~> 1.0) omniauth-rails_csrf_protection (~> 1.0)
omniauth-tumblr
omniauth-twitter omniauth-twitter
pg pg
pghero pghero
@ -657,7 +639,6 @@ DEPENDENCIES
simplecov-json simplecov-json
spring (~> 2.0) spring (~> 2.0)
timecop timecop
tumblr_client!
turbolinks (~> 2.5.3) turbolinks (~> 2.5.3)
twitter twitter
twitter-text twitter-text

View File

@ -1,34 +0,0 @@
class Services::Tumblr < Service
include Rails.application.routes.url_helpers
include SocialHelper::TumblrMethods
def provider
"tumblr"
end
def post(answer)
Rails.logger.debug "posting to Tumblr {'answer' => #{answer.id}, 'user' => #{self.user_id}}"
create_post answer
end
private
def client
@client ||= Tumblr::Client.new(
consumer_key: APP_CONFIG['sharing']['tumblr']['consumer_key'],
consumer_secret: APP_CONFIG['sharing']['tumblr']['consumer_secret'],
oauth_token: self.access_token,
oauth_token_secret: self.access_secret
)
end
def create_post(answer)
client.text(
self.uid,
title: tumblr_title(answer),
body: tumblr_body(answer),
format: 'markdown',
tweet: 'off'
)
end
end

View File

@ -1,7 +1,7 @@
Rails.application.config.middleware.use OmniAuth::Builder do Rails.application.config.middleware.use OmniAuth::Builder do
%w(facebook twitter tumblr).each do |service| APP_CONFIG.fetch('sharing').each do |service, opts|
if APP_CONFIG['sharing'][service]['enabled'] if opts['enabled']
provider service.to_sym, APP_CONFIG['sharing'][service]['consumer_key'], APP_CONFIG['sharing'][service]['consumer_secret'] provider service.to_sym, opts['consumer_key'], opts['consumer_secret']
end end
end end
end end

View File

@ -41,7 +41,6 @@ RailsAdmin.config do |config|
Report Report
Service Service
Services::Twitter Services::Twitter
Services::Tumblr
Smile Smile
Theme Theme
User User

View File

@ -27,13 +27,6 @@ sharing:
# Get the tokens from https://apps.twitter.com # Get the tokens from https://apps.twitter.com
consumer_key: '' consumer_key: ''
consumer_secret: '' consumer_secret: ''
facebook:
enabled: false
tumblr:
enabled: true
# Get the tokens from https://www.tumblr.com/oauth/apps
consumer_key: ''
consumer_secret: ''
# Redis # Redis
redis_url: "redis://localhost:6379" redis_url: "redis://localhost:6379"

View File

@ -0,0 +1,11 @@
# frozen_string_literal: true
class RemoveTumblrConnections < ActiveRecord::Migration[5.2]
def up
execute %(DELETE FROM services WHERE type = 'Services::Tumblr';)
end
def down
# won't have tumblr tokens anymore on rollback, but that's ok
end
end

View File

@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2021_12_28_135426) do ActiveRecord::Schema.define(version: 2022_01_05_171216) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"

View File

@ -12,11 +12,10 @@ Like many websites, we use cookies and similar technologies to collect addition
#### Non-personal Identification Information #### Non-personal Identification Information
When using our Services, we may receive technical information ("Non-personal Identification") information such as your IP address, browser type, operating system, the referring web page, pages visited, location, search terms, and cookie information. We receive this data when you interact with our Services, for example, when you visit our websites or sign into our Services. When using our Services, we may receive technical information ("Non-personal Identification") information such as your IP address, browser type, operating system, the referring web page, pages visited, location, search terms, and cookie information. We receive this data when you interact with our Services, for example, when you visit our websites or sign into our Services.
#### Third-Party Services #### Third-Party Services
Retrospring uses a variety of third-party services to help provide our Services or to share your answers to, if connected, other Services like Twitter or Tumblr. These third-party service providers may collect information sent by your browser as part of a web page request, such as cookies or your IP address. Please refer to their Privacy Policies in regard to how they handle your data. Retrospring uses a variety of third-party services to help provide our Services or to share your answers to, if connected, other Services like Twitter. These third-party service providers may collect information sent by your browser as part of a web page request, such as cookies or your IP address. Please refer to their Privacy Policies in regard to how they handle your data.
* [_Cloudflare - Privacy Policy_](https://www.cloudflare.com/en-gb/privacypolicy/) * [_Cloudflare - Privacy Policy_](https://www.cloudflare.com/en-gb/privacypolicy/)
* [_Twitter - Privacy Policy_](https://twitter.com/en/privacy) * [_Twitter - Privacy Policy_](https://twitter.com/en/privacy)
* [_Tumblr - Privacy Policy_](https://www.tumblr.com/privacy/en)
## Information Sharing ## Information Sharing
Retrospring will keep any collected data (see "Information Collection and Use" above) encrypted on our servers. Any information shared with other Services is controlled by the user itself, as we only supply sharing to these. If a user isn't satisfied with Terms from another Service they shouldn't connect their accounts or remove access over the Sharing page on the profile settings page. Retrospring will keep any collected data (see "Information Collection and Use" above) encrypted on our servers. Any information shared with other Services is controlled by the user itself, as we only supply sharing to these. If a user isn't satisfied with Terms from another Service they shouldn't connect their accounts or remove access over the Sharing page on the profile settings page.

View File

@ -14,11 +14,7 @@ describe SocialHelper::TumblrMethods, :type => :helper do
'anonymous_name' => 'Anonymous', 'anonymous_name' => 'Anonymous',
'https' => true, 'https' => true,
'items_per_page' => 5, 'items_per_page' => 5,
'sharing' => { 'sharing' => {}
'tumblr' => {
'consumer_key' => 'AAA',
}
}
}) })
end end

View File

@ -1,48 +0,0 @@
# frozen_string_literal: true
require 'rails_helper'
describe Services::Tumblr do
describe "#post" do
let(:user) { FactoryBot.create(:user) }
let(:service) { Services::Tumblr.create(user: user) }
let(:answer) { FactoryBot.create(:answer, user: user,
content: 'a' * 255,
question_content: 'q' * 255) }
let(:tumblr_client) { instance_double(Tumblr::Client) }
before do
allow(Tumblr::Client).to receive(:new).and_return(tumblr_client)
allow(tumblr_client).to receive(:text)
stub_const("APP_CONFIG", {
'hostname' => 'example.com',
'anonymous_name' => 'Anonymous',
'https' => true,
'items_per_page' => 5,
'sharing' => {
'tumblr' => {
'consumer_key' => 'AAA',
}
}
})
end
it "posts a text-post" do
answer.question.content = 'Why are raccoons so good?'
answer.question.author_is_anonymous = true
answer.question.save!
answer.content = 'Because they are good cunes.'
answer.save!
service.post(answer)
expect(tumblr_client).to have_received(:text).with(
service.uid,
title: 'Anonymous asked: Why are raccoons so good?',
body: "Because they are good cunes.\n\n[Smile or comment on the answer here](https://example.com/#{user.screen_name}/a/#{answer.id})",
format: 'markdown',
tweet: 'off'
)
end
end
end