2 namespace wcf\system\user\notification\event;
3 use wcf\data\user\follow\UserFollow;
4 use wcf\data\user\follow\UserFollowAction;
5 use wcf\data\user\UserProfile;
6 use wcf\system\request\LinkHandler;
7 use wcf\system\user\notification\object\IUserNotificationObject;
8 use wcf\system\user\notification\object\UserFollowUserNotificationObject;
11 * Notification event for followers.
13 * @author Alexander Ebert
14 * @copyright 2001-2019 WoltLab GmbH
15 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
16 * @package WoltLabSuite\Core\System\User\Notification\Event
18 * @method UserFollowUserNotificationObject getUserNotificationObject()
20 class UserFollowFollowingUserNotificationEvent extends AbstractUserNotificationEvent implements ITestableUserNotificationEvent {
21 use TTestableUserNotificationEvent;
26 protected $stackable = true;
31 public function getTitle() {
32 $count = count($this->getAuthors());
34 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.follow.title.stacked', ['count' => $count]);
37 return $this->getLanguage()->get('wcf.user.notification.follow.title');
43 public function getMessage() {
44 $authors = array_values($this->getAuthors());
45 $count = count($authors);
48 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.follow.message.stacked', [
49 'author' => $this->author,
50 'authors' => $authors,
52 'others' => $count - 1
56 return $this->getLanguage()->getDynamicVariable('wcf.user.notification.follow.message', ['author' => $this->author]);
62 public function getEmailMessage($notificationType = 'instant') {
64 'template' => 'email_notification_userFollowFollowing',
65 'application' => 'wcf'
72 public function getLink() {
73 return $this->author->getLink();
79 public function getEventHash() {
80 return sha1($this->eventID . '-' . $this->getUserNotificationObject()->followUserID);
85 * @return UserFollowUserNotificationObject[]
88 public static function getTestObjects(UserProfile $recipient, UserProfile $author) {
89 $follow = UserFollow::getFollow($recipient->userID, $author->userID);
90 if (!$follow->followID) {
91 $follow = (new UserFollowAction([], 'create', [
93 'userID' => $recipient->userID,
94 'followUserID' => $author->userID,
95 'time' => TIME_NOW - 60 * 60
97 ]))->executeAction()['returnValues'];
100 return [new UserFollowUserNotificationObject($follow)];
107 public static function getTestAdditionalData(IUserNotificationObject $object) {
108 /** @var UserFollowUserNotificationObject $object */
110 return [$object->followUserID];