Made use of the new method "createOrIgnore"
authorMarcel Werk <burntime@woltlab.com>
Thu, 30 Jul 2020 16:05:18 +0000 (18:05 +0200)
committerMarcel Werk <burntime@woltlab.com>
Thu, 30 Jul 2020 16:05:18 +0000 (18:05 +0200)
wcfsetup/install/files/lib/data/user/follow/UserFollowAction.class.php
wcfsetup/install/files/lib/data/user/ignore/UserIgnoreAction.class.php

index 3021c05f141d2b9c0397a380937f936519c89739..79e77f72a8bca9e24129725ef0af9ba7bbb78256 100644 (file)
@@ -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',
index ea3f6a9a0ac4356132954fee2b55970d30240a16..6c741deea375ac9670d6d67156f1c0284c289af4 100644 (file)
@@ -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');