Make TwitterBridge plugin use Queueing system

This commit is contained in:
Jean Baptiste Favre 2013-02-18 23:22:08 +01:00
parent dd97468c72
commit a10a34a3cf
3 changed files with 17 additions and 20 deletions

View File

@ -204,6 +204,7 @@ class TwitterBridgePlugin extends Plugin
return false; return false;
case 'TwitterOAuthClient': case 'TwitterOAuthClient':
case 'TwitterQueueHandler': case 'TwitterQueueHandler':
case 'TweetInQueueHandler':
case 'TwitterImport': case 'TwitterImport':
case 'JsonStreamReader': case 'JsonStreamReader':
case 'TwitterStreamReader': case 'TwitterStreamReader':

View File

@ -196,26 +196,18 @@ class TwitterStatusFetcher extends ParallelizingDaemon
' - Retrieved ' . sizeof($timeline) . ' statuses from ' . $timelineUri . ' timeline' . ' - Retrieved ' . sizeof($timeline) . ' statuses from ' . $timelineUri . ' timeline' .
' - for user ' . $flink->user_id); ' - for user ' . $flink->user_id);
/* @fixme make TwitterBridge use queueing system if (!empty($timeline)) {
* to speed up timeline processing $qm = QueueManager::get();
* as well as giving oportunity to use
* usefull feature such as realtime
* brodcast to clients
*/
$importer = new TwitterImport();
// Reverse to preserve order // Reverse to preserve order
foreach (array_reverse($timeline) as $status) { foreach (array_reverse($timeline) as $status) {
$notice = $importer->importStatus($status); $data = array(
'status' => $status,
if (!empty($notice)) { 'for_user' => $flink->foreign_id,
Inbox::insertNotice($flink->user_id, $notice->id); );
$qm->enqueue($data, 'tweetin');
} }
}
/* @fixme ends here */
if (!empty($timeline)) {
$lastId = twitter_id($timeline[0]); $lastId = twitter_id($timeline[0]);
Twitter_synch_status::setLastId($flink->foreign_id, $timelineUri, $lastId); Twitter_synch_status::setLastId($flink->foreign_id, $timelineUri, $lastId);
common_debug("Set lastId value '$lastId' for foreign id '{$flink->foreign_id}' and timeline '" . common_debug("Set lastId value '$lastId' for foreign id '{$flink->foreign_id}' and timeline '" .

View File

@ -51,10 +51,14 @@ class TweetInQueueHandler extends QueueHandler
$importer = new TwitterImport(); $importer = new TwitterImport();
$notice = $importer->importStatus($status); $notice = $importer->importStatus($status);
if ($notice) { if ($notice) {
$flink = Foreign_link::getByForeignID(TWITTER_SERVICE, $receiver); $flink = Foreign_link::getByForeignID($receiver, TWITTER_SERVICE);
if ($flink) { if ($flink) {
common_log(LOG_DEBUG, "TweetInQueueHandler - Got flink so add notice ".
$notice->id." to inbox ".$flink->user_id);
// @fixme this should go through more regular channels? // @fixme this should go through more regular channels?
Inbox::insertNotice($flink->user_id, $notice->id); Inbox::insertNotice($flink->user_id, $notice->id);
}else {
common_log(LOG_DEBUG, "TweetInQueueHandler - No flink found for foreign user ".$receiver);
} }
} }