public $location_id; // int(4)
public $location_ns; // int(4)
public $repeat_of; // int(4)
+ public $object_type; // varchar(255)
/* Static get */
function staticGet($k,$v=NULL)
* array 'urls' list of attached/referred URLs to save with the
* notice in place of extracting links from content
* boolean 'distribute' whether to distribute the notice, default true
+ * string 'object_type' URL of the associated object type (default ActivityObject::NOTE)
*
* @fixme tag override
*
$notice->rendered = common_render_content($final, $notice);
}
+ if (empty($object_type)) {
+ $notice->object_type = (empty($notice->reply_to)) ? ActivityObject::NOTE : ActivityObject::COMMENT;
+ } else {
+ $notice->object_type = $object_type;
+ }
+
if (Event::handle('StartNoticeSave', array(&$notice))) {
// XXX: some of these functions write to the DB
if ($this->isPublic()) {
self::blow('public;last');
}
+
+ self::blow('fave:by_notice', $this->id);
+
+ if ($this->conversation) {
+ // In case we're the first, will need to calc a new root.
+ self::blow('notice:conversation_root:%d', $this->conversation);
+ }
}
/** save all urls in the notice to the db
return false;
}
+ /**
+ * Grab the earliest notice from this conversation.
+ *
+ * @return Notice or null
+ */
+ function conversationRoot()
+ {
+ if (!empty($this->conversation)) {
+ $c = self::memcache();
+
+ $key = Cache::key('notice:conversation_root:' . $this->conversation);
+ $notice = $c->get($key);
+ if ($notice) {
+ return $notice;
+ }
+
+ $notice = new Notice();
+ $notice->conversation = $this->conversation;
+ $notice->orderBy('CREATED');
+ $notice->limit(1);
+ $notice->find(true);
+
+ if ($notice->N) {
+ $c->set($key, $notice);
+ return $notice;
+ }
+ }
+ return null;
+ }
/**
* Pull up a full list of local recipients who will be getting
* this notice in their inbox. Results will be cached, so don't
$ni = array();
- foreach ($users as $id) {
- $ni[$id] = NOTICE_INBOX_SOURCE_SUB;
- }
+ // Give plugins a chance to add folks in at start...
+ if (Event::handle('StartNoticeWhoGets', array($this, &$ni))) {
- foreach ($groups as $group) {
- $users = $group->getUserMembers();
foreach ($users as $id) {
- if (!array_key_exists($id, $ni)) {
- $ni[$id] = NOTICE_INBOX_SOURCE_GROUP;
+ $ni[$id] = NOTICE_INBOX_SOURCE_SUB;
+ }
+
+ foreach ($groups as $group) {
+ $users = $group->getUserMembers();
+ foreach ($users as $id) {
+ if (!array_key_exists($id, $ni)) {
+ $ni[$id] = NOTICE_INBOX_SOURCE_GROUP;
+ }
}
}
- }
foreach ($ptags as $ptag) {
$users = $ptag->getUserSubscribers();
if (!array_key_exists($recipient, $ni)) {
$ni[$recipient] = NOTICE_INBOX_SOURCE_REPLY;
}
- }
- // Exclude any deleted, non-local, or blocking recipients.
- $profile = $this->getProfile();
- $originalProfile = null;
- if ($this->repeat_of) {
- // Check blocks against the original notice's poster as well.
- $original = Notice::staticGet('id', $this->repeat_of);
- if ($original) {
- $originalProfile = $original->getProfile();
+ // Exclude any deleted, non-local, or blocking recipients.
+ $profile = $this->getProfile();
+ $originalProfile = null;
+ if ($this->repeat_of) {
+ // Check blocks against the original notice's poster as well.
+ $original = Notice::staticGet('id', $this->repeat_of);
+ if ($original) {
+ $originalProfile = $original->getProfile();
+ }
}
- }
- foreach ($ni as $id => $source) {
- $user = User::staticGet('id', $id);
- if (empty($user) || $user->hasBlocked($profile) ||
- ($originalProfile && $user->hasBlocked($originalProfile))) {
- unset($ni[$id]);
+ foreach ($ni as $id => $source) {
+ $user = User::staticGet('id', $id);
+ if (empty($user) || $user->hasBlocked($profile) ||
+ ($originalProfile && $user->hasBlocked($originalProfile))) {
+ unset($ni[$id]);
+ }
}
+
+ // Give plugins a chance to filter out...
+ Event::handle('EndNoticeWhoGets', array($this, &$ni));
}
if (!empty($c)) {
$this->is_local == Notice::LOCAL_NONPUBLIC);
}
+ /**
+ * Get the list of hash tags saved with this notice.
+ *
+ * @return array of strings
+ */
public function getTags()
{
$tags = array();