Functionality is now added
This commit is contained in:
parent
ecb4848dfd
commit
8e2494568e
|
@ -2026,6 +2026,8 @@ class Item
|
||||||
|
|
||||||
self::updateContact($item);
|
self::updateContact($item);
|
||||||
|
|
||||||
|
UserItem::setNotification($current_post, $item['uid']);
|
||||||
|
|
||||||
check_user_notification($current_post);
|
check_user_notification($current_post);
|
||||||
|
|
||||||
if ($notify || ($item['visible'] && ((!empty($parent) && $parent['origin']) || $item['origin']))) {
|
if ($notify || ($item['visible'] && ((!empty($parent) && $parent['origin']) || $item['origin']))) {
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
namespace Friendica\Model;
|
namespace Friendica\Model;
|
||||||
|
|
||||||
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Core\Hook;
|
use Friendica\Core\Hook;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
@ -28,8 +29,12 @@ class UserItem
|
||||||
* @param array $item The message array that is checked for notifications
|
* @param array $item The message array that is checked for notifications
|
||||||
* @param int $uid User ID
|
* @param int $uid User ID
|
||||||
*/
|
*/
|
||||||
public static function setNotification($item, $uid)
|
public static function setNotification($iid, $uid)
|
||||||
{
|
{
|
||||||
|
$fields = ['id', 'body', 'origin', 'parent', 'gravity', 'tag', 'contact-id',
|
||||||
|
'thr-parent', 'parent-uri', 'mention'];
|
||||||
|
$item = Item::selectFirst($fields, ['id' => $iid]);
|
||||||
|
|
||||||
// Don't check for own posts
|
// Don't check for own posts
|
||||||
if ($item['origin'] || empty($uid)) {
|
if ($item['origin'] || empty($uid)) {
|
||||||
return;
|
return;
|
||||||
|
@ -80,6 +85,12 @@ class UserItem
|
||||||
$notification_type = $notification_type | self::NOTIF_ACTIVITY_PARTICIPATION;
|
$notification_type = $notification_type | self::NOTIF_ACTIVITY_PARTICIPATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (empty($notification_type)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger::info('Set notification', ['iid' => $item['id'], 'uid' => $uid, 'notification-type' => $notification_type]);
|
||||||
|
|
||||||
DBA::update('user-item', ['notification-type' => $notification_type], ['iid' => $item['id'], 'uid' => $uid], true);
|
DBA::update('user-item', ['notification-type' => $notification_type], ['iid' => $item['id'], 'uid' => $uid], true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +155,7 @@ class UserItem
|
||||||
}
|
}
|
||||||
|
|
||||||
// Or the contact is a mentioned forum
|
// Or the contact is a mentioned forum
|
||||||
$tags = DBA::select('term', ['url'], ['otype' => TERM_OBJ_POST, 'oid' => $itemid, 'type' => TERM_MENTION, 'uid' => $uid]);
|
$tags = DBA::select('term', ['url'], ['otype' => TERM_OBJ_POST, 'oid' => $item['id'], 'type' => TERM_MENTION, 'uid' => $uid]);
|
||||||
while ($tag = DBA::fetch($tags)) {
|
while ($tag = DBA::fetch($tags)) {
|
||||||
$condition = ['nurl' => Strings::normaliseLink($tag['url']), 'uid' => $uid, 'notify_new_posts' => true, 'contact-type' => Contact::TYPE_COMMUNITY];
|
$condition = ['nurl' => Strings::normaliseLink($tag['url']), 'uid' => $uid, 'notify_new_posts' => true, 'contact-type' => Contact::TYPE_COMMUNITY];
|
||||||
if (DBA::exists('contact', $condition)) {
|
if (DBA::exists('contact', $condition)) {
|
||||||
|
|
Loading…
Reference in a new issue