a bit more progress on the new network/home ajax notifications, at least I've now got a plan
This commit is contained in:
parent
15c8da101a
commit
4af6d77de3
@ -82,7 +82,8 @@ function item_redir_and_replace_images($body, $images, $cid) {
|
|||||||
/**
|
/**
|
||||||
* Render actions localized
|
* Render actions localized
|
||||||
*/
|
*/
|
||||||
function localize_item(&$item){
|
|
||||||
|
function localize_item(&$item,$brief = false){
|
||||||
|
|
||||||
$extracted = item_extract_images($item['body']);
|
$extracted = item_extract_images($item['body']);
|
||||||
if($extracted['images'])
|
if($extracted['images'])
|
||||||
@ -123,6 +124,9 @@ function localize_item(&$item){
|
|||||||
break;
|
break;
|
||||||
case ACTIVITY_OBJ_NOTE:
|
case ACTIVITY_OBJ_NOTE:
|
||||||
default:
|
default:
|
||||||
|
if(! ($item_flags & ITEM_THREAD_TOP))
|
||||||
|
$post_type = t('comment');
|
||||||
|
else
|
||||||
$post_type = t('status');
|
$post_type = t('status');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -3,58 +3,39 @@
|
|||||||
|
|
||||||
function format_notification($item) {
|
function format_notification($item) {
|
||||||
|
|
||||||
|
$ret = '';
|
||||||
|
|
||||||
return;
|
return array();
|
||||||
|
|
||||||
|
|
||||||
|
require_once('include/conversation.php');
|
||||||
|
|
||||||
|
// Call localize_item with the "brief" flag to get a one line status for activities.
|
||||||
|
// This should set $item['localized'] to indicate we have a brief summary.
|
||||||
|
|
||||||
|
localize_item($item,true);
|
||||||
|
|
||||||
|
// FIXME - we may need the parent
|
||||||
|
|
||||||
|
if(! $item['localized']) {
|
||||||
|
$itemem_text = (($item['item_flags'] & ITEM_THREAD_TOP)
|
||||||
|
? sprintf( t("%s created a new post"), $item['author']['xchan_name'])
|
||||||
|
: sprintf( t("%s commented on %s's post"), $item['author']['xchan_name'], $item['pname']));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$itemem_text = $item['body'];
|
||||||
|
|
||||||
// convert this logic into a json array just like the system notifications
|
// convert this logic into a json array just like the system notifications
|
||||||
|
|
||||||
switch($item['verb']){
|
return array(
|
||||||
case ACTIVITY_LIKE:
|
'notify_link' => $a->get_baseurl() . '/notify/view/' . $zz['id'],
|
||||||
|
'name' => $zz['name'],
|
||||||
|
'url' => $zz['url'],
|
||||||
|
'photo' => $zz['photo'],
|
||||||
|
'when' => relative_date($zz['date']),
|
||||||
|
'class' => (($zz['seen']) ? 'notify-seen' : 'notify-unseen'),
|
||||||
|
'message' => strip_tags(bbcode($zz['msg']))
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
$notif_content .= replace_macros($tpl_item_likes,array(
|
|
||||||
'$itemem_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$item['parent'],
|
|
||||||
'$itemem_image' => $item['author-avatar'],
|
|
||||||
'$itemem_text' => sprintf( t("%s liked %s's post"), $item['author-name'], $item['pname']),
|
|
||||||
'$itemem_when' => relative_date($item['created'])
|
|
||||||
));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ACTIVITY_DISLIKE:
|
|
||||||
$notif_content .= replace_macros($tpl_item_dislikes,array(
|
|
||||||
'$itemem_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$item['parent'],
|
|
||||||
'$itemem_image' => $item['author-avatar'],
|
|
||||||
'$itemem_text' => sprintf( t("%s disliked %s's post"), $item['author-name'], $item['pname']),
|
|
||||||
'$itemem_when' => relative_date($item['created'])
|
|
||||||
));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ACTIVITY_FRIEND:
|
|
||||||
|
|
||||||
$xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
|
|
||||||
$obj = parse_xml_string($xmlhead.$item['object']);
|
|
||||||
$item['fname'] = $obj->title;
|
|
||||||
|
|
||||||
$notif_content .= replace_macros($tpl_item_friends,array(
|
|
||||||
'$itemem_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$item['parent'],
|
|
||||||
'$itemem_image' => $item['author-avatar'],
|
|
||||||
'$itemem_text' => sprintf( t("%s is now friends with %s"), $item['author-name'], $item['fname']),
|
|
||||||
'$itemem_when' => relative_date($item['created'])
|
|
||||||
));
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
$itemem_text = (($item['id'] == $item['parent'])
|
|
||||||
? sprintf( t("%s created a new post"), $item['author-name'])
|
|
||||||
: sprintf( t("%s commented on %s's post"), $item['author-name'], $item['pname']));
|
|
||||||
$tpl = (($item['id'] == $item['parent']) ? $tpl_item_posts : $tpl_item_comments);
|
|
||||||
|
|
||||||
$notif_content .= replace_macros($tpl,array(
|
|
||||||
'$itemem_link' => $a->get_baseurl(true).'/display/'.$a->user['nickname']."/".$item['parent'],
|
|
||||||
'$itemem_image' => $item['author-avatar'],
|
|
||||||
'$itemem_text' => $itemem_text,
|
|
||||||
'$itemem_when' => relative_date($it['created'])
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,6 +102,7 @@ function ping_init(&$a) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if($r) {
|
if($r) {
|
||||||
|
xchan_query($r);
|
||||||
foreach($r as $item) {
|
foreach($r as $item) {
|
||||||
if((argv(1) === 'home') && (! ($item['item_flags'] & ITEM_HOME)))
|
if((argv(1) === 'home') && (! ($item['item_flags'] & ITEM_HOME)))
|
||||||
continue;
|
continue;
|
||||||
|
Reference in New Issue
Block a user