/** * If a notice gets deleted, remove the Notice_to_status mapping and * delete the status on Twitter. * * @param User $user The user doing the deleting * @param Notice $notice The notice getting deleted * * @return boolean hook value */ function onStartDeleteOwnNotice(User $user, Notice $notice) { $n2s = Notice_to_status::getKV('notice_id', $notice->id); if (!empty($n2s)) { $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; } try { $token = TwitterOAuthClient::unpackToken($flink->credentials); $client = new TwitterOAuthClient($token->key, $token->secret); $client->statusesDestroy($n2s->status_id); } catch (Exception $e) { common_log(LOG_ERR, "Error attempting to delete bridged notice from Twitter: " . $e->getMessage()); } $n2s->delete(); } return true; }
/** * If a notice gets deleted, remove the Notice_to_status mapping and * delete the status on Twitter. * * @param User $user The user doing the deleting * @param Notice $notice The notice getting deleted * * @return boolean hook value */ function onStartDeleteOwnNotice(User $user, Notice $notice) { $n2s = Notice_to_status::staticGet('notice_id', $notice->id); if (!empty($n2s)) { $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(); } return true; }