Skip to content

Commit

Permalink
member: Fix 'member is accepted' link bug
Browse files Browse the repository at this point in the history
  • Loading branch information
doortts committed Aug 1, 2018
1 parent 3624944 commit 2305231
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
19 changes: 17 additions & 2 deletions app/models/NotificationEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
7 changes: 4 additions & 3 deletions app/models/NotificationMail.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion app/models/enumeration/EventType.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 2305231

Please sign in to comment.