3 * @copyright Copyright (C) 2010-2023, 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\Navigation\Notifications\Entity;
25 use Friendica\BaseEntity;
26 use Friendica\Content\Text\BBCode;
27 use Friendica\Core\Renderer;
28 use Psr\Http\Message\UriInterface;
31 * @property-read $type
32 * @property-read $name
34 * @property-read $photo
35 * @property-read $date
38 * @property-read $link
39 * @property-read $itemId
40 * @property-read $parent
41 * @property-read $seen
42 * @property-read $verb
43 * @property-read $otype
44 * @property-read $name_cache
45 * @property-read $msg_cache
46 * @property-read $uriId
47 * @property-read $parentUriId
50 * @deprecated since 2022.05 Use \Friendica\Navigation\Notifications\Entity\Notification instead
52 class Notify extends BaseEntity
58 /** @var UriInterface */
60 /** @var UriInterface */
68 /** @var UriInterface */
81 protected $name_cache;
87 protected $parentUriId;
91 public function __construct(int $type, string $name, UriInterface $url, UriInterface $photo, DateTime $date, int $uid, UriInterface $link, bool $seen, string $verb, string $otype, string $name_cache, string $msg = null, string $msg_cache = null, int $itemId = null, int $uriId = null, int $parent = null, ?int $parentUriId = null, ?int $id = null)
96 $this->photo = $photo;
101 $this->itemId = $itemId;
102 $this->parent = $parent;
105 $this->otype = $otype;
106 $this->name_cache = $name_cache;
107 $this->msg_cache = $msg_cache;
108 $this->uriId = $uriId;
109 $this->parentUriId = $parentUriId;
113 public function setSeen()
118 public function updateMsgFromPreamble($epreamble)
120 $this->msg = Renderer::replaceMacros($epreamble, ['$itemlink' => $this->link->__toString()]);
121 $this->msg_cache = self::formatMessage($this->name_cache, strip_tags(BBCode::convert($this->msg)));
125 * Formats a notification message with the notification author
127 * Replace the name with {0} but ensure to make that only once. The {0} is used
128 * later and prints the name in bold.
130 * @param string $name
131 * @param string $message
133 * @return string Formatted message
135 public static function formatMessage(string $name, string $message): string
137 return str_replace('{0}', '<span class="contactname">' . strip_tags(BBCode::convert($name)) . '</span>', $message);