FEATURE: Introduce Ignore user (#7072)

This commit is contained in:
Tarek Khalil
2019-02-27 13:49:07 +00:00
committed by Régis Hanol
parent 5c476f639c
commit 986cc8a0fb
16 changed files with 233 additions and 25 deletions

View File

@ -14,7 +14,7 @@ class UsersController < ApplicationController
:pick_avatar, :destroy_user_image, :destroy, :check_emails,
:topic_tracking_state, :preferences, :create_second_factor,
:update_second_factor, :create_second_factor_backup, :select_avatar,
:revoke_auth_token
:ignore, :watch, :revoke_auth_token
]
skip_before_action :check_xhr, only: [
@ -995,6 +995,22 @@ class UsersController < ApplicationController
render json: success_json
end
def ignore
raise Discourse::NotFound unless SiteSetting.ignore_user_enabled
::IgnoredUser.find_or_create_by!(
user: current_user,
ignored_user_id: params[:ignored_user_id])
render json: success_json
end
def watch
raise Discourse::NotFound unless SiteSetting.ignore_user_enabled
IgnoredUser.where(user: current_user, ignored_user_id: params[:ignored_user_id]).delete_all
render json: success_json
end
def read_faq
if user = current_user
user.user_stat.read_faq = 1.second.ago