Twitter service removes status from twitter when post is revoked
This commit is contained in:
parent
a8655e2e8d
commit
ba0e2509c9
4 changed files with 30 additions and 8 deletions
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
## Features
|
||||
|
||||
* Deleting a post that was shared to Twitter now deletes it from Twitter too [#4135](https://github.com/diaspora/diaspora/pull/4135)
|
||||
|
||||
# 0.1.0.0
|
||||
|
||||
|
|
@ -212,7 +213,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/)
|
||||
|
|
|
|||
|
|
@ -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,15 @@ class Services::Twitter < Service
|
|||
client.user(nickname).profile_image_url_https("original")
|
||||
end
|
||||
|
||||
def delete_post(service_post_id)
|
||||
Rails.logger.debug("event=delete_from_service type=twitter sender_id=#{self.user_id}")
|
||||
delete_from_twitter(service_post_id)
|
||||
end
|
||||
|
||||
def delete_from_twitter(service_post_id)
|
||||
client.status_destroy(service_post_id)
|
||||
end
|
||||
|
||||
private
|
||||
def client
|
||||
@client ||= Twitter::Client.new(
|
||||
|
|
|
|||
|
|
@ -151,9 +151,12 @@ class Postzord::Dispatcher
|
|||
end
|
||||
end
|
||||
if @object.instance_of?(SignedRetraction)
|
||||
services.select { |service| service.respond_to? :delete_post }.each do |service|
|
||||
services.select { |service| service.provider == "facebook" }.each do |service|
|
||||
Workers::DeletePostFromService.perform_async(service.id, @object.target.facebook_id)
|
||||
end
|
||||
services.select { |service| service.provider == "twitter" }.each do |service|
|
||||
Workers::DeletePostFromService.perform_async(service.id, @object.target.tweet_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -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