}
@CheckForNull
private Notification createChangeNotification(DefaultIssue issue, IssueChangeContext context, @Nullable Rule rule, Component project,
@Nullable Component component, @Nullable String comment) {
Notification notification = null;
if (comment != null || issue.mustSendNotifications()) {
FieldDiffs currentChange = issue.currentChange();
notification = newNotification(project, "issue-changes");
notification.setFieldValue("key", issue.key());
notification.setFieldValue("changeAuthor", context.login());
notification.setFieldValue("reporter", issue.reporter());
notification.setFieldValue("assignee", issue.assignee());
notification.setFieldValue("message", issue.message());
notification.setFieldValue("ruleName", ruleName(rule));
notification.setFieldValue("componentKey", issue.componentKey());
if (component != null) {
notification.setFieldValue("componentName", component.longName());
}
if (comment != null) {
notification.setFieldValue("comment", comment);
}
if (currentChange != null) {
for (Map.Entry<String, FieldDiffs.Diff> entry : currentChange.diffs().entrySet()) {
String type = entry.getKey();
FieldDiffs.Diff diff = entry.getValue();
Serializable newValue = diff.newValue();
Serializable oldValue = diff.oldValue();
notification.setFieldValue("old." + type, oldValue != null ? oldValue.toString() : null);
notification.setFieldValue("new." + type, newValue != null ? newValue.toString() : null);
}
}
}
return notification;
}