item tag notifications

This commit is contained in:
friendica 2012-02-09 21:18:50 -08:00
parent 5859f9dcf6
commit ffe7d8b1e9
3 changed files with 44 additions and 24 deletions

View file

@ -905,7 +905,7 @@ function item_store($arr,$force_parent = false) {
); );
} }
tgroup_deliver($arr['uid'],$current_post); tag_deliver($arr['uid'],$current_post);
return $current_post; return $current_post;
} }
@ -923,22 +923,22 @@ function get_item_contact($item,$contacts) {
} }
function tgroup_deliver($uid,$item_id) { function tag_deliver($uid,$item_id) {
// look for mention tags and setup a second delivery chain for forum/community posts if appropriate
// setup a second delivery chain for forum/community posts if appropriate
$a = get_app(); $a = get_app();
$deliver_to_tgroup = false; $mention = false;
$u = q("select * from user where uid = %d and `page-flags` = %d limit 1", $u = q("select uid, nickname, language, username, email, `page-flags`, `notify-flags` from user where uid = %d limit 1",
intval($uid), intval($uid)
intval(PAGE_COMMUNITY)
); );
if(! count($u)) if(! count($u))
return; return;
$community_page = (($u[0]['page-flags'] == PAGE_COMMUNITY) ? true : false);
$i = q("select * from item where id = %d and uid = %d limit 1", $i = q("select * from item where id = %d and uid = %d limit 1",
intval($item_id), intval($item_id),
intval($uid) intval($uid)
@ -948,13 +948,6 @@ function tgroup_deliver($uid,$item_id) {
$item = $i[0]; $item = $i[0];
// prevent delivery looping - only proceed
// if the message originated elsewhere and is a top-level post
if(($item['wall']) || ($item['origin']) || ($item['id'] != $item['parent']))
return;
$link = normalise_link($a->get_baseurl() . '/profile/' . $u[0]['nickname']); $link = normalise_link($a->get_baseurl() . '/profile/' . $u[0]['nickname']);
// Diaspora uses their own hardwired link URL in @-tags // Diaspora uses their own hardwired link URL in @-tags
@ -966,13 +959,38 @@ function tgroup_deliver($uid,$item_id) {
if($cnt) { if($cnt) {
foreach($matches as $mtch) { foreach($matches as $mtch) {
if(link_compare($link,$mtch[1]) || link_compare($dlink,$mtch[1])) { if(link_compare($link,$mtch[1]) || link_compare($dlink,$mtch[1])) {
$deliver_to_tgroup = true; $mention = true;
logger('tgroup_deliver: local group mention found: ' . $mtch[2]); logger('tag_deliver: mention found: ' . $mtch[2]);
} }
} }
} }
if(! $deliver_to_tgroup) if(! $mention)
return;
if(! $community_page) {
require_once('include/enotify.php');
notification(array(
'type' => NOTIFY_TAGSELF,
'notify_flags' => $u[0]['notify-flags'],
'language' => $u[0]['language'],
'to_name' => $u[0]['username'],
'to_email' => $u[0]['email'],
'item' => $item,
'link' => $a->get_baseurl() . '/display/' . $u[0]['nickname'] . '/' . $item['id'],
'source_name' => $item['author-name'],
'source_link' => $item['author-link'],
'source_photo' => $item['author-avatar'],
'verb' => ACTIVITY_TAG,
'otype' => 'item'
));
return;
}
else {
// prevent delivery looping - only proceed
// if the message originated elsewhere and is a top-level post
if(($item['wall']) || ($item['origin']) || ($item['id'] != $item['parent']))
return; return;
// now change this copy of the post to a forum head message and deliver to all the tgroup members // now change this copy of the post to a forum head message and deliver to all the tgroup members
@ -983,7 +1001,7 @@ function tgroup_deliver($uid,$item_id) {
); );
proc_run('php','include/notifier.php','tgroup',$item_id); proc_run('php','include/notifier.php','tgroup',$item_id);
}
} }

View file

@ -818,6 +818,7 @@ function settings_content(&$a) {
'$notify4' => array('notify4', t('Someone writes a followup comment'), ($notify & NOTIFY_COMMENT), NOTIFY_COMMENT, ''), '$notify4' => array('notify4', t('Someone writes a followup comment'), ($notify & NOTIFY_COMMENT), NOTIFY_COMMENT, ''),
'$notify5' => array('notify5', t('You receive a private message'), ($notify & NOTIFY_MAIL), NOTIFY_MAIL, ''), '$notify5' => array('notify5', t('You receive a private message'), ($notify & NOTIFY_MAIL), NOTIFY_MAIL, ''),
'$notify6' => array('notify6', t('You receive a friend suggestion'), ($notify & NOTIFY_SUGGEST), NOTIFY_SUGGEST, ''), '$notify6' => array('notify6', t('You receive a friend suggestion'), ($notify & NOTIFY_SUGGEST), NOTIFY_SUGGEST, ''),
'$notify7' => array('notify7', t('You are tagged in a post'), ($notify & NOTIFY_TAGSELF), NOTIFY_TAGSELF, ''),
'$h_advn' => t('Advanced Page Settings'), '$h_advn' => t('Advanced Page Settings'),

View file

@ -108,6 +108,7 @@ $suggestme
{{inc field_intcheckbox.tpl with $field=$notify4 }}{{endinc}} {{inc field_intcheckbox.tpl with $field=$notify4 }}{{endinc}}
{{inc field_intcheckbox.tpl with $field=$notify5 }}{{endinc}} {{inc field_intcheckbox.tpl with $field=$notify5 }}{{endinc}}
{{inc field_intcheckbox.tpl with $field=$notify6 }}{{endinc}} {{inc field_intcheckbox.tpl with $field=$notify6 }}{{endinc}}
{{inc field_intcheckbox.tpl with $field=$notify7 }}{{endinc}}
</div> </div>