Fix post update / clean up code

This commit is contained in:
Michael 2020-01-05 10:16:01 +00:00
parent 4b44aca507
commit 20d570823d
2 changed files with 9 additions and 10 deletions

View file

@ -487,6 +487,8 @@ class PostUpdate
}
while ($item = DBA::fetch($items)) {
$id = $item['id'];
UserItem::setNotification($item['id']);
++$rows;

View file

@ -81,19 +81,19 @@ class UserItem
return;
}
if (self::checkImplicitMention($item, $uid, $profiles)) {
if (self::checkImplicitMention($item, $profiles)) {
$notification_type = $notification_type | self::NOTIF_IMPLICIT_TAGGED;
}
if (self::checkExplicitMention($item, $uid, $profiles)) {
if (self::checkExplicitMention($item, $profiles)) {
$notification_type = $notification_type | self::NOTIF_EXPLICIT_TAGGED;
}
if (self::checkCommentedThread($item, $uid, $contacts)) {
if (self::checkCommentedThread($item, $contacts)) {
$notification_type = $notification_type | self::NOTIF_THREAD_COMMENT;
}
if (self::checkDirectComment($item, $uid, $contacts, $thread)) {
if (self::checkDirectComment($item, $uid, $contacts)) {
$notification_type = $notification_type | self::NOTIF_DIRECT_COMMENT;
}
@ -198,10 +198,9 @@ class UserItem
/**
* Check for an implicit mention (only tag, no body) of the given user
* @param array $item
* @param int $uid User ID
* @return bool The user is mentioned
*/
private static function checkImplicitMention($item, $uid, $profiles)
private static function checkImplicitMention($item, $profiles)
{
foreach ($profiles AS $profile) {
if (strpos($item['tag'], '='.$profile.']') || strpos($item['body'], '='.$profile.']')) {
@ -217,10 +216,9 @@ class UserItem
/**
* Check for an explicit mention (tag and body) of the given user
* @param array $item
* @param int $uid User ID
* @return bool The user is mentioned
*/
private static function checkExplicitMention($item, $uid, $profiles)
private static function checkExplicitMention($item, $profiles)
{
foreach ($profiles AS $profile) {
if (strpos($item['tag'], '='.$profile.']') || strpos($item['body'], '='.$profile.']')) {
@ -236,10 +234,9 @@ class UserItem
/**
* Check if the given user had created this thread
* @param array $item
* @param int $uid User ID
* @return bool The user had created this thread
*/
private static function checkCommentedThread($item, $uid, $contacts)
private static function checkCommentedThread($item, $contacts)
{
$condition = ['parent' => $item['parent'], 'author-id' => $contacts, 'deleted' => false, 'gravity' => GRAVITY_PARENT];
return Item::exists($condition);