diff options
Diffstat (limited to 'app/services/users/activity_service.rb')
-rw-r--r-- | app/services/users/activity_service.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/app/services/users/activity_service.rb b/app/services/users/activity_service.rb new file mode 100644 index 00000000000..b81f947cd01 --- /dev/null +++ b/app/services/users/activity_service.rb @@ -0,0 +1,26 @@ +module Users + class ActivityService + def initialize(author, activity) + @author = author.respond_to?(:user) ? author.user : author + @activity = activity + end + + def execute + return unless @author && @author.is_a?(User) + + record_activity + end + + private + + def record_activity + user_activity.touch + + Rails.logger.debug("Recorded activity: #{@activity} for User ID: #{@author.id} (username: #{@author.username}") + end + + def user_activity + UserActivity.find_or_initialize_by(user: @author) + end + end +end |