[Notice] Announcing the End of Demo Server [Read me]
doortts doortts 2018-08-01
member: Fix 'member is accepted' link bug
@2305231db2b1432680d2dfd2b9442b78467b06ab
app/models/NotificationEvent.java
--- app/models/NotificationEvent.java
+++ app/models/NotificationEvent.java
@@ -527,6 +527,7 @@
     }
 
     public String getUrlToView() {
+        Organization organization;
         switch(eventType) {
             case MEMBER_ENROLL_REQUEST:
                 if (getProject() == null) {
@@ -535,13 +536,25 @@
                     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 @@
                 break;
             case ACCEPT:
                 notiEvent.title = formatMemberAcceptTitle(project, user);
+                notiEvent.eventType = MEMBER_ENROLL_ACCEPT;
                 notiEvent.oldValue = RequestState.REQUEST.name();
                 break;
         }
@@ -1192,6 +1206,7 @@
                 break;
             case ACCEPT:
                 notiEvent.title = formatMemberAcceptTitle(organization, user);
+                notiEvent.eventType = ORGANIZATION_MEMBER_ENROLL_ACCEPT;
                 notiEvent.oldValue = RequestState.REQUEST.name();
                 break;
         }
app/models/NotificationMail.java
--- app/models/NotificationMail.java
+++ 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 @@
 
         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);
app/models/enumeration/EventType.java
--- app/models/enumeration/EventType.java
+++ app/models/enumeration/EventType.java
@@ -39,7 +39,9 @@
     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;
 
Add a comment
List