* @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',
* @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');