Skip to content

Commit 2305231

Browse files
committed
member: Fix 'member is accepted' link bug
1 parent 3624944 commit 2305231

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

app/models/NotificationEvent.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,7 @@ public static NotificationEvent afterNewPullRequest(User sender, PullRequest pul
527527
}
528528

529529
public String getUrlToView() {
530+
Organization organization;
530531
switch(eventType) {
531532
case MEMBER_ENROLL_REQUEST:
532533
if (getProject() == null) {
@@ -535,13 +536,25 @@ public String getUrlToView() {
535536
return routes.ProjectApp.members(
536537
getProject().owner, getProject().name).url();
537538
}
539+
case MEMBER_ENROLL_ACCEPT:
540+
if (getProject() == null) {
541+
return null;
542+
} else {
543+
return routes.ProjectApp.project(
544+
getProject().owner, getProject().name).url();
545+
}
538546
case ORGANIZATION_MEMBER_ENROLL_REQUEST:
539-
Organization organization = getOrganization();
547+
organization = getOrganization();
540548
if (organization == null) {
541549
return null;
542550
}
543551
return routes.OrganizationApp.members(organization.name).url();
544-
552+
case ORGANIZATION_MEMBER_ENROLL_ACCEPT:
553+
organization = getOrganization();
554+
if (organization == null) {
555+
return null;
556+
}
557+
return routes.OrganizationApp.organization(organization.name).url();
545558
case NEW_COMMIT:
546559
if (getProject() == null) {
547560
return null;
@@ -1162,6 +1175,7 @@ public static void afterMemberRequest(Project project, User user, RequestState s
11621175
break;
11631176
case ACCEPT:
11641177
notiEvent.title = formatMemberAcceptTitle(project, user);
1178+
notiEvent.eventType = MEMBER_ENROLL_ACCEPT;
11651179
notiEvent.oldValue = RequestState.REQUEST.name();
11661180
break;
11671181
}
@@ -1192,6 +1206,7 @@ public static void afterOrganizationMemberRequest(Organization organization, Use
11921206
break;
11931207
case ACCEPT:
11941208
notiEvent.title = formatMemberAcceptTitle(organization, user);
1209+
notiEvent.eventType = ORGANIZATION_MEMBER_ENROLL_ACCEPT;
11951210
notiEvent.oldValue = RequestState.REQUEST.name();
11961211
break;
11971212
}

app/models/NotificationMail.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import java.util.concurrent.TimeUnit;
5353

5454
import static models.enumeration.EventType.*;
55+
import static models.enumeration.ResourceType.ORGANIZATION;
5556

5657
@Entity
5758
public class NotificationMail extends Model {
@@ -620,10 +621,10 @@ private static String getHtmlMessage(Lang lang, String message, String urlToView
620621

621622
String renderred = null;
622623

623-
if(resource != null) {
624-
renderred = Markdown.render(message, resource.getProject(), lang.code());
625-
} else {
624+
if (resource == null || resource.getType() == ORGANIZATION) {
626625
renderred = Markdown.render(message);
626+
} else {
627+
renderred = Markdown.render(message, resource.getProject(), lang.code());
627628
}
628629

629630
return getRenderedMail(lang, renderred, urlToView, resource, acceptsReply);

app/models/enumeration/EventType.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ public enum EventType {
3939
ISSUE_LABEL_CHANGED("notification.type.issue.label.changed", 23),
4040
ISSUE_MILESTONE_CHANGED("notification.type.milestone.changed", 24),
4141
POSTING_BODY_CHANGED("notification.type.posting.body.changed", 25),
42-
RESOURCE_DELETED("notification.type.resource.deleted", 26);
42+
RESOURCE_DELETED("notification.type.resource.deleted", 26),
43+
MEMBER_ENROLL_ACCEPT("notification.member.enroll.accept", 27),
44+
ORGANIZATION_MEMBER_ENROLL_ACCEPT("notification.member.enroll.accept", 28);
4345

4446
private String descr;
4547

0 commit comments

Comments
 (0)