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;
case 'TwitterOAuthClient':
case 'TwitterQueueHandler':
case 'TweetInQueueHandler':
case 'TwitterImport':
case 'JsonStreamReader':
case 'TwitterStreamReader':

View File

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