forked from GNUsocial/gnu-social
Inbox class a bit more consistent in argument order and type
This commit is contained in:
parent
3eac5e6026
commit
729c6eef36
@ -66,7 +66,7 @@ class Inbox extends Managed_DataObject {
|
|||||||
* @param int $notice_id
|
* @param int $notice_id
|
||||||
* @return boolean success
|
* @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
|
// Going straight to the DB rather than trusting our caching
|
||||||
// during an update. Note: not using DB_DataObject::staticGet,
|
// during an update. Note: not using DB_DataObject::staticGet,
|
||||||
@ -80,7 +80,7 @@ class Inbox extends Managed_DataObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$ids = $inbox->unpack();
|
$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
|
// Already in there, we probably re-ran some inbox adds
|
||||||
// due to an error. Skip the dupe silently.
|
// due to an error. Skip the dupe silently.
|
||||||
return true;
|
return true;
|
||||||
@ -90,7 +90,7 @@ class Inbox extends Managed_DataObject {
|
|||||||
'SET notice_ids = concat(cast(0x%08x as binary(4)), '.
|
'SET notice_ids = concat(cast(0x%08x as binary(4)), '.
|
||||||
'SUBSTR(notice_ids, 1, %d)) '.
|
'SUBSTR(notice_ids, 1, %d)) '.
|
||||||
'WHERE user_id = %d',
|
'WHERE user_id = %d',
|
||||||
$notice_id,
|
$notice->id,
|
||||||
4 * (self::MAX_NOTICES - 1),
|
4 * (self::MAX_NOTICES - 1),
|
||||||
$user_id));
|
$user_id));
|
||||||
|
|
||||||
@ -101,11 +101,11 @@ class Inbox extends Managed_DataObject {
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function bulkInsert($notice_id, $user_ids)
|
static function bulkInsert(Notice $notice, array $user_ids)
|
||||||
{
|
{
|
||||||
foreach ($user_ids as $user_id)
|
foreach ($user_ids as $user_id)
|
||||||
{
|
{
|
||||||
self::insertNotice($user_id, $notice_id);
|
self::insertNotice($notice, $user_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1086,7 +1086,7 @@ class Notice extends Managed_DataObject
|
|||||||
|
|
||||||
// Bulk insert
|
// Bulk insert
|
||||||
|
|
||||||
Inbox::bulkInsert($this->id, $ids);
|
Inbox::bulkInsert($this, $ids);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2058,7 +2058,7 @@ class Notice extends Managed_DataObject
|
|||||||
|
|
||||||
$user = User::getKV('id', $this->profile_id);
|
$user = User::getKV('id', $this->profile_id);
|
||||||
if ($user instanceof User) {
|
if ($user instanceof User) {
|
||||||
Inbox::insertNotice($user->id, $this->id);
|
Inbox::insertNotice($this, $user->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (common_config('queue', 'inboxes')) {
|
if (common_config('queue', 'inboxes')) {
|
||||||
|
@ -50,13 +50,13 @@ class TweetInQueueHandler extends QueueHandler
|
|||||||
|
|
||||||
$importer = new TwitterImport();
|
$importer = new TwitterImport();
|
||||||
$notice = $importer->importStatus($status);
|
$notice = $importer->importStatus($status);
|
||||||
if ($notice) {
|
if ($notice instanceof Notice) {
|
||||||
$flink = Foreign_link::getByForeignID($receiver, TWITTER_SERVICE);
|
$flink = Foreign_link::getByForeignID($receiver, TWITTER_SERVICE);
|
||||||
if ($flink) {
|
if ($flink instanceof Foreign_link) {
|
||||||
common_log(LOG_DEBUG, "TweetInQueueHandler - Got flink so add notice ".
|
common_log(LOG_DEBUG, "TweetInQueueHandler - Got flink so add notice ".
|
||||||
$notice->id." to inbox ".$flink->user_id);
|
$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($notice, $flink->user_id);
|
||||||
}else {
|
}else {
|
||||||
common_log(LOG_DEBUG, "TweetInQueueHandler - No flink found for foreign user ".$receiver);
|
common_log(LOG_DEBUG, "TweetInQueueHandler - No flink found for foreign user ".$receiver);
|
||||||
}
|
}
|
||||||
|
@ -170,9 +170,9 @@ $stream->hookEvent('status', function($data, $context) {
|
|||||||
$importer = new TwitterImport();
|
$importer = new TwitterImport();
|
||||||
printf("\timporting...");
|
printf("\timporting...");
|
||||||
$notice = $importer->importStatus($data);
|
$notice = $importer->importStatus($data);
|
||||||
if ($notice) {
|
if ($notice instanceof Notice) {
|
||||||
global $myuser;
|
global $myuser;
|
||||||
Inbox::insertNotice($myuser->id, $notice->id);
|
Inbox::insertNotice($notice, $myuser->id);
|
||||||
printf(" %s\n", $notice->id);
|
printf(" %s\n", $notice->id);
|
||||||
} else {
|
} else {
|
||||||
printf(" FAIL\n");
|
printf(" FAIL\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user