2013-06-27 15:37:41 +01:00
|
|
|
# -*- encoding : utf-8 -*-
|
|
|
|
module Modules::Observers::ActivityFeed::BuildList
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
included do
|
|
|
|
after_update :build_list_notifications
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def build_list_notifications
|
|
|
|
if mass_build.blank? && ( # Do not show mass build activity in activity feeds
|
|
|
|
status_changed? && [
|
2013-06-27 16:00:56 +01:00
|
|
|
BuildList::BUILD_PUBLISHED,
|
|
|
|
BuildList::SUCCESS,
|
|
|
|
BuildList::BUILD_ERROR,
|
|
|
|
BuildList::FAILED_PUBLISH,
|
|
|
|
BuildList::TESTS_FAILED
|
2013-06-27 15:37:41 +01:00
|
|
|
].include?(status) ||
|
2013-07-01 13:20:38 +01:00
|
|
|
status == BuildList::BUILD_PENDING
|
2013-06-27 15:37:41 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
updater = publisher || user
|
|
|
|
project.admins.each do |recipient|
|
|
|
|
ActivityFeed.create(
|
|
|
|
:user => recipient,
|
|
|
|
:kind => 'build_list_notification',
|
|
|
|
:data => {
|
2013-07-01 13:20:38 +01:00
|
|
|
:task_num => id,
|
2013-06-27 15:37:41 +01:00
|
|
|
:build_list_id => id,
|
|
|
|
:status => status,
|
|
|
|
:updated_at => updated_at,
|
|
|
|
:project_id => project_id,
|
|
|
|
:project_name => project.name,
|
|
|
|
:project_owner => project.owner.uname,
|
|
|
|
:user_name => updater.name,
|
|
|
|
:user_email => updater.email,
|
|
|
|
:user_id => updater.id
|
|
|
|
}
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|