From 2951a8543ef97ceb1bcaca5f5140d822729c950b Mon Sep 17 00:00:00 2001 From: James Lopez Date: Wed, 5 Oct 2016 16:41:32 +0200 Subject: Add user activity service and spec. Also added relevant - NOT offline - migration It uses a user activity table instead of a column in users. Tested with mySQL and postgreSQL --- lib/api/internal.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'lib/api/internal.rb') diff --git a/lib/api/internal.rb b/lib/api/internal.rb index 215bc03d0e9..d374d183dcd 100644 --- a/lib/api/internal.rb +++ b/lib/api/internal.rb @@ -15,6 +15,16 @@ module API # project - project path with namespace # action - git action (git-upload-pack or git-receive-pack) # changes - changes as "oldrev newrev ref", see Gitlab::ChangesList + helpers do + def log_user_activity(actor) + commands = Gitlab::GitAccess::DOWNLOAD_COMMANDS + + Gitlab::GitAccess::PUSH_COMMANDS + + Gitlab::GitAccess::GIT_ANNEX_COMMANDS + + ::Users::ActivityService.new(actor, 'Git SSH').execute if commands.include?(params[:action]) + end + end + post "/allowed" do status 200 @@ -40,6 +50,8 @@ module API response = { status: access_status.status, message: access_status.message } if access_status.status + log_user_activity(actor) + # Return the repository full path so that gitlab-shell has it when # handling ssh commands response[:repository_path] = -- cgit v1.2.1