- // 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",
- intval($item[0]['contact-id']),
- intval($uid)
- );
- $send_notification = count($r);
-
- if (!$send_notification) {
- $tags = q("SELECT `url` FROM `term` WHERE `otype` = %d AND `oid` = %d AND `type` = %d AND `uid` = %d",
- intval(TERM_OBJ_POST), intval($itemid), intval(TERM_MENTION), intval($uid));
-
- if (count($tags)) {
- foreach ($tags AS $tag) {
- $r = q("SELECT `id` FROM `contact` WHERE `nurl` = '%s' AND `uid` = %d AND `notify_new_posts`",
- normalise_link($tag["url"]), intval($uid));
- if (dba::is_result($r))
- $send_notification = true;
- }
- }
- }
+ // Send a notification for every new post?
+ $send_notification = dba::exists('contact', ['id' => $item[0]['contact-id'], 'notify_new_posts' => true]);
+
+ if (!$send_notification) {
+ $tags = q("SELECT `url` FROM `term` WHERE `otype` = %d AND `oid` = %d AND `type` = %d AND `uid` = %d",
+ intval(TERM_OBJ_POST), intval($itemid), intval(TERM_MENTION), intval($uid));
+
+ if (DBM::is_result($tags)) {
+ foreach ($tags AS $tag) {
+ $condition = ['nurl' => normalise_link($tag["url"]), 'uid' => $uid, 'notify_new_posts' => true];
+ $r = dba::exists('contact', $condition);
+ if ($r) {
+ $send_notification = true;
+ }
+ }
+ }
+ }