delete Twitter notice if it was posted from here
This commit is contained in:
parent
ba8a24073f
commit
b059a19e0f
|
@ -423,7 +423,33 @@ class TwitterBridgePlugin extends Plugin
|
||||||
function onNoticeDeleteRelated($notice)
|
function onNoticeDeleteRelated($notice)
|
||||||
{
|
{
|
||||||
$n2s = Notice_to_status::staticGet('notice_id', $notice->id);
|
$n2s = Notice_to_status::staticGet('notice_id', $notice->id);
|
||||||
|
|
||||||
if (!empty($n2s)) {
|
if (!empty($n2s)) {
|
||||||
|
|
||||||
|
$user = common_current_user();
|
||||||
|
|
||||||
|
if (empty($user) || $user->id != $notice->profile_id) {
|
||||||
|
$this->log(LOG_INFO, "Skipping deleting notice for {$notice->id} since it doesn't seem to be by the author.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$flink = Foreign_link::getByUserID($notice->profile_id,
|
||||||
|
TWITTER_SERVICE); // twitter service
|
||||||
|
|
||||||
|
if (empty($flink)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!TwitterOAuthClient::isPackedToken($flink->credentials)) {
|
||||||
|
$this->log(LOG_INFO, "Skipping deleting notice for {$notice->id} since link is not OAuth.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$token = TwitterOAuthClient::unpackToken($flink->credentials);
|
||||||
|
$client = new TwitterOAuthClient($token->key, $token->secret);
|
||||||
|
|
||||||
|
$client->statusesDestroy($n2s->status_id);
|
||||||
|
|
||||||
$n2s->delete();
|
$n2s->delete();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -324,4 +324,20 @@ class TwitterOAuthClient extends OAuthClient
|
||||||
$status = json_decode($response);
|
$status = json_decode($response);
|
||||||
return $status;
|
return $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calls Twitter's /statuses/destroy API method
|
||||||
|
*
|
||||||
|
* @param int $id ID of the status to destroy
|
||||||
|
*
|
||||||
|
* @return object destroyed
|
||||||
|
*/
|
||||||
|
|
||||||
|
function statusesDestroy($id)
|
||||||
|
{
|
||||||
|
$url = "http://api.twitter.com/1/statuses/destroy/$id.json";
|
||||||
|
$response = $this->oAuthPost($url);
|
||||||
|
$status = json_decode($response);
|
||||||
|
return $status;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user