3 * @copyright Copyright (C) 2020, Friendica
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\Object\Email;
30 use Friendica\Protocol\Email as EmailProtocol;
33 * Class for creating CC emails based on a received item
35 class ItemCCEMail extends Email
37 public function __construct(App $a, L10n $l10n, BaseURL $baseUrl, array $item, string $toAddress, string $authorThumb)
39 $disclaimer = '<hr />' . $l10n->t('This message was sent to you by %s, a member of the Friendica social network.', $a->user['username'])
41 $disclaimer .= $l10n->t('You may visit them online at %s', $baseUrl . '/profile/' . $a->user['nickname']) . EOL;
42 $disclaimer .= $l10n->t('Please contact the sender by replying to this post if you do not wish to receive these messages.') . EOL;
43 if (!$item['title'] == '') {
44 $subject = EmailProtocol::encodeHeader($item['title'], 'UTF-8');
46 $subject = EmailProtocol::encodeHeader('[Friendica]' . ' ' . $l10n->t('%s posted an update.', $a->user['username']), 'UTF-8');
48 $link = '<a href="' . $baseUrl . '/profile/' . $a->user['nickname'] . '"><img src="' . $authorThumb . '" alt="' . $a->user['username'] . '" /></a><br /><br />';
49 $html = Item::prepareBody($item);
50 $message = '<html><body>' . $link . $html . $disclaimer . '</body></html>';;
52 parent::__construct($a->user['username'], $a->user['email'], $a->user['email'], $toAddress,
53 $subject, $message, HTML::toPlaintext($html . $disclaimer));