diff --git a/app/models/NotificationEvent.java b/app/models/NotificationEvent.java index a82be3d0e..ea6efba5f 100644 --- a/app/models/NotificationEvent.java +++ b/app/models/NotificationEvent.java @@ -527,6 +527,7 @@ public static NotificationEvent afterNewPullRequest(User sender, PullRequest pul } public String getUrlToView() { + Organization organization; switch(eventType) { case MEMBER_ENROLL_REQUEST: if (getProject() == null) { @@ -535,13 +536,25 @@ public String getUrlToView() { return routes.ProjectApp.members( getProject().owner, getProject().name).url(); } + case MEMBER_ENROLL_ACCEPT: + if (getProject() == null) { + return null; + } else { + return routes.ProjectApp.project( + getProject().owner, getProject().name).url(); + } case ORGANIZATION_MEMBER_ENROLL_REQUEST: - Organization organization = getOrganization(); + organization = getOrganization(); if (organization == null) { return null; } return routes.OrganizationApp.members(organization.name).url(); - + case ORGANIZATION_MEMBER_ENROLL_ACCEPT: + organization = getOrganization(); + if (organization == null) { + return null; + } + return routes.OrganizationApp.organization(organization.name).url(); case NEW_COMMIT: if (getProject() == null) { return null; @@ -1162,6 +1175,7 @@ public static void afterMemberRequest(Project project, User user, RequestState s break; case ACCEPT: notiEvent.title = formatMemberAcceptTitle(project, user); + notiEvent.eventType = MEMBER_ENROLL_ACCEPT; notiEvent.oldValue = RequestState.REQUEST.name(); break; } @@ -1192,6 +1206,7 @@ public static void afterOrganizationMemberRequest(Organization organization, Use break; case ACCEPT: notiEvent.title = formatMemberAcceptTitle(organization, user); + notiEvent.eventType = ORGANIZATION_MEMBER_ENROLL_ACCEPT; notiEvent.oldValue = RequestState.REQUEST.name(); break; } diff --git a/app/models/NotificationMail.java b/app/models/NotificationMail.java index f8eabcc6f..82f35e92f 100644 --- a/app/models/NotificationMail.java +++ b/app/models/NotificationMail.java @@ -52,6 +52,7 @@ import java.util.concurrent.TimeUnit; import static models.enumeration.EventType.*; +import static models.enumeration.ResourceType.ORGANIZATION; @Entity public class NotificationMail extends Model { @@ -620,10 +621,10 @@ private static String getHtmlMessage(Lang lang, String message, String urlToView String renderred = null; - if(resource != null) { - renderred = Markdown.render(message, resource.getProject(), lang.code()); - } else { + if (resource == null || resource.getType() == ORGANIZATION) { renderred = Markdown.render(message); + } else { + renderred = Markdown.render(message, resource.getProject(), lang.code()); } return getRenderedMail(lang, renderred, urlToView, resource, acceptsReply); diff --git a/app/models/enumeration/EventType.java b/app/models/enumeration/EventType.java index 6cd407710..02ecde542 100644 --- a/app/models/enumeration/EventType.java +++ b/app/models/enumeration/EventType.java @@ -39,7 +39,9 @@ public enum EventType { ISSUE_LABEL_CHANGED("notification.type.issue.label.changed", 23), ISSUE_MILESTONE_CHANGED("notification.type.milestone.changed", 24), POSTING_BODY_CHANGED("notification.type.posting.body.changed", 25), - RESOURCE_DELETED("notification.type.resource.deleted", 26); + RESOURCE_DELETED("notification.type.resource.deleted", 26), + MEMBER_ENROLL_ACCEPT("notification.member.enroll.accept", 27), + ORGANIZATION_MEMBER_ENROLL_ACCEPT("notification.member.enroll.accept", 28); private String descr;