work on notifications
This commit is contained in:
parent
e6aaf1e9bf
commit
1e8146fc5c
@ -1505,11 +1505,73 @@ function item_store($arr,$force_parent = false) {
|
|||||||
intval($parent_id)
|
intval($parent_id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
send_status_notifications($current_post,$arr);
|
||||||
|
|
||||||
tag_deliver($arr['uid'],$current_post);
|
tag_deliver($arr['uid'],$current_post);
|
||||||
|
|
||||||
return $current_post;
|
return $current_post;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function send_status_notifications($post_id,$item) {
|
||||||
|
|
||||||
|
$notify = false;
|
||||||
|
$parent = 0;
|
||||||
|
|
||||||
|
$r = q("select channel_hash from channel where channel_id = %d limit 1",
|
||||||
|
intval($item['uid'])
|
||||||
|
);
|
||||||
|
if(! $r)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// my own post - no notification needed
|
||||||
|
if($item['author_xchan'] === $r[0]['channel_hash'])
|
||||||
|
return;
|
||||||
|
|
||||||
|
// I'm the owner - notify me
|
||||||
|
|
||||||
|
if($item['owner_hash'] === $r[0]['channel_hash'])
|
||||||
|
$notify = true;
|
||||||
|
|
||||||
|
// Was I involved in this conversation?
|
||||||
|
|
||||||
|
$x = q("select * from item where parent_uri = '%s' and uid = %d",
|
||||||
|
dbesc($item['parent_uri']),
|
||||||
|
intval($item['uid'])
|
||||||
|
);
|
||||||
|
if($x) {
|
||||||
|
foreach($x as $xx) {
|
||||||
|
if($xx['author_xchan'] === $r[0]['channel_hash']) {
|
||||||
|
$notify = true;
|
||||||
|
if($xx['id'] == $xx['parent'])
|
||||||
|
$parent = $xx['parent'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(! $notify)
|
||||||
|
return;
|
||||||
|
require_once('include/enotify.php');
|
||||||
|
notification(array(
|
||||||
|
'type' => NOTIFY_COMMENT,
|
||||||
|
'from_xchan' => $item['author_xchan'],
|
||||||
|
'to_xchan' => $r[0]['channel_hash'],
|
||||||
|
'item' => $item,
|
||||||
|
'link' => $a->get_baseurl() . '/display/' . $item['uri'],
|
||||||
|
'verb' => ACTIVITY_POST,
|
||||||
|
'otype' => 'item',
|
||||||
|
'parent' => $parent,
|
||||||
|
'parent_uri' => $item['parent_uri']
|
||||||
|
));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function get_item_contact($item,$contacts) {
|
function get_item_contact($item,$contacts) {
|
||||||
if(! count($contacts) || (! is_array($item)))
|
if(! count($contacts) || (! is_array($item)))
|
||||||
return false;
|
return false;
|
||||||
|
32
mod/item.php
32
mod/item.php
@ -662,20 +662,14 @@ function item_post(&$a) {
|
|||||||
intval($parent_item['private']),
|
intval($parent_item['private']),
|
||||||
intval($post_id)
|
intval($post_id)
|
||||||
);
|
);
|
||||||
//fixme
|
|
||||||
if($contact_record != $author) {
|
if($datarray['owner_xchan'] != $datarray['author_xchan']) {
|
||||||
notification(array(
|
notification(array(
|
||||||
'type' => NOTIFY_COMMENT,
|
'type' => NOTIFY_COMMENT,
|
||||||
'notify_flags' => $channel['channel_notifyflags'],
|
'from_xchan' => $datarray['author_xchan'],
|
||||||
'language' => $channel['account_language'],
|
'to_xchan' => $datarray['owner_xchan'],
|
||||||
'to_name' => $channel['channel_name'],
|
|
||||||
'to_email' => $channel['account_email'],
|
|
||||||
'uid' => $channel['channel_id'],
|
|
||||||
'item' => $datarray,
|
'item' => $datarray,
|
||||||
'link' => $a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $post_id,
|
'link' => $a->get_baseurl() . '/display/' . $datarray['uri'],
|
||||||
'source_name' => $datarray['author-name'],
|
|
||||||
'source_link' => $datarray['author-link'],
|
|
||||||
'source_photo' => $datarray['author-avatar'],
|
|
||||||
'verb' => ACTIVITY_POST,
|
'verb' => ACTIVITY_POST,
|
||||||
'otype' => 'item',
|
'otype' => 'item',
|
||||||
'parent' => $parent,
|
'parent' => $parent,
|
||||||
@ -687,20 +681,14 @@ function item_post(&$a) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$parent = $post_id;
|
$parent = $post_id;
|
||||||
//fixme
|
|
||||||
if($contact_record != $author) {
|
if($datarray['owner_xchan'] != $datarray['author_xchan']) {
|
||||||
notification(array(
|
notification(array(
|
||||||
'type' => NOTIFY_WALL,
|
'type' => NOTIFY_WALL,
|
||||||
'notify_flags' => $channel['channel_notifyflags'],
|
'from_xchan' => $datarray['author_xchan'],
|
||||||
'language' => $channel['account_language'],
|
'to_xchan' => $datarray['owner_xchan'],
|
||||||
'to_name' => $channel['channel_name'],
|
|
||||||
'to_email' => $channel['account_email'],
|
|
||||||
'uid' => $channel['channel_id'],
|
|
||||||
'item' => $datarray,
|
'item' => $datarray,
|
||||||
'link' => $a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $post_id,
|
'link' => $a->get_baseurl() . '/display/' . $datarray['uri'],
|
||||||
'source_name' => $datarray['author-name'],
|
|
||||||
'source_link' => $datarray['author-link'],
|
|
||||||
'source_photo' => $datarray['author-avatar'],
|
|
||||||
'verb' => ACTIVITY_POST,
|
'verb' => ACTIVITY_POST,
|
||||||
'otype' => 'item'
|
'otype' => 'item'
|
||||||
));
|
));
|
||||||
|
Reference in New Issue
Block a user