]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Mail.php
Merge pull request #8265 from nupplaphil/task/add_license
[friendica.git] / src / Model / Mail.php
index eeea130a60b8ca16e2c0c36fcf3694d6eb5d102c..c0efe4f2334138f60cb3e118b64141588342c923 100644 (file)
@@ -1,18 +1,32 @@
 <?php
-
 /**
- * @file src/Model/Mail.php
+ * @copyright Copyright (C) 2020, Friendica
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ *
  */
+
 namespace Friendica\Model;
 
-use Friendica\Core\L10n;
 use Friendica\Core\Logger;
 use Friendica\Core\System;
 use Friendica\Core\Worker;
 use Friendica\DI;
-use Friendica\Model\Item;
-use Friendica\Model\Photo;
 use Friendica\Database\DBA;
+use Friendica\Model\Notify\Type;
 use Friendica\Network\Probe;
 use Friendica\Protocol\Activity;
 use Friendica\Util\DateTimeFormat;
@@ -71,7 +85,7 @@ class Mail
 
                // send notifications.
                $notif_params = [
-                       'type' => NOTIFY_MAIL,
+                       'type' => Type::MAIL,
                        'notify_flags' => $user['notify-flags'],
                        'language' => $user['language'],
                        'to_name' => $user['username'],
@@ -112,7 +126,7 @@ class Mail
                }
 
                if (!strlen($subject)) {
-                       $subject = L10n::t('[no subject]');
+                       $subject = DI::l10n()->t('[no subject]');
                }
 
                $me = DBA::selectFirst('contact', [], ['uid' => local_user(), 'self' => true]);
@@ -215,12 +229,10 @@ class Mail
                        $images = $match[1];
                        if (count($images)) {
                                foreach ($images as $image) {
-                                       if (!stristr($image, DI::baseUrl() . '/photo/')) {
-                                               continue;
+                                       $image_rid = Photo::ridFromURI($image);
+                                       if (!empty($image_rid)) {
+                                               Photo::update(['allow-cid' => '<' . $recipient . '>'], ['resource-id' => $image_rid, 'album' => 'Wall Photos', 'uid' => local_user()]);
                                        }
-                                       $image_uri = substr($image, strrpos($image, '/') + 1);
-                                       $image_uri = substr($image_uri, 0, strpos($image_uri, '-'));
-                                       Photo::update(['allow-cid' => '<' . $recipient . '>'], ['resource-id' => $image_uri, 'album' => 'Wall Photos', 'uid' => local_user()]);
                                }
                        }
                }
@@ -249,7 +261,7 @@ class Mail
                }
 
                if (!strlen($subject)) {
-                       $subject = L10n::t('[no subject]');
+                       $subject = DI::l10n()->t('[no subject]');
                }
 
                $guid = System::createUUID();