Merge branch 'feature/retract_tweets_when_post_retracted' of git://github.com/Ruxton/diaspora into develop
Conflicts: Changelog.md
This commit is contained in:
commit
d331242d94
10 changed files with 55 additions and 28 deletions
|
|
@ -13,6 +13,8 @@
|
|||
|
||||
## Features
|
||||
|
||||
* Deleting a post that was shared to Twitter now deletes it from Twitter too [#4156](https://github.com/diaspora/diaspora/pull/4156)
|
||||
|
||||
# 0.1.0.1
|
||||
|
||||
* Regression fix: 500 for deleted reshares introduced by the locator
|
||||
|
|
@ -146,7 +148,7 @@ everything is set up.
|
|||
* Fix reshares in single post-view [#4056](https://github.com/diaspora/diaspora/issues/4056)
|
||||
* Fix mobile view of deleted reshares. [#4063](https://github.com/diaspora/diaspora/issues/4063)
|
||||
* Hide comment button in the mobile view when not signed in. [#4065](https://github.com/diaspora/diaspora/issues/4065)
|
||||
* Send profile alongside notification [#3976] (https://github.com/diaspora/diaspora/issues/3976)
|
||||
* Send profile alongside notification [#3976](https://github.com/diaspora/diaspora/issues/3976)
|
||||
* Fix off-center close button image on intro popovers [#3841](https://github.com/diaspora/diaspora/pull/3841)
|
||||
* Remove unnecessary dotted CSS borders. [#2940](https://github.com/diaspora/diaspora/issues/2940)
|
||||
* Fix default image url in profiles table. [#3795](https://github.com/diaspora/diaspora/issues/3795)
|
||||
|
|
@ -166,7 +168,7 @@ everything is set up.
|
|||
|
||||
## Features
|
||||
|
||||
* Deleting a post that was shared to Facebook now deletes it from Facebook too [#3980]( https://github.com/diaspora/diaspora/pull/3980)
|
||||
* Deleting a post that was shared to Facebook now deletes it from Facebook too [#3980](https://github.com/diaspora/diaspora/pull/3980)
|
||||
* Include reshares in a users public atom feed [#1781](https://github.com/diaspora/diaspora/issues/1781)
|
||||
* Add the ability to upload photos from the mobile site. [#4004](https://github.com/diaspora/diaspora/issues/4004)
|
||||
* Show timestamp when hovering on comment time-ago string. [#4042](https://github.com/diaspora/diaspora/issues/4042)
|
||||
|
|
@ -219,7 +221,6 @@ everything is set up.
|
|||
* uglifier 1.3.0 -> 2.0.1
|
||||
* unicorn 4.6.0 -> 4.6.2
|
||||
|
||||
|
||||
# 0.0.3.4
|
||||
|
||||
* Bump Rails to 3.2.13, fixes CVE-2013-1854, CVE-2013-1855, CVE-2013-1856 and CVE-2013-1857. [Read more](http://weblog.rubyonrails.org/2013/3/18/SEC-ANN-Rails-3-2-13-3-1-12-and-2-3-18-have-been-released/)
|
||||
|
|
|
|||
|
|
@ -37,6 +37,10 @@ class Service < ActiveRecord::Base
|
|||
nil
|
||||
end
|
||||
|
||||
def delete_post(post)
|
||||
#don't do anything (should be overriden by service extensions)
|
||||
end
|
||||
|
||||
end
|
||||
require 'services/facebook'
|
||||
require 'services/twitter'
|
||||
|
|
|
|||
|
|
@ -37,9 +37,11 @@ class Services::Facebook < Service
|
|||
"https://graph.facebook.com/#{self.uid}/picture?type=large&access_token=#{URI.escape(self.access_token)}"
|
||||
end
|
||||
|
||||
def delete_post(service_post_id)
|
||||
def delete_post(post)
|
||||
if post.present? && post.facebbook_id.present?
|
||||
Rails.logger.debug("event=delete_from_service type=facebook sender_id=#{self.user_id}")
|
||||
delete_from_facebook("https://graph.facebook.com/#{service_post_id}/", {:access_token => self.access_token})
|
||||
delete_from_facebook("https://graph.facebook.com/#{post.facebook_id}/", {:access_token => self.access_token})
|
||||
end
|
||||
end
|
||||
|
||||
def delete_from_facebook(url, body)
|
||||
|
|
|
|||
|
|
@ -9,8 +9,9 @@ class Services::Twitter < Service
|
|||
def post(post, url='')
|
||||
Rails.logger.debug("event=post_to_service type=twitter sender_id=#{self.user_id}")
|
||||
message = public_message(post, url)
|
||||
|
||||
client.update(message)
|
||||
tweet = client.update(message)
|
||||
post.tweet_id = tweet.id
|
||||
post.save
|
||||
end
|
||||
|
||||
|
||||
|
|
@ -28,6 +29,17 @@ class Services::Twitter < Service
|
|||
client.user(nickname).profile_image_url_https("original")
|
||||
end
|
||||
|
||||
def delete_post(post)
|
||||
if post.present? && post.tweet_id.present?
|
||||
Rails.logger.debug("event=delete_from_service type=twitter sender_id=#{self.user_id}")
|
||||
delete_from_twitter(post.tweet_id)
|
||||
end
|
||||
end
|
||||
|
||||
def delete_from_twitter(service_post_id)
|
||||
client.status_destroy(service_post_id)
|
||||
end
|
||||
|
||||
private
|
||||
def client
|
||||
@client ||= Twitter::Client.new(
|
||||
|
|
|
|||
|
|
@ -6,9 +6,10 @@ module Workers
|
|||
class DeletePostFromService < Base
|
||||
sidekiq_options queue: :http_service
|
||||
|
||||
def perform(service_id, service_post_id)
|
||||
def perform(service_id, post_id)
|
||||
service = Service.find_by_id(service_id)
|
||||
service.delete_post(service_post_id)
|
||||
post = Post.find_by_id(post_id)
|
||||
service.delete_post(post)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
6
db/migrate/20130429073928_add_tweet_id_to_post.rb
Normal file
6
db/migrate/20130429073928_add_tweet_id_to_post.rb
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
class AddTweetIdToPost < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :posts, :tweet_id, :string
|
||||
add_index :posts, :tweet_id
|
||||
end
|
||||
end
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20130404211624) do
|
||||
ActiveRecord::Schema.define(:version => 20130429073928) do
|
||||
|
||||
create_table "account_deletions", :force => true do |t|
|
||||
t.string "diaspora_handle"
|
||||
|
|
@ -307,6 +307,7 @@ ActiveRecord::Schema.define(:version => 20130404211624) do
|
|||
t.string "frame_name"
|
||||
t.boolean "favorite", :default => false
|
||||
t.string "facebook_id"
|
||||
t.string "tweet_id"
|
||||
end
|
||||
|
||||
add_index "posts", ["author_id", "root_guid"], :name => "index_posts_on_author_id_and_root_guid", :unique => true
|
||||
|
|
@ -316,6 +317,7 @@ ActiveRecord::Schema.define(:version => 20130404211624) do
|
|||
add_index "posts", ["root_guid"], :name => "index_posts_on_root_guid"
|
||||
add_index "posts", ["status_message_guid", "pending"], :name => "index_posts_on_status_message_guid_and_pending"
|
||||
add_index "posts", ["status_message_guid"], :name => "index_posts_on_status_message_guid"
|
||||
add_index "posts", ["tweet_id"], :name => "index_posts_on_tweet_id"
|
||||
add_index "posts", ["type", "pending", "id"], :name => "index_posts_on_type_and_pending_and_id"
|
||||
|
||||
create_table "profiles", :force => true do |t|
|
||||
|
|
|
|||
|
|
@ -145,14 +145,12 @@ class Postzord::Dispatcher
|
|||
if @object.respond_to?(:public) && @object.public
|
||||
deliver_to_hub
|
||||
end
|
||||
if @object.instance_of?(StatusMessage)
|
||||
services.each do |service|
|
||||
if @object.instance_of?(StatusMessage)
|
||||
Workers::PostToService.perform_async(service.id, @object.id, url)
|
||||
end
|
||||
end
|
||||
if @object.instance_of?(SignedRetraction)
|
||||
services.select { |service| service.respond_to? :delete_post }.each do |service|
|
||||
Workers::DeletePostFromService.perform_async(service.id, @object.target.facebook_id)
|
||||
Workers::DeletePostFromService.perform_async(service.id, @object.target.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -319,14 +319,6 @@ describe Postzord::Dispatcher do
|
|||
mailman.post
|
||||
end
|
||||
|
||||
it "doesn't queue a job if we can't delete the post from the service" do
|
||||
retraction = SignedRetraction.build(alice, FactoryGirl.create(:status_message))
|
||||
service = Services::Twitter.new(access_token: "nope")
|
||||
mailman = Postzord::Dispatcher.build(alice, retraction, :url => "http://joindiaspora.com/p/123", :services => [service])
|
||||
|
||||
Workers::DeletePostFromService.should_not_receive(:perform_async).with(anything, anything)
|
||||
mailman.post
|
||||
end
|
||||
end
|
||||
|
||||
describe '#and_notify_local_users' do
|
||||
|
|
|
|||
|
|
@ -10,11 +10,21 @@ describe Services::Twitter do
|
|||
end
|
||||
|
||||
describe '#post' do
|
||||
|
||||
before do
|
||||
Twitter::Client.any_instance.stub(:update) { Twitter::Tweet.new(id: "1234") }
|
||||
end
|
||||
|
||||
it 'posts a status message to twitter' do
|
||||
Twitter::Client.any_instance.should_receive(:update).with(instance_of(String))
|
||||
@service.post(@post)
|
||||
end
|
||||
|
||||
it 'sets the tweet_id on the post' do
|
||||
@service.post(@post)
|
||||
@post.tweet_id.should match "1234"
|
||||
end
|
||||
|
||||
it 'swallows exception raised by twitter always being down' do
|
||||
pending
|
||||
Twitter::Client.any_instance.should_receive(:update).and_raise(StandardError)
|
||||
|
|
@ -22,7 +32,6 @@ describe Services::Twitter do
|
|||
end
|
||||
|
||||
it 'should call public message' do
|
||||
Twitter::Client.any_instance.stub(:update)
|
||||
url = "foo"
|
||||
@service.should_receive(:public_message).with(@post, url)
|
||||
@service.post(@post, url)
|
||||
|
|
|
|||
Loading…
Reference in a new issue