Patch from g0: fix for conversation links in Realtime updates
Previously was using the reply-to URL, which didn't match with other displays. Now sends to the right conversation page.
This commit is contained in:
parent
1999b836c0
commit
e36df29212
|
@ -1,6 +1,5 @@
|
|||
== TODO ==
|
||||
* i18n
|
||||
* Change in context URL to conversation (try not to construct the URL in JS)
|
||||
* Update mark behaviour (on notice send)
|
||||
* Pause, Send a notice ~ should not update counter
|
||||
* Pause ~ retain up to 50-100 most recent notices
|
||||
|
|
|
@ -250,14 +250,7 @@ class RealtimePlugin extends Plugin
|
|||
$arr['url'] = $notice->bestUrl();
|
||||
$arr['html'] = htmlspecialchars($notice->rendered);
|
||||
$arr['source'] = htmlspecialchars($arr['source']);
|
||||
|
||||
if (!empty($notice->reply_to)) {
|
||||
$reply_to = Notice::staticGet('id', $notice->reply_to);
|
||||
if (!empty($reply_to)) {
|
||||
$arr['in_reply_to_status_url'] = $reply_to->bestUrl();
|
||||
}
|
||||
$reply_to = null;
|
||||
}
|
||||
$arr['conversation_url'] = $this->getConversationUrl($notice);
|
||||
|
||||
$profile = $notice->getProfile();
|
||||
$arr['user']['profile_url'] = $profile->profileurl;
|
||||
|
@ -272,10 +265,7 @@ class RealtimePlugin extends Plugin
|
|||
$arr['retweeted_status']['source'] = htmlspecialchars($original->source);
|
||||
$originalProfile = $original->getProfile();
|
||||
$arr['retweeted_status']['user']['profile_url'] = $originalProfile->profileurl;
|
||||
if (!empty($original->reply_to)) {
|
||||
$originalReply = Notice::staticGet('id', $original->reply_to);
|
||||
$arr['retweeted_status']['in_reply_to_status_url'] = $originalReply->bestUrl();
|
||||
}
|
||||
$arr['retweeted_status']['conversation_url'] = $this->getConversationUrl($original);
|
||||
}
|
||||
$original = null;
|
||||
}
|
||||
|
@ -303,6 +293,32 @@ class RealtimePlugin extends Plugin
|
|||
return $tags;
|
||||
}
|
||||
|
||||
function getConversationUrl($notice)
|
||||
{
|
||||
$convurl = null;
|
||||
|
||||
if ($notice->hasConversation()) {
|
||||
$conv = Conversation::staticGet(
|
||||
'id',
|
||||
$notice->conversation
|
||||
);
|
||||
$convurl = $conv->uri;
|
||||
|
||||
if(empty($convurl)) {
|
||||
$msg = sprintf(
|
||||
"Couldn't find Conversation ID %d to make 'in context'"
|
||||
. "link for Notice ID %d",
|
||||
$notice->conversation,
|
||||
$notice->id
|
||||
);
|
||||
|
||||
common_log(LOG_WARNING, $msg);
|
||||
}
|
||||
}
|
||||
|
||||
return $convurl;
|
||||
}
|
||||
|
||||
function _getScripts()
|
||||
{
|
||||
return array('plugins/Realtime/realtimeupdate.js');
|
||||
|
|
|
@ -149,8 +149,8 @@ RealtimeUpdate = {
|
|||
"from "+
|
||||
"<span class=\"device\">"+source+"</span>"+ // may have a link
|
||||
"</span>";
|
||||
if (data['in_reply_to_status_id']) {
|
||||
ni = ni+" <a class=\"response\" href=\""+data['in_reply_to_status_url']+"\">in context</a>";
|
||||
if (data['conversation_url']) {
|
||||
ni = ni+" <a class=\"response\" href=\""+data['conversation_url']+"\">in context</a>";
|
||||
}
|
||||
|
||||
if (repeat) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user