summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
Diffstat (limited to 'classes')
-rw-r--r--classes/Notice.php89
-rw-r--r--classes/User.php58
2 files changed, 46 insertions, 101 deletions
diff --git a/classes/Notice.php b/classes/Notice.php
index ba2227c0a..cd3906ca1 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -111,10 +111,9 @@ class Notice extends Memcached_DataObject
'Fave',
'Notice_tag',
'Group_inbox',
- 'Queue_item');
- if (common_config('inboxes', 'enabled')) {
- $related[] = 'Notice_inbox';
- }
+ 'Queue_item',
+ 'Notice_inbox');
+
foreach ($related as $cls) {
$inst = new $cls();
$inst->notice_id = $this->id;
@@ -883,66 +882,61 @@ class Notice extends Memcached_DataObject
function addToInboxes()
{
- $enabled = common_config('inboxes', 'enabled');
+ // XXX: loads constants
- if ($enabled === true || $enabled === 'transitional') {
+ $inbox = new Notice_inbox();
- // XXX: loads constants
+ $users = $this->getSubscribedUsers();
- $inbox = new Notice_inbox();
+ // FIXME: kind of ignoring 'transitional'...
+ // we'll probably stop supporting inboxless mode
+ // in 0.9.x
- $users = $this->getSubscribedUsers();
+ $ni = array();
- // FIXME: kind of ignoring 'transitional'...
- // we'll probably stop supporting inboxless mode
- // in 0.9.x
+ foreach ($users as $id) {
+ $ni[$id] = NOTICE_INBOX_SOURCE_SUB;
+ }
- $ni = array();
+ $groups = $this->saveGroups();
+ foreach ($groups as $group) {
+ $users = $group->getUserMembers();
foreach ($users as $id) {
- $ni[$id] = NOTICE_INBOX_SOURCE_SUB;
- }
-
- $groups = $this->saveGroups();
-
- foreach ($groups as $group) {
- $users = $group->getUserMembers();
- foreach ($users as $id) {
- if (!array_key_exists($id, $ni)) {
- $ni[$id] = NOTICE_INBOX_SOURCE_GROUP;
- }
+ if (!array_key_exists($id, $ni)) {
+ $ni[$id] = NOTICE_INBOX_SOURCE_GROUP;
}
}
+ }
- $cnt = 0;
-
- $qryhdr = 'INSERT INTO notice_inbox (user_id, notice_id, source, created) VALUES ';
- $qry = $qryhdr;
+ $cnt = 0;
- foreach ($ni as $id => $source) {
- if ($cnt > 0) {
- $qry .= ', ';
- }
- $qry .= '('.$id.', '.$this->id.', '.$source.", '".$this->created. "') ";
- $cnt++;
- if (rand() % NOTICE_INBOX_SOFT_LIMIT == 0) {
- // FIXME: Causes lag in replicated servers
- // Notice_inbox::gc($id);
- }
- if ($cnt >= MAX_BOXCARS) {
- $inbox = new Notice_inbox();
- $inbox->query($qry);
- $qry = $qryhdr;
- $cnt = 0;
- }
- }
+ $qryhdr = 'INSERT INTO notice_inbox (user_id, notice_id, source, created) VALUES ';
+ $qry = $qryhdr;
+ foreach ($ni as $id => $source) {
if ($cnt > 0) {
+ $qry .= ', ';
+ }
+ $qry .= '('.$id.', '.$this->id.', '.$source.", '".$this->created. "') ";
+ $cnt++;
+ if (rand() % NOTICE_INBOX_SOFT_LIMIT == 0) {
+ // FIXME: Causes lag in replicated servers
+ // Notice_inbox::gc($id);
+ }
+ if ($cnt >= MAX_BOXCARS) {
$inbox = new Notice_inbox();
$inbox->query($qry);
+ $qry = $qryhdr;
+ $cnt = 0;
}
}
+ if ($cnt > 0) {
+ $inbox = new Notice_inbox();
+ $inbox->query($qry);
+ }
+
return;
}
@@ -977,11 +971,6 @@ class Notice extends Memcached_DataObject
{
$groups = array();
- $enabled = common_config('inboxes', 'enabled');
- if ($enabled !== true && $enabled !== 'transitional') {
- return $groups;
- }
-
/* extract all !group */
$count = preg_match_all('/(?:^|\s)!([A-Za-z0-9]{1,64})/',
strtolower($this->content),
diff --git a/classes/User.php b/classes/User.php
index 48df0cdd7..0a70c9801 100644
--- a/classes/User.php
+++ b/classes/User.php
@@ -227,11 +227,9 @@ class User extends Memcached_DataObject
}
}
- $inboxes = common_config('inboxes', 'enabled');
+ // This flag is ignored but still set to 1
- if ($inboxes === true || $inboxes == 'transitional') {
- $user->inboxed = 1;
- }
+ $user->inboxed = 1;
$user->created = common_sql_now();
$user->uri = common_user_uri($user);
@@ -433,55 +431,16 @@ class User extends Memcached_DataObject
function noticesWithFriends($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=null)
{
- $enabled = common_config('inboxes', 'enabled');
-
- // Complicated code, depending on whether we support inboxes yet
- // XXX: make this go away when inboxes become mandatory
-
- if ($enabled === false ||
- ($enabled == 'transitional' && $this->inboxed == 0)) {
- $qry =
- 'SELECT notice.* ' .
- 'FROM notice JOIN subscription ON notice.profile_id = subscription.subscribed ' .
- 'WHERE subscription.subscriber = %d ' .
- 'AND notice.is_local != ' . Notice::GATEWAY;
- return Notice::getStream(sprintf($qry, $this->id),
- 'user:notices_with_friends:' . $this->id,
- $offset, $limit, $since_id, $before_id,
- $order, $since);
- } else if ($enabled === true ||
- ($enabled == 'transitional' && $this->inboxed == 1)) {
-
- $ids = Notice_inbox::stream($this->id, $offset, $limit, $since_id, $before_id, $since, false);
+ $ids = Notice_inbox::stream($this->id, $offset, $limit, $since_id, $before_id, $since, false);
- return Notice::getStreamByIds($ids);
- }
+ return Notice::getStreamByIds($ids);
}
function noticeInbox($offset=0, $limit=NOTICES_PER_PAGE, $since_id=0, $before_id=0, $since=null)
{
- $enabled = common_config('inboxes', 'enabled');
-
- // Complicated code, depending on whether we support inboxes yet
- // XXX: make this go away when inboxes become mandatory
+ $ids = Notice_inbox::stream($this->id, $offset, $limit, $since_id, $before_id, $since, true);
- if ($enabled === false ||
- ($enabled == 'transitional' && $this->inboxed == 0)) {
- $qry =
- 'SELECT notice.* ' .
- 'FROM notice JOIN subscription ON notice.profile_id = subscription.subscribed ' .
- 'WHERE subscription.subscriber = %d ';
- return Notice::getStream(sprintf($qry, $this->id),
- 'user:notices_with_friends:' . $this->id,
- $offset, $limit, $since_id, $before_id,
- $order, $since);
- } else if ($enabled === true ||
- ($enabled == 'transitional' && $this->inboxed == 1)) {
-
- $ids = Notice_inbox::stream($this->id, $offset, $limit, $since_id, $before_id, $since, true);
-
- return Notice::getStreamByIds($ids);
- }
+ return Notice::getStreamByIds($ids);
}
function blowFavesCache()
@@ -752,12 +711,9 @@ class User extends Memcached_DataObject
'Remember_me',
'Foreign_link',
'Invitation',
+ 'Notice_inbox',
);
- if (common_config('inboxes', 'enabled')) {
- $related[] = 'Notice_inbox';
- }
-
foreach ($related as $cls) {
$inst = new $cls();
$inst->user_id = $this->id;