4 * @file src/Model/UserItem.php
7 namespace Friendica\Model;
9 use Friendica\Database\DBA;
14 * Checks an item for notifications and sets the "notification-type" field
16 * @param array $item The message array that is checked for notifications
17 * @param int $uid User ID
19 public static function setNotification($item, $uid)
23 private static function checkShared($item, $uid)
25 if ($item['gravity'] != GRAVITY_PARENT) {
29 // Send a notification for every new post?
30 // Either the contact had posted something directly
31 if (DBA::exists('contact', ['id' => $item['contact-id'], 'notify_new_posts' => true])) {
35 // Or the contact is a mentioned forum
36 $tags = DBA::select('term', ['url'], ['otype' => TERM_OBJ_POST, 'oid' => $itemid, 'type' => TERM_MENTION, 'uid' => $uid]);
37 while ($tag = DBA::fetch($tags)) {
38 $condition = ['nurl' => Strings::normaliseLink($tag["url"]), 'uid' => $uid, 'notify_new_posts' => true, 'contact-type' => Contact::TYPE_COMMUNITY];
39 if (DBA::exists('contact', $condition)) {
47 // Is the user mentioned in this post?
48 private static function checkTagged($item, $uid)
50 if ($item["mention"]) {
54 foreach ($profiles AS $profile) {
55 if (strpos($item["tag"], "=".$profile."]") || strpos($item["body"], "=".$profile."]"))
59 if ($defaulttype == NOTIFY_TAGSELF) {
66 private static function checkCommented($item, $uid)
68 // Is it a post that the user had started?
69 $fields = ['ignored', 'mention'];
70 $thread = Item::selectFirstThreadForUser($uid, $fields, ['iid' => $item["parent"], 'deleted' => false]);
72 if ($thread['mention'] && !$thread['ignored']) {
76 // And now we check for participation of one of our contacts in the thread
77 $condition = ['parent' => $item["parent"], 'author-id' => $contacts, 'deleted' => false];
79 if (!$thread['ignored'] && Item::exists($condition)) {