$stored->uri = $uri;
if ($stored->find()) {
common_debug('cannot create duplicate Notice URI: '.$stored->uri);
- throw new Exception('Notice URI already exists');
+ // I _assume_ saving a Notice with a colliding URI means we're really trying to
+ // save the same notice again...
+ throw new AlreadyFulfilledException('Notice URI already exists');
}
}
// Use the local user's shortening preferences, if applicable.
$stored->rendered = $actor->isLocal()
? $actor->shortenLinks($act->content)
- : $act->content;
+ : common_purify($act->content);
$stored->content = common_strip_html($stored->rendered);
// Maybe a missing act-time should be fatal if the actor is not local?
// If the original is private to a group, and notice has no group specified,
// make it to the same group(s)
if (empty($groups) && ($reply->scope & Notice::GROUP_SCOPE)) {
- $groups = array();
$replyGroups = $reply->getGroups();
foreach ($replyGroups as $group) {
if ($actor->isMember($group)) {
// Save per-notice metadata...
$mentions = array();
- $groups = array();
+ $group_ids = array();
// This event lets plugins filter out non-local recipients (attentions we don't care about)
// Used primarily for OStatus (and if we don't federate, all attentions would be local anyway)
- Event::handle('GetLocalAttentions', array($actor, $act->context->attention, &$mentions, &$groups));
+ Event::handle('GetLocalAttentions', array($actor, $act->context->attention, &$mentions, &$group_ids));
if (!empty($mentions)) {
$stored->saveKnownReplies($mentions);
// to avoid errors on duplicates.
// Note: groups should always be set.
- $stored->saveKnownGroups($groups);
+ $stored->saveKnownGroups($group_ids);
if (!empty($urls)) {
$stored->saveKnownUrls($urls);
* best with generalizations on user_group to support
* remote groups better.
*/
- function saveKnownGroups($group_ids)
+ function saveKnownGroups(array $group_ids)
{
- if (!is_array($group_ids)) {
- // TRANS: Server exception thrown when no array is provided to the method saveKnownGroups().
- throw new ServerException(_('Bad type provided to saveKnownGroups.'));
- }
-
$groups = array();
foreach (array_unique($group_ids) as $id) {
$group = User_group::getKV('id', $id);
return;
}
- $sender = Profile::getKV($this->profile_id);
+ $sender = $this->getProfile();
foreach (array_unique($uris) as $uri) {
try {
continue;
}
- $this->saveReply($profile->id);
- self::blow('reply:stream:%d', $profile->id);
+ $this->saveReply($profile->getID());
+ self::blow('reply:stream:%d', $profile->getID());
}
-
- return;
}
/**
function sendReplyNotifications()
{
// Don't send reply notifications for repeats
-
if ($this->isRepeat()) {
return array();
}
require_once INSTALLDIR.'/lib/mail.php';
foreach ($recipientIds as $recipientId) {
- $user = User::getKV('id', $recipientId);
- if ($user instanceof User) {
+ try {
+ $user = User::getByID($recipientId);
mail_notify_attn($user, $this);
+ } catch (NoResultException $e) {
+ // No such user
}
}
Event::handle('EndNotifyMentioned', array($this, $recipientIds));
public function getParent()
{
+ $reply_to_id = null;
+
if (empty($this->reply_to)) {
throw new NoParentNoticeException($this);
}
- return self::getByID($this->reply_to);
+
+ // The reply_to ID in the table Notice could exist with a number
+ // however, the replied to notice might not exist in the database.
+ // Thus we need to catch the exception and throw the NoParentNoticeException else
+ // the timeline will not display correctly.
+ try {
+ $reply_to_id = self::getByID($this->reply_to);
+ } catch(Exception $e){
+ throw new NoParentNoticeException($this);
+ }
+
+
+ return $reply_to_id;
}
/**