Skip to content

Commit

Permalink
Remove facebook integration
Browse files Browse the repository at this point in the history
Facebook removed the API and facebook integration is broken now, so lets
remove it.

closes #7874
  • Loading branch information
SuperTux88 authored and denschub committed Oct 8, 2018
1 parent d0c6495 commit fc6893d
Show file tree
Hide file tree
Showing 27 changed files with 72 additions and 306 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Expand Up @@ -3,6 +3,7 @@
## Refactor
* Remove mention of deprecated `statistic.json` [#7867](https://github.com/diaspora/diaspora/pull/7867)
* Add quotes in `database.yml.example` to fields that may contain special characters [#7875](https://github.com/diaspora/diaspora/pull/7875)
* Removed broken, and thus deprecated, Facebook integration [#7874](https://github.com/diaspora/diaspora/pull/7874)

## Bug fixes
* Add compatibility with macOS to `script/configure_bundler` [#7830](https://github.com/diaspora/diaspora/pull/7830)
Expand Down
1 change: 0 additions & 1 deletion Gemfile
Expand Up @@ -157,7 +157,6 @@ gem "secure_headers", "5.0.5"
# Services

gem "omniauth", "1.8.1"
gem "omniauth-facebook", "4.0.0"
gem "omniauth-tumblr", "1.2"
gem "omniauth-twitter", "1.4.0"
gem "omniauth-wordpress", "0.2.2"
Expand Down
3 changes: 0 additions & 3 deletions Gemfile.lock
Expand Up @@ -408,8 +408,6 @@ GEM
omniauth (1.8.1)
hashie (>= 3.4.6, < 3.6.0)
rack (>= 1.6.2, < 3)
omniauth-facebook (4.0.0)
omniauth-oauth2 (~> 1.2)
omniauth-oauth (1.1.0)
oauth
omniauth (~> 1.0)
Expand Down Expand Up @@ -820,7 +818,6 @@ DEPENDENCIES
mysql2 (= 0.5.0)
nokogiri (= 1.8.2)
omniauth (= 1.8.1)
omniauth-facebook (= 4.0.0)
omniauth-tumblr (= 1.2)
omniauth-twitter (= 1.4.0)
omniauth-wordpress (= 0.2.2)
Expand Down
Binary file removed app/assets/images/social-media-logos/facebook-16x16.png
Binary file not shown.
Binary file removed app/assets/images/social-media-logos/facebook-24x24.png
Binary file not shown.
Binary file not shown.
1 change: 0 additions & 1 deletion app/assets/stylesheets/navbar_left.scss
Expand Up @@ -199,7 +199,6 @@
}
text-align: center;

.social-media-logos-facebook-24x24,
.social-media-logos-twitter-24x24,
.social-media-logos-tumblr-24x24,
.social-media-logos-wordpress-24x24 {
Expand Down
58 changes: 0 additions & 58 deletions app/models/services/facebook.rb

This file was deleted.

4 changes: 0 additions & 4 deletions app/views/users/getting_started.haml
Expand Up @@ -14,10 +14,6 @@
%h3
= t(".who_are_you")

- if AppConfig.configured_services.include? :facebook
%p
!= t('.connect_to_facebook', link: link_to(t('.connect_to_facebook_link'), "auth/facebook?callback_url=#{getting_started_url}"))

= form_tag profile_path, method: :put, remote: true, id: 'edit_profile' do
%fieldset
.form-group
Expand Down
4 changes: 0 additions & 4 deletions app/views/users/getting_started.mobile.haml
Expand Up @@ -19,10 +19,6 @@
%h2
= t(".who_are_you")

- if AppConfig.configured_services.include? :facebook
%p
!= t('.connect_to_facebook', link: link_to(t('.connect_to_facebook_link'), "auth/facebook?callback_url=#{getting_started_url}"))

= form_tag profile_path, method: :put, remote: true, id: "edit_profile" do
%fieldset
.form-group
Expand Down
11 changes: 2 additions & 9 deletions config/defaults.yml
Expand Up @@ -153,12 +153,6 @@ defaults:
report_only: true
report_uri:
services:
facebook:
enable: false
app_id:
secret:
open_graph_namespace: 'joindiaspora'
authorized: false
twitter:
enable: false
key:
Expand Down Expand Up @@ -234,11 +228,10 @@ test:
invitations:
open: true
services:
facebook:
twitter:
enable: true
app_id: 'fake'
key: 'fake'
secret: 'sdoigjosdfijg'
authorized: true
mail:
enable: true
integration1:
Expand Down
16 changes: 1 addition & 15 deletions config/diaspora.yml.example
Expand Up @@ -21,7 +21,7 @@
## - Specify lists/arrays as comma-separated values
##
## - For example, on Heroku:
## heroku config:set SERVICES_FACEBOOK_APP_ID=yourappid SERVICES_FACEBOOK_SECRET=yourappsecret
## heroku config:set SERVICES_TWITTER_KEY=yourkey SERVICES_TWITTER_SECRET=yoursecret

configuration: ## Section

Expand Down Expand Up @@ -583,20 +583,6 @@ configuration: ## Section
## Posting from Diaspora to external services (all are disabled by default).
services: ## Section

## OAuth credentials for Facebook
facebook: ## Section

#enable: true
#app_id: 'abcdef'
#secret: 'change_me'

## This setting is required to define whether the Facebook app has permissions to post
## false == No permissions (default)
## true == Permissions for all users to post. App MUST have 'publish_actions' approved by Facebook!
## "username" == Set to local username to allow a single user to cross-post. The person who has created
## the Facebook app will always be able to cross-post, even without 'publish_actions'.
#authorized: false

## OAuth credentials for Twitter
twitter: ## Section

Expand Down
11 changes: 0 additions & 11 deletions config/initializers/omniauth.rb
Expand Up @@ -13,17 +13,6 @@
provider :tumblr, AppConfig.services.tumblr.key, AppConfig.services.tumblr.secret
end

if AppConfig.services.facebook.enable?
provider :facebook, AppConfig.services.facebook.app_id, AppConfig.services.facebook.secret, {
scope: "public_profile,publish_actions",
client_options: {
ssl: {
ca_file: AppConfig.environment.certificate_authorities
}
}
}
end

if AppConfig.services.wordpress.enable?
provider :wordpress, AppConfig.services.wordpress.client_id, AppConfig.services.wordpress.secret
end
Expand Down
3 changes: 0 additions & 3 deletions config/locales/diaspora/en.yml
Expand Up @@ -1043,7 +1043,6 @@ en:
comment_email_subject: "%{resharer}’s reshare of %{author}’s post"
services:
provider:
facebook: "Facebook"
tumblr: "Tumblr"
twitter: "Twitter"
wordpress: "WordPress"
Expand Down Expand Up @@ -1264,8 +1263,6 @@ en:
community_welcome: "diaspora*’s community is happy to have you aboard!"
awesome_take_me_to_diaspora: "Awesome! Take me to diaspora*"
who_are_you: "Who are you?"
connect_to_facebook: "We can speed things up a bit by %{link} to diaspora*. This will pull your name and photo, and enable cross-posting."
connect_to_facebook_link: "Hooking up your Facebook account"
what_are_you_in_to: "What are you into?"
hashtag_explanation: "Hashtags allow you to talk about and follow your interests. They’re also a great way to find new people on diaspora*."
hashtag_suggestions: "Try following tags like #art, #movies, #gif, etc."
Expand Down
14 changes: 14 additions & 0 deletions db/migrate/20181004003638_remove_facebook.rb
@@ -0,0 +1,14 @@
# frozen_string_literal: true

class RemoveFacebook < ActiveRecord::Migration[5.1]
class Service < ApplicationRecord
end

def change
remove_column :posts, :facebook_id, :string

reversible do |change|
change.up { Service.where(type: "Services::Facebook").delete_all }
end
end
end
2 changes: 1 addition & 1 deletion lib/configuration_methods.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module Configuration
KNOWN_SERVICES = [:twitter, :tumblr, :facebook, :wordpress].freeze
KNOWN_SERVICES = %i[twitter tumblr wordpress].freeze

module Methods
def pod_uri
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/jasmine_fixtures/aspects_spec.rb
Expand Up @@ -29,8 +29,8 @@
end

it 'generates a jasmine fixture with services', :fixture => true do
alice.services << Services::Facebook.create(:user_id => alice.id)
alice.services << Services::Twitter.create(:user_id => alice.id)
alice.services << Services::Twitter.create(user_id: alice.id)
alice.services << Services::Tumblr.create(user_id: alice.id)
get :aspects, params: {prefill: "reshare things"}
save_fixture(html_for("body"), "aspects_index_services")
end
Expand Down
44 changes: 12 additions & 32 deletions spec/controllers/services_controller_spec.rb
Expand Up @@ -5,12 +5,14 @@
# the COPYRIGHT file.

describe ServicesController, :type => :controller do
let(:omniauth_auth) do
{ 'provider' => 'facebook',
'uid' => '2',
'info' => { 'nickname' => 'grimmin', 'image' => 'http://graph.facebook.com/2/picture' },
'credentials' => { 'token' => 'tokin', 'secret' =>"not_so_much" }}
end
let(:omniauth_auth) {
{
"provider" => "tumblr",
"uid" => "2",
"info" => {"nickname" => "grimmin"},
"credentials" => {"token" => "token", "secret" => "not_so_much"}
}
}
let(:user) { alice }

before do
Expand All @@ -37,22 +39,13 @@

it 'creates a new service and associates it with the current user' do
expect {
post :create, params: {provider: "facebook"}
post :create, params: {provider: "twitter"}
}.to change(user.services, :count).by(1)
end

it 'saves the provider' do
post :create, params: {provider: "facebook"}
expect(user.reload.services.first.class.name).to eq("Services::Facebook")
end

context "when the user hasn't got a profile photo on Diaspora" do
before { user.person.profile.update_attribute :image_url, nil }

it "imports the profile photo from the service" do
expect(Workers::FetchProfilePhoto).to receive(:perform_async)
post :create, params: {provider: "facebook"}
end
post :create, params: {provider: "twitter"}
expect(user.reload.services.first.class.name).to eq("Services::Tumblr")
end

context 'when service exists with the same uid' do
Expand Down Expand Up @@ -97,23 +90,10 @@
end
end

context 'Facebook' do
before do
facebook_auth_without_twitter_extras = { 'provider' => 'facebook', 'extras' => { 'someotherkey' => 'lorem'}}
request.env['omniauth.auth'] = omniauth_auth.merge!( facebook_auth_without_twitter_extras )
end

it "doesn't break when twitter-specific extras aren't available in omniauth hash" do
expect {
post :create, params: {provider: "facebook"}
}.to change(user.services, :count).by(1)
end
end

context 'when fetching a photo' do
before do
omniauth_auth
omniauth_auth["info"].merge!({"image" => "https://service.com/fallback_lowres.jpg"})
omniauth_auth["info"]["image"] = "https://service.com/fallback_lowres.jpg"

request.env['omniauth.auth'] = omniauth_auth
end
Expand Down
13 changes: 5 additions & 8 deletions spec/controllers/status_messages_controller_spec.rb
Expand Up @@ -141,20 +141,17 @@
end

it "dispatches the post to the specified services" do
s1 = Services::Facebook.new
alice.services << s1
alice.services << Services::Twitter.new
status_message_hash[:services] = ['facebook']
status_message_hash[:services] = ["twitter"]
service_types = Service.titles(status_message_hash[:services])
expect(alice).to receive(:dispatch_post).with(anything(), hash_including(:service_types => service_types))
expect(alice).to receive(:dispatch_post).with(anything, hash_including(service_types: service_types))
post :create, params: status_message_hash
end

it "works if services is a string" do
s1 = Services::Facebook.new
alice.services << s1
status_message_hash[:services] = "facebook"
expect(alice).to receive(:dispatch_post).with(anything(), hash_including(:service_types => ["Services::Facebook"]))
alice.services << Services::Twitter.new
status_message_hash[:services] = "twitter"
expect(alice).to receive(:dispatch_post).with(anything, hash_including(service_types: ["Services::Twitter"]))
post :create, params: status_message_hash
end

Expand Down
4 changes: 2 additions & 2 deletions spec/javascripts/app/models/user_spec.js
Expand Up @@ -16,8 +16,8 @@ describe("app.models.User", function(){

describe("isServiceConnected", function(){
it("checks to see if the sent provider name is a configured service", function(){
this.user.set({configured_services : ["facebook"]});
expect(this.user.isServiceConfigured("facebook")).toBeTruthy();
this.user.set({configured_services: ["twitter"]}); // eslint-disable-line camelcase
expect(this.user.isServiceConfigured("twitter")).toBeTruthy();
expect(this.user.isServiceConfigured("tumblr")).toBeFalsy();
});
});
Expand Down
9 changes: 0 additions & 9 deletions spec/lib/configuration_methods_spec.rb
Expand Up @@ -94,22 +94,17 @@
allow(disabled).to receive(:enable?).and_return(false)
allow(services).to receive(:twitter).and_return(enabled)
allow(services).to receive(:tumblr).and_return(enabled)
allow(services).to receive(:facebook).and_return(disabled)
allow(services).to receive(:wordpress).and_return(disabled)
allow(@settings).to receive(:services).and_return(services)
expect(@settings.configured_services).to include :twitter
expect(@settings.configured_services).to include :tumblr
expect(@settings.configured_services).not_to include :facebook
expect(@settings.configured_services).not_to include :wordpress
end
end

describe "#show_service" do
before do
AppConfig.services.twitter.authorized = true
AppConfig.services.twitter.enable = true
AppConfig.services.facebook.authorized = true
AppConfig.services.facebook.enable = true
AppConfig.services.wordpress.authorized = false
AppConfig.services.wordpress.enable = true
AppConfig.services.tumblr.authorized = "alice"
Expand All @@ -120,10 +115,6 @@
expect(AppConfig.show_service?("twitter", bob)).to be_truthy
end

it "shows service with authorized key true" do
expect(AppConfig.show_service?("facebook", bob)).to be_truthy
end

it "doesn't show service with authorized key false" do
expect(AppConfig.show_service?("wordpress", bob)).to be_falsey
end
Expand Down

0 comments on commit fc6893d

Please sign in to comment.