Skip to content

Commit e441911

Browse files
committed
Add missing events for user commands
1 parent b76f959 commit e441911

File tree

8 files changed

+106
-0
lines changed

8 files changed

+106
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
use wcf\data\user\follow\UserFollow;
66
use wcf\data\user\follow\UserFollowEditor;
77
use wcf\data\user\User;
8+
use wcf\event\user\UserFollowed;
9+
use wcf\system\event\EventHandler;
810
use wcf\system\user\activity\event\UserActivityEventHandler;
911
use wcf\system\user\notification\object\UserFollowUserNotificationObject;
1012
use wcf\system\user\notification\UserNotificationHandler;
@@ -40,6 +42,8 @@ public function __invoke(): void
4042
$this->sendNotification($follow);
4143
$this->fireActivityEvent();
4244
$this->resetUserStorage();
45+
46+
EventHandler::getInstance()->fire(new UserFollowed($this->user, $this->target));
4347
}
4448

4549
private function sendNotification(UserFollow $follow): void

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
use wcf\data\file\FileAction;
77
use wcf\data\user\User;
88
use wcf\data\user\UserEditor;
9+
use wcf\event\user\AvatarChanged;
910
use wcf\system\cache\runtime\UserProfileRuntimeCache;
11+
use wcf\system\event\EventHandler;
1012
use wcf\system\user\group\assignment\UserGroupAssignmentHandler;
1113
use wcf\system\user\storage\UserStorageHandler;
1214
use wcf\system\user\UserProfileHandler;
@@ -54,5 +56,7 @@ public function __invoke(): void
5456
if ($this->user->userID === WCF::getUser()->userID) {
5557
UserProfileHandler::getInstance()->reloadUserProfile();
5658
}
59+
60+
EventHandler::getInstance()->fire(new AvatarChanged($this->user, $this->file));
5761
}
5862
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
use wcf\data\file\FileAction;
77
use wcf\data\user\User;
88
use wcf\data\user\UserEditor;
9+
use wcf\event\user\CoverPhotoChanged;
910
use wcf\system\cache\runtime\UserProfileRuntimeCache;
11+
use wcf\system\event\EventHandler;
1012

1113
/**
1214
* Sets the cover photo of a user.
@@ -36,5 +38,7 @@ public function __invoke(): void
3638
'coverPhotoHasWebP' => 0,
3739
]);
3840
UserProfileRuntimeCache::getInstance()->removeObject($this->user->userID);
41+
42+
EventHandler::getInstance()->fire(new CoverPhotoChanged($this->user, $this->file));
3943
}
4044
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
use wcf\data\user\follow\UserFollow;
66
use wcf\data\user\follow\UserFollowEditor;
77
use wcf\data\user\User;
8+
use wcf\event\user\UserUnfollowed;
9+
use wcf\system\event\EventHandler;
810
use wcf\system\user\activity\event\UserActivityEventHandler;
911
use wcf\system\user\storage\UserStorageHandler;
1012

@@ -35,6 +37,8 @@ public function __invoke(): void
3537
}
3638

3739
$this->resetUserStorage();
40+
41+
EventHandler::getInstance()->fire(new UserUnfollowed($this->user, $this->target));
3842
}
3943

4044
private function removeActivityEvent(): void
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace wcf\event\user;
4+
5+
use wcf\data\file\File;
6+
use wcf\data\user\User;
7+
use wcf\event\IPsr14Event;
8+
9+
/**
10+
* Indicates that the avatar of a user has been changed.
11+
*
12+
* @author Marcel Werk
13+
* @copyright 2001-2025 WoltLab GmbH
14+
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
15+
* @since 6.2
16+
*/
17+
final class AvatarChanged implements IPsr14Event
18+
{
19+
public function __construct(
20+
public readonly User $user,
21+
public readonly ?File $file
22+
) {}
23+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace wcf\event\user;
4+
5+
use wcf\data\file\File;
6+
use wcf\data\user\User;
7+
use wcf\event\IPsr14Event;
8+
9+
/**
10+
* Indicates that the cover photo of a user has been changed.
11+
*
12+
* @author Marcel Werk
13+
* @copyright 2001-2025 WoltLab GmbH
14+
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
15+
* @since 6.2
16+
*/
17+
final class CoverPhotoChanged implements IPsr14Event
18+
{
19+
public function __construct(
20+
public readonly User $user,
21+
public readonly ?File $file
22+
) {}
23+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace wcf\event\user;
4+
5+
use wcf\data\user\User;
6+
use wcf\event\IPsr14Event;
7+
8+
/**
9+
* Indicates that a user is following another user.
10+
*
11+
* @author Marcel Werk
12+
* @copyright 2001-2025 WoltLab GmbH
13+
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
14+
* @since 6.2
15+
*/
16+
final class UserFollowed implements IPsr14Event
17+
{
18+
public function __construct(
19+
public readonly User $user,
20+
public readonly User $target
21+
) {}
22+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace wcf\event\user;
4+
5+
use wcf\data\user\User;
6+
use wcf\event\IPsr14Event;
7+
8+
/**
9+
* Indicates that a user is unfollowing another user.
10+
*
11+
* @author Marcel Werk
12+
* @copyright 2001-2025 WoltLab GmbH
13+
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
14+
* @since 6.2
15+
*/
16+
final class UserUnfollowed implements IPsr14Event
17+
{
18+
public function __construct(
19+
public readonly User $user,
20+
public readonly User $target
21+
) {}
22+
}

0 commit comments

Comments
 (0)