]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/Email.php
Merge pull request #13646 from annando/page-drop
[friendica.git] / src / Protocol / Email.php
index 75845184492da2595553c5693de10928ad2f2882..35f5fdfdd40eed482afacbf7ac08419df4f4e11a 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2022, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -51,12 +51,12 @@ class Email
 
                $errors = imap_errors();
                if (!empty($errors)) {
-                       Logger::notice('IMAP Errors occured', ['errors' => $errors]);
+                       Logger::notice('IMAP Errors occurred', ['errors' => $errors]);
                }
 
                $alerts = imap_alerts();
                if (!empty($alerts)) {
-                       Logger::notice('IMAP Alerts occured: ', ['alerts' => $alerts]);
+                       Logger::notice('IMAP Alerts occurred: ', ['alerts' => $alerts]);
                }
 
                return $mbox;
@@ -78,21 +78,21 @@ class Email
                if (!$search1) {
                        $search1 = [];
                } else {
-                       Logger::notice("Found mails from ".$email_addr);
+                       Logger::debug("Found mails from ".$email_addr);
                }
 
                $search2 = @imap_search($mbox, 'UNDELETED TO "' . $email_addr . '"', SE_UID);
                if (!$search2) {
                        $search2 = [];
                } else {
-                       Logger::notice("Found mails to ".$email_addr);
+                       Logger::debug("Found mails to ".$email_addr);
                }
 
                $search3 = @imap_search($mbox, 'UNDELETED CC "' . $email_addr . '"', SE_UID);
                if (!$search3) {
                        $search3 = [];
                } else {
-                       Logger::notice("Found mails cc ".$email_addr);
+                       Logger::debug("Found mails cc ".$email_addr);
                }
 
                $res = array_unique(array_merge($search1, $search2, $search3));
@@ -115,13 +115,13 @@ class Email
        }
 
        /**
-        * @param Connection|resource $mbox mailbox
-        * @param integer             $uid  user id
+        * @param Connection|resource $mbox     mailbox
+        * @param string              $sequence
         * @return mixed
         */
-       public static function messageMeta($mbox, int $uid)
+       public static function messageMeta($mbox, string $sequence)
        {
-               $ret = (($mbox && $uid) ? @imap_fetch_overview($mbox, $uid, FT_UID) : [[]]); // POSSIBLE CLEANUP --> array(array()) is probably redundant now
+               $ret = (($mbox && $sequence) ? @imap_fetch_overview($mbox, $sequence, FT_UID) : [[]]); // POSSIBLE CLEANUP --> array(array()) is probably redundant now
                return (count($ret)) ? $ret : [];
        }
 
@@ -296,6 +296,7 @@ class Email
                        }
                        return $x;
                }
+               return '';
        }
 
        /**
@@ -321,7 +322,7 @@ class Email
                }
 
                if ($out_str && $charset) {
-                       // define start delimimter, end delimiter and spacer
+                       // define start delimiter, end delimiter and spacer
                        $end = "?=";
                        $start = "=?" . $charset . "?B?";
                        $spacer = $end . "\r\n " . $start;
@@ -569,9 +570,9 @@ class Email
         * Removes signature from message
         *
         * @param string $message Unfiltered message
-        * @return string Message with no signature
+        * @return array Message array with no signature (elements "body" and "sig")
         */
-       private static function removeSig(string $message): string
+       private static function removeSig(string $message): array
        {
                $sigpos = strrpos($message, "\n-- \n");
                $quotepos = strrpos($message, "[/quote]");
@@ -662,7 +663,7 @@ class Email
                return implode("\n", $lines);
        }
 
-       private static function convertQuote(strng $body, string $reply): string
+       private static function convertQuote(string $body, string $reply): string
        {
                // Convert Quotes
                $arrbody = explode("\n", trim($body));