d13669716a
In GitLab EE, a GitLab instance can be read-only (e.g. when it's a Geo secondary node). But in GitLab CE it also might be useful to have the "read-only" idea around. So port it back to GitLab CE. Also having the principle of read-only in GitLab CE would hopefully lead to less errors introduced, doing write operations when there aren't allowed for read-only calls. Closes gitlab-org/gitlab-ce#37534.
22 lines
529 B
Ruby
22 lines
529 B
Ruby
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
|
|
Gitlab::UserActivities.record(@author.id) if Gitlab::Database.read_write?
|
|
|
|
Rails.logger.debug("Recorded activity: #{@activity} for User ID: #{@author.id} (username: #{@author.username})")
|
|
end
|
|
end
|
|
end
|