forked from GNUsocial/gnu-social
reply to notice marks the author of notice for reply
This commit is contained in:
parent
7e6cffe4cf
commit
c39207b0f8
@ -1191,15 +1191,8 @@ class Notice extends Memcached_DataObject
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$reply = new Reply();
|
$this->saveReply($profile->id);
|
||||||
|
self::blow('reply:stream:%d', $profile->id);
|
||||||
$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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -1225,13 +1218,27 @@ class Notice extends Memcached_DataObject
|
|||||||
|
|
||||||
$sender = Profile::staticGet($this->profile_id);
|
$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
|
// @todo ideally this parser information would only
|
||||||
// be calculated once.
|
// be calculated once.
|
||||||
|
|
||||||
$mentions = common_find_mentions($this->content, $this);
|
$mentions = common_find_mentions($this->content, $this);
|
||||||
|
|
||||||
$replied = array();
|
|
||||||
|
|
||||||
// store replied only for first @ (what user/notice what the reply directed,
|
// store replied only for first @ (what user/notice what the reply directed,
|
||||||
// we assume first @ is it)
|
// we assume first @ is it)
|
||||||
|
|
||||||
@ -1252,31 +1259,30 @@ class Notice extends Memcached_DataObject
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$reply = new Reply();
|
$this->saveReply($mentioned->id);
|
||||||
|
|
||||||
$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;
|
$replied[$mentioned->id] = 1;
|
||||||
self::blow('reply:stream:%d', $mentioned->id);
|
self::blow('reply:stream:%d', $mentioned->id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$recipientIds = array_keys($replied);
|
$recipientIds = array_keys($replied);
|
||||||
|
|
||||||
return $recipientIds;
|
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.
|
* Pull the complete list of @-reply targets for this notice.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user