Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions lib/redmine_issue_assign_notice/issue_hook_listener.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,15 @@ def redmine_issue_assign_notice_change(context={})

private

def notice(issue, old_assgined_to, new_assgined_to, note, author)
def notice(issue, old_assgined_to, new_assgined_to, note, author, group_name = nil)

if new_assgined_to.is_a?(Group)
new_assgined_to.users.each do |user|
notice(issue, old_assgined_to, user, note, author, new_assgined_to)
end
return
end

if Setting.plugin_redmine_issue_assign_notice['notice_url_each_project'] == '1'
notice_url_field = issue.project.custom_field_values.find{ |field| field.custom_field.name == 'Assign Notice URL' }
notice_url = notice_url_field.value unless notice_url_field.nil?
Expand All @@ -55,7 +62,7 @@ def notice(issue, old_assgined_to, new_assgined_to, note, author)

message_creator = MessageCreator.from(notice_url)

message = message_creator.create(issue, old_assgined_to, new_assgined_to, note, author)
message = message_creator.create(issue, old_assgined_to, new_assgined_to, note, author, group_name)

Rails.logger.debug "[RedmineIssueAssignNotice] IssueHookListener#notice message:#{message}"

Expand Down
18 changes: 14 additions & 4 deletions lib/redmine_issue_assign_notice/message_creator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def initialize(formatter)
@formatter = formatter
end

def create(issue, old_assgined_to, new_assgined_to, note, author)
def create(issue, old_assgined_to, new_assgined_to, note, author, group_name = nil)

text = ""

Expand All @@ -33,8 +33,13 @@ def create(issue, old_assgined_to, new_assgined_to, note, author)
text << @formatter.mention(mention_id)
text << " "
end

if group_name.nil?
text << "Assign changed from #{@formatter.user_name old_assgined_to} to #{@formatter.user_name new_assgined_to}"
else
text << "Assign changed from #{@formatter.user_name old_assgined_to} to #{group_name}"
end

text << "Assign changed from #{@formatter.user_name old_assgined_to} to #{@formatter.user_name new_assgined_to}"
text << @formatter.change_line
text << "[#{@formatter.escape issue.project}] "
text << @formatter.link("#{issue.tracker} ##{issue.id}", MessageHelper.issue_url(issue))
Expand All @@ -51,7 +56,7 @@ def initialize()
@formatter = Formatter::Teams.new
end

def create(issue, old_assgined_to, new_assgined_to, note, author)
def create(issue, old_assgined_to, new_assgined_to, note, author, group_name = nil)

text = ""

Expand All @@ -61,7 +66,12 @@ def create(issue, old_assgined_to, new_assgined_to, note, author)
text << mention_part + " "
end

text << "Assign changed from #{@formatter.user_name old_assgined_to} to #{@formatter.user_name new_assgined_to}"
if group_name.nil?
text << "Assign changed from #{@formatter.user_name old_assgined_to} to #{@formatter.user_name new_assgined_to}"
else
text << "Assign changed from #{@formatter.user_name old_assgined_to} to #{group_name}"
end

text << @formatter.change_line
text << "[#{@formatter.escape issue.project}] "
text << @formatter.link("#{issue.tracker} ##{issue.id}", MessageHelper.issue_url(issue))
Expand Down