]> git.mxchange.org Git - friendica.git/blobdiff - include/enotify.php
Merge pull request #7078 from nupplaphil/task/mod_fetch
[friendica.git] / include / enotify.php
index f725511f5eee273cc72849e17afbc530ad09d784..becf672b2aaa4cddae79f208d963f9901c099990 100644 (file)
@@ -11,8 +11,8 @@ use Friendica\Core\Logger;
 use Friendica\Core\Renderer;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
-use Friendica\Model\Contact;
 use Friendica\Model\Item;
+use Friendica\Model\User;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Emailer;
 use Friendica\Util\Strings;
@@ -33,8 +33,8 @@ function notification($params)
        $a = \get_app();
 
        // Temporary logging for finding the origin
-       if (!isset($params['language']) || !isset($params['uid'])) {
-               Logger::log('Missing parameters.' . System::callstack());
+       if (!isset($params['uid'])) {
+               Logger::notice('Missing parameters "uid".', ['params' => $params, 'callstack' => System::callstack()]);
        }
 
        // Ensure that the important fields are set at any time
@@ -42,7 +42,7 @@ function notification($params)
        $user = DBA::selectFirst('user', $fields, ['uid' => $params['uid']]);
 
        if (!DBA::isResult($user)) {
-               Logger::log('Unknown user ' . $params['uid']);
+               Logger::error('Unknown user', ['uid' =>  $params['uid']]);
                return false;
        }
 
@@ -453,11 +453,20 @@ function notification($params)
                // It will be used by the system to send emails to users (like
                // password reset, invitations and so) using one look (but without
                // add a notification to the user, with could be inexistent)
-               $subject = $params['subject'];
+               if (!isset($params['subject'])) {
+                       Logger::warning('subject isn\'t set.', ['type' => $params['type']]);
+               }
+               $subject = defaults($params, 'subject', '');
 
-               $preamble = $params['preamble'];
+               if (!isset($params['preamble'])) {
+                       Logger::warning('preamble isn\'t set.', ['type' => $params['type'], 'subject' => $subject]);
+               }
+               $preamble = defaults($params, 'preamble', '');
 
-               $body =  $params['body'];
+               if (!isset($params['body'])) {
+                       Logger::warning('body isn\'t set.', ['type' => $params['type'], 'subject' => $subject, 'preamble' => $preamble]);
+               }
+               $body = defaults($params, 'body', '');
 
                $show_in_notification_page = false;
        }
@@ -775,7 +784,7 @@ function check_item_notification($itemid, $uid, $defaulttype = "") {
                'author-link', 'author-name', 'author-avatar', 'author-id',
                'guid', 'parent-uri', 'uri', 'contact-id', 'network'];
        $condition = ['id' => $itemid, 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]];
-       $item = Item::selectFirst($fields, $condition);
+       $item = Item::selectFirstForUser($uid, $fields, $condition);
        if (!DBA::isResult($item) || in_array($item['author-id'], $contacts)) {
                return false;
        }