insanehong 2015-04-10
Mention: Fix does not auto link for group mention
- add '_' character in valid pattern for id or group check
- add genarator for group link
@d8b07daeea729cc31548c1d095d8e897f8cc8820
app/utils/AutoLinkRenderer.java
--- app/utils/AutoLinkRenderer.java
+++ app/utils/AutoLinkRenderer.java
@@ -21,6 +21,7 @@
 package utils;
 
 import models.Issue;
+import models.Organization;
 import models.Project;
 import models.User;
 import org.apache.commons.lang.ArrayUtils;
@@ -59,7 +60,7 @@
  * </pre>
  */
 public class AutoLinkRenderer {
-    private static final String PATH_PATTERN_STR = "[a-zA-Z0-9-./]+";
+    private static final String PATH_PATTERN_STR = "[a-zA-Z0-9-_./]+";
     private static final String ISSUE_PATTERN_STR = "\\d+";
     private static final String SHA_PATTERN_STR = "[a-f0-9]{7,40}";
 
@@ -309,8 +310,13 @@
 
     private static Link toValidUserLink(String userId) {
         User user = User.findByLoginId(userId);
+        Organization org = Organization.findByName(userId);
 
-        if (user.isAnonymous()) {
+        if(org != null) {
+            return new Link(RouteUtil.getUrl(org), "@" + org.name);
+        }
+
+        if (user.isAnonymous() ) {
             return Link.EMPTY_LINK;
         } else {
             return new Link(RouteUtil.getUrl(user), "@" + user.loginId);
app/utils/RouteUtil.java
--- app/utils/RouteUtil.java
+++ app/utils/RouteUtil.java
@@ -22,6 +22,7 @@
 package utils;
 
 import controllers.CodeHistoryApp;
+import controllers.routes;
 import models.*;
 import models.enumeration.ResourceType;
 import models.resource.Resource;
@@ -80,6 +81,13 @@
         ).url();
     }
 
+    public static String getUrl(Organization org) {
+        if (org == null) return null;
+        org.refresh();
+
+        return controllers.routes.OrganizationApp.organization(org.name).url();
+    }
+
     public static String getUrl(Project project) {
         if (project == null) return null;
         project.refresh();
Add a comment
List