Sends notifications for public posts with "uid=0"
This commit is contained in:
parent
1fdde9b140
commit
f2efd58366
|
@ -106,9 +106,8 @@ function notification($params)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($params['type'] == NOTIFY_COMMENT) {
|
if ($params['type'] == NOTIFY_COMMENT) {
|
||||||
$p = q("SELECT `ignored` FROM `thread` WHERE `iid` = %d AND `uid` = %d LIMIT 1",
|
$p = q("SELECT `ignored` FROM `thread` WHERE `iid` = %d LIMIT 1",
|
||||||
intval($parent_id),
|
intval($parent_id)
|
||||||
intval($params['uid'])
|
|
||||||
);
|
);
|
||||||
if ($p && count($p) && ($p[0]["ignored"])) {
|
if ($p && count($p) && ($p[0]["ignored"])) {
|
||||||
logger("Thread ".$parent_id." will be ignored", LOGGER_DEBUG);
|
logger("Thread ".$parent_id." will be ignored", LOGGER_DEBUG);
|
||||||
|
@ -134,9 +133,8 @@ function notification($params)
|
||||||
$p = null;
|
$p = null;
|
||||||
|
|
||||||
if ($params['otype'] === 'item' && $parent_id) {
|
if ($params['otype'] === 'item' && $parent_id) {
|
||||||
$p = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
$p = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1",
|
||||||
intval($parent_id),
|
intval($parent_id)
|
||||||
intval($params['uid'])
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -648,6 +646,20 @@ function notification($params)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Checks for users who should be notified
|
||||||
|
*
|
||||||
|
* @param int $itemid ID of the item for which the check should be done
|
||||||
|
*/
|
||||||
|
function check_user_notification($itemid) {
|
||||||
|
// fetch all users in the thread
|
||||||
|
$users = dba::p("SELECT DISTINCT(`uid`) FROM `item` WHERE `parent` IN (SELECT `parent` FROM `item` WHERE `id`=?) AND `uid` != 0", $itemid);
|
||||||
|
while ($user = dba::fetch($users)) {
|
||||||
|
check_item_notification($itemid, $user['uid']);
|
||||||
|
}
|
||||||
|
dba::close($users);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Checks for item related notifications and sends them
|
* @brief Checks for item related notifications and sends them
|
||||||
*
|
*
|
||||||
|
@ -735,9 +747,8 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
|
||||||
|
|
||||||
if ($item[0]["parent-uri"] === $item[0]["uri"]) {
|
if ($item[0]["parent-uri"] === $item[0]["uri"]) {
|
||||||
// Send a notification for every new post?
|
// Send a notification for every new post?
|
||||||
$r = q("SELECT `notify_new_posts` FROM `contact` WHERE `id` = %d AND `uid` = %d AND `notify_new_posts` LIMIT 1",
|
$r = q("SELECT `notify_new_posts` FROM `contact` WHERE `id` = %d AND `notify_new_posts` LIMIT 1",
|
||||||
intval($item[0]['contact-id']),
|
intval($item[0]['contact-id'])
|
||||||
intval($uid)
|
|
||||||
);
|
);
|
||||||
$send_notification = DBM::is_result($r);
|
$send_notification = DBM::is_result($r);
|
||||||
|
|
||||||
|
@ -776,10 +787,10 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
|
||||||
|
|
||||||
// Is it a post that the user had started or where he interacted?
|
// Is it a post that the user had started or where he interacted?
|
||||||
$parent = q("SELECT `thread`.`iid` FROM `thread` INNER JOIN `item` ON `item`.`parent` = `thread`.`iid`
|
$parent = q("SELECT `thread`.`iid` FROM `thread` INNER JOIN `item` ON `item`.`parent` = `thread`.`iid`
|
||||||
WHERE `thread`.`iid` = %d AND `thread`.`uid` = %d AND NOT `thread`.`ignored` AND
|
WHERE `thread`.`iid` = %d AND NOT `thread`.`ignored` AND
|
||||||
(`thread`.`mention` OR `item`.`author-link` IN ($profile_list))
|
(`thread`.`mention` OR `item`.`author-link` IN ($profile_list))
|
||||||
LIMIT 1",
|
LIMIT 1",
|
||||||
intval($item[0]["parent"]), intval($uid));
|
intval($item[0]["parent"]));
|
||||||
|
|
||||||
if ($parent && !isset($params["type"])) {
|
if ($parent && !isset($params["type"])) {
|
||||||
$params["type"] = NOTIFY_COMMENT;
|
$params["type"] = NOTIFY_COMMENT;
|
||||||
|
|
|
@ -1129,7 +1129,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
|
||||||
add_shadow_entry($current_post);
|
add_shadow_entry($current_post);
|
||||||
}
|
}
|
||||||
|
|
||||||
check_item_notification($current_post, $uid);
|
check_user_notification($current_post);
|
||||||
|
|
||||||
if ($notify) {
|
if ($notify) {
|
||||||
Worker::add(array('priority' => PRIORITY_HIGH, 'dont_fork' => true), "Notifier", $notify_type, $current_post);
|
Worker::add(array('priority' => PRIORITY_HIGH, 'dont_fork' => true), "Notifier", $notify_type, $current_post);
|
||||||
|
|
|
@ -1067,6 +1067,8 @@ function item_post(App $a) {
|
||||||
create_tags_from_item($post_id);
|
create_tags_from_item($post_id);
|
||||||
create_files_from_item($post_id);
|
create_files_from_item($post_id);
|
||||||
|
|
||||||
|
check_user_notification($post_id);
|
||||||
|
|
||||||
// Insert an item entry for UID=0 for global entries.
|
// Insert an item entry for UID=0 for global entries.
|
||||||
// We now do it in the background to save some time.
|
// We now do it in the background to save some time.
|
||||||
// This is important in interactive environments like the frontend or the API.
|
// This is important in interactive environments like the frontend or the API.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user