]> source.dussan.org Git - gitblit.git/commitdiff
Support email View Ticket go-to-action 86/186/2
authorJames Moger <james.moger@gitblit.com>
Wed, 24 Sep 2014 18:20:59 +0000 (14:20 -0400)
committerJames Moger <james.moger@gitblit.com>
Thu, 25 Sep 2014 11:51:39 +0000 (07:51 -0400)
src/main/java/com/gitblit/tickets/TicketNotifier.java
src/main/java/com/gitblit/tickets/viewTicket.html [new file with mode: 0644]

index 07371b1b0591768941ca027c2957eb315e046459..5979cf26014536a723e26f7211f95625e4a2154d 100644 (file)
@@ -135,6 +135,7 @@ public class TicketNotifier {
                        StringBuilder html = new StringBuilder();
                        html.append("<head>");
                        html.append(readStyle());
+                       html.append(readViewTicketAction(ticket));
                        html.append("</head>");
                        html.append("<body>");
                        html.append(MarkdownUtils.transformGFM(settings, markdown, ticket.repository));
@@ -596,7 +597,7 @@ public class TicketNotifier {
 
                // respect the author's email preference
                UserModel lastAuthor = userManager.getUserModel(lastChange.author);
-               if (!lastAuthor.getPreferences().isEmailMeOnMyTicketChanges()) {
+               if (lastAuthor != null && !lastAuthor.getPreferences().isEmailMeOnMyTicketChanges()) {
                        toAddresses.remove(lastAuthor.emailAddress);
                        ccAddresses.remove(lastAuthor.emailAddress);
                }
@@ -613,6 +614,12 @@ public class TicketNotifier {
                return sb.toString();
        }
 
+       protected String readViewTicketAction(TicketModel ticket) {
+               String action = readResource("viewTicket.html");
+               action = action.replace("${url}", ticketService.getTicketUrl(ticket));
+               return action;
+       }
+
        protected String readResource(String resource) {
                StringBuilder sb = new StringBuilder();
                InputStream is = null;
diff --git a/src/main/java/com/gitblit/tickets/viewTicket.html b/src/main/java/com/gitblit/tickets/viewTicket.html
new file mode 100644 (file)
index 0000000..54e091c
--- /dev/null
@@ -0,0 +1,12 @@
+<script type="application/ld+json">
+{
+  "@context": "http://schema.org",
+  "@type": "EmailMessage",
+  "description": "View this Ticket in Gitblit",
+  "action": {
+    "@type": "ViewAction",
+    "url": "${url}",
+    "name": "View Ticket"
+  }
+}
+</script>