Skip to content

Commit e2c0657

Browse files
BurntimeXdtdesign
authored andcommitted
Move Unfollow command
1 parent 844698d commit e2c0657

File tree

4 files changed

+17
-38
lines changed

4 files changed

+17
-38
lines changed

wcfsetup/install/files/lib/action/UserFollowAction.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use wcf\system\exception\IllegalLinkException;
1313
use wcf\system\exception\PermissionDeniedException;
1414
use wcf\command\user\Follow;
15-
use wcf\system\user\command\Unfollow;
15+
use wcf\command\user\Unfollow;
1616
use wcf\system\WCF;
1717

1818
/**

wcfsetup/install/files/lib/command/user/Unfollow.class.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace wcf\system\user\command;
3+
namespace wcf\command\user;
44

55
use wcf\data\user\follow\UserFollow;
66
use wcf\data\user\follow\UserFollowEditor;
@@ -14,13 +14,14 @@
1414
* @author Marcel Werk
1515
* @copyright 2001-2024 WoltLab GmbH
1616
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
17-
* @since 6.1
17+
* @since 6.2
1818
*/
1919
final class Unfollow
2020
{
21-
public function __construct(private readonly User $user, private readonly User $target)
22-
{
23-
}
21+
public function __construct(
22+
private readonly User $user,
23+
private readonly User $target
24+
) {}
2425

2526
public function __invoke(): void
2627
{

wcfsetup/install/files/lib/data/user/follow/UserFollowAction.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use wcf\system\exception\UserInputException;
1212
use wcf\system\user\activity\event\UserActivityEventHandler;
1313
use wcf\command\user\Follow;
14-
use wcf\system\user\command\Unfollow;
14+
use wcf\command\user\Unfollow;
1515
use wcf\system\user\GroupedUserList;
1616
use wcf\system\user\storage\UserStorageHandler;
1717
use wcf\system\WCF;

wcfsetup/install/files/lib/system/user/command/Unfollow.class.php

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22

33
namespace wcf\system\user\command;
44

5-
use wcf\data\user\follow\UserFollow;
6-
use wcf\data\user\follow\UserFollowEditor;
75
use wcf\data\user\User;
8-
use wcf\system\user\activity\event\UserActivityEventHandler;
9-
use wcf\system\user\storage\UserStorageHandler;
106

117
/**
128
* Saves that a user is unfollowing another user.
@@ -15,38 +11,20 @@
1511
* @copyright 2001-2024 WoltLab GmbH
1612
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
1713
* @since 6.1
14+
* @deprecated 6.2 Use `\wcf\command\user\Unfollow` instead.
1815
*/
1916
final class Unfollow
2017
{
21-
public function __construct(private readonly User $user, private readonly User $target)
22-
{
23-
}
18+
public function __construct(
19+
private readonly User $user,
20+
private readonly User $target
21+
) {}
2422

2523
public function __invoke(): void
2624
{
27-
$follow = UserFollow::getFollow($this->user->userID, $this->target->userID);
28-
29-
if ($follow->followID) {
30-
$followEditor = new UserFollowEditor($follow);
31-
$followEditor->delete();
32-
33-
$this->removeActivityEvent();
34-
}
35-
36-
$this->resetUserStorage();
37-
}
38-
39-
private function removeActivityEvent(): void
40-
{
41-
UserActivityEventHandler::getInstance()->removeEvent(
42-
'com.woltlab.wcf.user.recentActivityEvent.follow',
43-
$this->target->userID
44-
);
45-
}
46-
47-
private function resetUserStorage(): void
48-
{
49-
UserStorageHandler::getInstance()->reset([$this->target->userID], 'followerUserIDs');
50-
UserStorageHandler::getInstance()->reset([$this->user->userID], 'followingUserIDs');
25+
(new \wcf\command\user\Unfollow(
26+
$this->user,
27+
$this->target
28+
))();
5129
}
5230
}

0 commit comments

Comments
 (0)