Skip to content

ChatOps calls should record user activity

James Nutt requested to merge jnutt/chatops-user-activity into master

What does this MR do and why?

ChatOps calls should record user activity as per #413368 (closed)

This MR triggers the user activity service at the same time as updating the usage timestamp on the ChatName record. There were some suggestions1 about where to place this call, but I selected the FindUserService for the following reasons:

  1. It makes sense to me to mark activity on the ChatName and the user in the same place.
  2. Rubocop was nudging me away from calling a service from a model, and the service -> service call satisfies the code re-use guidelines2.

Changelog: fixed

How to set up and validate locally

  1. Create a chat name for a user that has no recent activity in GDK's Rails console:

    user = User.first
    user.chat_names.create(chat_id: 1, team_id: 1)
  2. Set up a Slack command integration in one of your projects and copy the hook URL.

  3. In your terminal:

    curl --request POST --header "PRIVATE-TOKEN: <your-pat-here>" \
      --url "http://localhost:3000/api/v4/projects/7/integrations/slack_slash_commands/trigger?token=<your-token>&team_id=1&user_id=1"
  4. Verify that User#last_activity_on has been updated.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

  1. #413368 (closed)

  2. https://docs.gitlab.com/ee/development/reusing_abstractions.html

Edited by James Nutt

Merge request reports

Loading