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
|
## 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
|
# 0.1.0.0
|
||||||
|
|
||||||
|
|
@ -139,7 +140,7 @@ everything is set up.
|
||||||
* Fix reshares in single post-view [#4056](https://github.com/diaspora/diaspora/issues/4056)
|
* 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)
|
* 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)
|
* 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)
|
* 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)
|
* 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)
|
* Fix default image url in profiles table. [#3795](https://github.com/diaspora/diaspora/issues/3795)
|
||||||
|
|
@ -159,7 +160,7 @@ everything is set up.
|
||||||
|
|
||||||
## Features
|
## 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)
|
* 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)
|
* 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)
|
* Show timestamp when hovering on comment time-ago string. [#4042](https://github.com/diaspora/diaspora/issues/4042)
|
||||||
|
|
@ -212,7 +213,6 @@ everything is set up.
|
||||||
* uglifier 1.3.0 -> 2.0.1
|
* uglifier 1.3.0 -> 2.0.1
|
||||||
* unicorn 4.6.0 -> 4.6.2
|
* unicorn 4.6.0 -> 4.6.2
|
||||||
|
|
||||||
|
|
||||||
# 0.0.3.4
|
# 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/)
|
* 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='')
|
def post(post, url='')
|
||||||
Rails.logger.debug("event=post_to_service type=twitter sender_id=#{self.user_id}")
|
Rails.logger.debug("event=post_to_service type=twitter sender_id=#{self.user_id}")
|
||||||
message = public_message(post, url)
|
message = public_message(post, url)
|
||||||
|
tweet = client.update(message)
|
||||||
client.update(message)
|
post.tweet_id = tweet.id
|
||||||
|
post.save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -28,6 +29,15 @@ class Services::Twitter < Service
|
||||||
client.user(nickname).profile_image_url_https("original")
|
client.user(nickname).profile_image_url_https("original")
|
||||||
end
|
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
|
private
|
||||||
def client
|
def client
|
||||||
@client ||= Twitter::Client.new(
|
@client ||= Twitter::Client.new(
|
||||||
|
|
|
||||||
|
|
@ -151,9 +151,12 @@ class Postzord::Dispatcher
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if @object.instance_of?(SignedRetraction)
|
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)
|
Workers::DeletePostFromService.perform_async(service.id, @object.target.facebook_id)
|
||||||
end
|
end
|
||||||
|
services.select { |service| service.provider == "twitter" }.each do |service|
|
||||||
|
Workers::DeletePostFromService.perform_async(service.id, @object.target.tweet_id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,21 @@ describe Services::Twitter do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#post' do
|
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
|
it 'posts a status message to twitter' do
|
||||||
Twitter::Client.any_instance.should_receive(:update).with(instance_of(String))
|
Twitter::Client.any_instance.should_receive(:update).with(instance_of(String))
|
||||||
@service.post(@post)
|
@service.post(@post)
|
||||||
end
|
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
|
it 'swallows exception raised by twitter always being down' do
|
||||||
pending
|
pending
|
||||||
Twitter::Client.any_instance.should_receive(:update).and_raise(StandardError)
|
Twitter::Client.any_instance.should_receive(:update).and_raise(StandardError)
|
||||||
|
|
@ -22,7 +32,6 @@ describe Services::Twitter do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should call public message' do
|
it 'should call public message' do
|
||||||
Twitter::Client.any_instance.stub(:update)
|
|
||||||
url = "foo"
|
url = "foo"
|
||||||
@service.should_receive(:public_message).with(@post, url)
|
@service.should_receive(:public_message).with(@post, url)
|
||||||
@service.post(@post, url)
|
@service.post(@post, url)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue