We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit c39207b0 authored by Evan Prodromou's avatar Evan Prodromou

reply to notice marks the author of notice for reply

parent 7e6cffe4
......@@ -1191,15 +1191,8 @@ class Notice extends Memcached_DataObject
continue;
}
$reply = new Reply();
$reply->notice_id = $this->id;
$reply->profile_id = $profile->id;
$reply->modified = $this->created;
common_log(LOG_INFO, __METHOD__ . ": saving reply: notice $this->id to profile $profile->id");
$id = $reply->insert();
$this->saveReply($profile->id);
self::blow('reply:stream:%d', $profile->id);
}
return;
......@@ -1225,13 +1218,27 @@ class Notice extends Memcached_DataObject
$sender = Profile::staticGet($this->profile_id);
$replied = array();
// If it's a reply, save for the replied-to author
if (!empty($this->reply_to)) {
$original = $this->getOriginal();
if (!empty($original)) { // that'd be weird
$author = $original->getProfile();
if (!empty($author)) {
$this->saveReply($author->id);
$replied[$author->id] = 1;
self::blow('reply:stream:%d', $author->id);
}
}
}
// @todo ideally this parser information would only
// be calculated once.
$mentions = common_find_mentions($this->content, $this);
$replied = array();
// store replied only for first @ (what user/notice what the reply directed,
// we assume first @ is it)
......@@ -1252,23 +1259,9 @@ class Notice extends Memcached_DataObject
continue;
}
$reply = new Reply();
$reply->notice_id = $this->id;
$reply->profile_id = $mentioned->id;
$reply->modified = $this->created;
$id = $reply->insert();
if (!$id) {
common_log_db_error($reply, 'INSERT', __FILE__);
// TRANS: Server exception thrown when a reply cannot be saved.
// TRANS: %1$d is a notice ID, %2$d is the ID of the mentioned user.
throw new ServerException(sprintf(_('Could not save reply for %1$d, %2$d.'), $this->id, $mentioned->id));
} else {
$replied[$mentioned->id] = 1;
self::blow('reply:stream:%d', $mentioned->id);
}
$this->saveReply($mentioned->id);
$replied[$mentioned->id] = 1;
self::blow('reply:stream:%d', $mentioned->id);
}
}
......@@ -1277,6 +1270,19 @@ class Notice extends Memcached_DataObject
return $recipientIds;
}
function saveReply($profileId)
{
$reply = new Reply();
$reply->notice_id = $this->id;
$reply->profile_id = $profileId;
$reply->modified = $this->created;
$reply->insert();
return $reply;
}
/**
* Pull the complete list of @-reply targets for this notice.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment