summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
Diffstat (limited to 'classes')
-rw-r--r--classes/Notice.php9
-rw-r--r--classes/User.php52
2 files changed, 61 insertions, 0 deletions
diff --git a/classes/Notice.php b/classes/Notice.php
index ec80f763f..6a701ae0c 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -454,6 +454,15 @@ class Notice extends Memcached_DataObject
// XXX: only blow if <100 in cache
$ck = common_cache_key('notice:repeats:'.$this->repeat_of);
$result = $cache->delete($ck);
+
+ $user = User::staticGet('id', $this->profile_id);
+
+ if (!empty($user)) {
+ $uk = common_cache_key('user:repeated_by_me:'.$user->id);
+ $cache->delete($uk);
+ $user->free();
+ unset($user);
+ }
}
}
}
diff --git a/classes/User.php b/classes/User.php
index 2a4fab7d4..4b7365fc7 100644
--- a/classes/User.php
+++ b/classes/User.php
@@ -741,4 +741,56 @@ class User extends Memcached_DataObject
$profile = $this->getProfile();
return $profile->isSilenced();
}
+
+ function repeatedByMe($offset=0, $limit=20, $since_id=null, $max_id=null)
+ {
+ $ids = Notice::stream(array($this, '_repeatedByMeDirect'),
+ array(),
+ 'user:repeated_by_me:'.$this->id,
+ $offset, $limit, $since_id, $max_id, null);
+
+ return Notice::getStreamByIds($ids);
+ }
+
+ function _repeatedByMeDirect($offset, $limit, $since_id, $max_id, $since)
+ {
+ $notice = new Notice();
+
+ $notice->selectAdd(); // clears it
+ $notice->selectAdd('id');
+
+ $notice->profile_id = $this->id;
+ $notice->whereAdd('repeat_of IS NOT NULL');
+
+ $notice->orderBy('id DESC');
+
+ if (!is_null($offset)) {
+ $notice->limit($offset, $limit);
+ }
+
+ if ($since_id != 0) {
+ $notice->whereAdd('id > ' . $since_id);
+ }
+
+ if ($max_id != 0) {
+ $notice->whereAdd('id <= ' . $max_id);
+ }
+
+ if (!is_null($since)) {
+ $notice->whereAdd('created > \'' . date('Y-m-d H:i:s', $since) . '\'');
+ }
+
+ $ids = array();
+
+ if ($notice->find()) {
+ while ($notice->fetch()) {
+ $ids[] = $notice->id;
+ }
+ }
+
+ $notice->free();
+ $notice = NULL;
+
+ return $ids;
+ }
}