Skip to content

Refactor User#follow into a service

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Why are we doing this work

As a follow-up for !97349 (comment 1104027190) and !97349 (comment 1104027193), we should refactor User#follow into a service. There are multiple benefits for this:

  1. We have more flexibility with error handling, as we no longer have to rely on ActiveModel#errors to hold error messages.
  2. We can associate an HTTP status code with each error
  3. We have better separation of concerns as we User shouldn't be concerned with creating UserFollowUser records

Implementation plan

  1. Create app/services/users/follow_service.rb
  2. Move the logic from User#follow into this service
  3. Delete User#follow
  4. Replace usages of User#follow with Users::FollowService
Edited by 🤖 GitLab Bot 🤖