3 * @copyright Copyright (C) 2010-2022, the Friendica project
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 namespace Friendica\Object\EMail;
25 use Friendica\App\BaseURL;
26 use Friendica\Content\Text\HTML;
27 use Friendica\Core\L10n;
28 use Friendica\Model\Item;
29 use Friendica\Model\User;
30 use Friendica\Object\Email;
31 use Friendica\Protocol\Email as EmailProtocol;
34 * Class for creating CC emails based on a received item
36 class ItemCCEMail extends Email
38 public function __construct(App $a, L10n $l10n, BaseURL $baseUrl, array $item, string $toAddress, string $authorThumb)
40 $user = User::getById($a->getLoggedInUserId());
42 $disclaimer = '<hr />' . $l10n->t('This message was sent to you by %s, a member of the Friendica social network.', $user['username'])
44 $disclaimer .= $l10n->t('You may visit them online at %s', $baseUrl . '/profile/' . $a->getLoggedInUserNickname()) . EOL;
45 $disclaimer .= $l10n->t('Please contact the sender by replying to this post if you do not wish to receive these messages.') . EOL;
46 if (!$item['title'] == '') {
47 $subject = $item['title'];
49 $subject = '[Friendica]' . ' ' . $l10n->t('%s posted an update.', $user['username']);
51 $link = '<a href="' . $baseUrl . '/profile/' . $a->getLoggedInUserNickname() . '"><img src="' . $authorThumb . '" alt="' . $user['username'] . '" /></a><br /><br />';
52 $html = Item::prepareBody($item);
53 $message = '<html><body>' . $link . $html . $disclaimer . '</body></html>';;
55 parent::__construct($user['username'], $user['email'], $user['email'], $toAddress,
56 $subject, $message, HTML::toPlaintext($html . $disclaimer));