From: Marcel Werk Date: Thu, 30 Jul 2020 16:05:18 +0000 (+0200) Subject: Made use of the new method "createOrIgnore" X-Git-Tag: 5.3.0_Alpha_1~113 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=2b5a55bfbadd3a3c58b7711cc930408b0bf6a719;p=GitHub%2FWoltLab%2FWCF.git Made use of the new method "createOrIgnore" --- diff --git a/wcfsetup/install/files/lib/data/user/follow/UserFollowAction.class.php b/wcfsetup/install/files/lib/data/user/follow/UserFollowAction.class.php index 3021c05f14..79e77f72a8 100644 --- a/wcfsetup/install/files/lib/data/user/follow/UserFollowAction.class.php +++ b/wcfsetup/install/files/lib/data/user/follow/UserFollowAction.class.php @@ -70,16 +70,14 @@ class UserFollowAction extends AbstractDatabaseObjectAction implements IGroupedU * @return array */ public function follow() { - $follow = UserFollow::getFollow(WCF::getUser()->userID, $this->parameters['data']['userID']); + /** @var UserFollow $follow */ + $follow = UserFollowEditor::createOrIgnore([ + 'userID' => WCF::getUser()->userID, + 'followUserID' => $this->parameters['data']['userID'], + 'time' => TIME_NOW, + ]); - // not following right now - if (!$follow->followID) { - $follow = UserFollowEditor::create([ - 'userID' => WCF::getUser()->userID, - 'followUserID' => $this->parameters['data']['userID'], - 'time' => TIME_NOW - ]); - + if ($follow !== null) { // send notification UserNotificationHandler::getInstance()->fireEvent( 'following', diff --git a/wcfsetup/install/files/lib/data/user/ignore/UserIgnoreAction.class.php b/wcfsetup/install/files/lib/data/user/ignore/UserIgnoreAction.class.php index ea3f6a9a0a..6c741deea3 100644 --- a/wcfsetup/install/files/lib/data/user/ignore/UserIgnoreAction.class.php +++ b/wcfsetup/install/files/lib/data/user/ignore/UserIgnoreAction.class.php @@ -46,15 +46,14 @@ class UserIgnoreAction extends AbstractDatabaseObjectAction { * @return array */ public function ignore() { - $ignore = UserIgnore::getIgnore($this->parameters['data']['userID']); + /** @var UserIgnore $ignore */ + $ignore = UserIgnoreEditor::createOrIgnore([ + 'ignoreUserID' => $this->parameters['data']['userID'], + 'time' => TIME_NOW, + 'userID' => WCF::getUser()->userID, + ]); - if (!$ignore->ignoreID) { - UserIgnoreEditor::create([ - 'ignoreUserID' => $this->parameters['data']['userID'], - 'time' => TIME_NOW, - 'userID' => WCF::getUser()->userID - ]); - + if ($ignore !== null) { UserStorageHandler::getInstance()->reset([WCF::getUser()->userID], 'ignoredUserIDs'); UserStorageHandler::getInstance()->reset([$this->parameters['data']['userID']], 'ignoredByUserIDs');