gitlabhq/app/observers/activity_observer.rb

35 lines
907 B
Ruby
Raw Normal View History

class ActivityObserver < ActiveRecord::Observer
observe :issue, :merge_request, :note, :milestone
def after_create(record)
event_author_id = record.author_id
# Skip status notes
if record.kind_of?(Note) && record.note.include?("_Status changed to ")
return true
end
if event_author_id
Event.create(
project: record.project,
target_id: record.id,
target_type: record.class.name,
action: Event.determine_action(record),
author_id: event_author_id
)
end
end
def after_save(record)
if record.changed.include?("closed") && record.author_id_of_changes
Event.create(
project: record.project,
target_id: record.id,
target_type: record.class.name,
2013-02-13 12:48:16 +01:00
action: (record.closed ? Event::CLOSED : Event::REOPENED),
author_id: record.author_id_of_changes
)
end
end
end