mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-03 03:40:49 +08:00
init project
This commit is contained in:
42
app/controllers/watchers_controller.rb
Normal file
42
app/controllers/watchers_controller.rb
Normal file
@@ -0,0 +1,42 @@
|
||||
class WatchersController < ApplicationController
|
||||
before_action :require_login, except: %i[index]
|
||||
before_action :find_project_with_id
|
||||
|
||||
def index
|
||||
scope = @project.watchers.includes(:user)
|
||||
@watchers = paginate(scope)
|
||||
end
|
||||
|
||||
def unfollow
|
||||
begin
|
||||
return normal_status(2, "你还没有关注哦") unless current_user.watched?(@project)
|
||||
current_user.unwatch!(@project)
|
||||
render_ok
|
||||
rescue Exception => e
|
||||
uid_logger_error(e.message)
|
||||
tip_exception(e.message)
|
||||
raise ActiveRecord::Rollback
|
||||
end
|
||||
end
|
||||
|
||||
def follow
|
||||
begin
|
||||
return normal_status(2, "你已关注了") if current_user.watched?(@project)
|
||||
current_user.watch!(@project)
|
||||
render_ok
|
||||
rescue Exception => e
|
||||
uid_logger_error(e.message)
|
||||
tip_exception(e.message)
|
||||
raise ActiveRecord::Rollback
|
||||
end
|
||||
end
|
||||
|
||||
def check_watch
|
||||
is_watch = current_user.watched?(@project)
|
||||
render_result(is_watch ? 1 : 0)
|
||||
rescue Exception => e
|
||||
uid_logger_error(e.message)
|
||||
tip_exception(e.message)
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user