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:
- We have more flexibility with error handling, as we no longer have to rely on
ActiveModel#errorsto hold error messages. - We can associate an HTTP status code with each error
- We have better separation of concerns as we
Usershouldn't be concerned with creatingUserFollowUserrecords
Implementation plan
- Create
app/services/users/follow_service.rb - Move the logic from
User#followinto this service - Delete
User#follow - Replace usages of
User#followwithUsers::FollowService
Edited by 🤖 GitLab Bot 🤖