* @param int $notice_id
* @return boolean success
*/
- static function insertNotice($user_id, $notice_id)
+ static function insertNotice(Notice $notice, $user_id)
{
// Going straight to the DB rather than trusting our caching
// during an update. Note: not using DB_DataObject::staticGet,
}
$ids = $inbox->unpack();
- if (in_array(intval($notice_id), $ids)) {
+ if (in_array(intval($notice->id), $ids)) {
// Already in there, we probably re-ran some inbox adds
// due to an error. Skip the dupe silently.
return true;
'SET notice_ids = concat(cast(0x%08x as binary(4)), '.
'SUBSTR(notice_ids, 1, %d)) '.
'WHERE user_id = %d',
- $notice_id,
+ $notice->id,
4 * (self::MAX_NOTICES - 1),
$user_id));
return $result;
}
- static function bulkInsert($notice_id, $user_ids)
+ static function bulkInsert(Notice $notice, array $user_ids)
{
foreach ($user_ids as $user_id)
{
- self::insertNotice($user_id, $notice_id);
+ self::insertNotice($notice, $user_id);
}
}
// Bulk insert
- Inbox::bulkInsert($this->id, $ids);
+ Inbox::bulkInsert($this, $ids);
return;
}
$user = User::getKV('id', $this->profile_id);
if ($user instanceof User) {
- Inbox::insertNotice($user->id, $this->id);
+ Inbox::insertNotice($this, $user->id);
}
if (common_config('queue', 'inboxes')) {
$importer = new TwitterImport();
$notice = $importer->importStatus($status);
- if ($notice) {
+ if ($notice instanceof Notice) {
$flink = Foreign_link::getByForeignID($receiver, TWITTER_SERVICE);
- if ($flink) {
+ if ($flink instanceof Foreign_link) {
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);
+ Inbox::insertNotice($notice, $flink->user_id);
}else {
common_log(LOG_DEBUG, "TweetInQueueHandler - No flink found for foreign user ".$receiver);
}
$importer = new TwitterImport();
printf("\timporting...");
$notice = $importer->importStatus($data);
- if ($notice) {
+ if ($notice instanceof Notice) {
global $myuser;
- Inbox::insertNotice($myuser->id, $notice->id);
+ Inbox::insertNotice($notice, $myuser->id);
printf(" %s\n", $notice->id);
} else {
printf(" FAIL\n");