| | |
| | | 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)); |
| | |
| | | } catch (Exception e) { |
| | | Logger.getLogger(getClass()).error("failed to get changed paths", e); |
| | | } finally { |
| | | repo.close(); |
| | | if (repo != null) { |
| | | repo.close(); |
| | | } |
| | | } |
| | | |
| | | String compareUrl = ticketService.getCompareUrl(ticket, base, patchset.tip); |
| | |
| | | // new proposal |
| | | pattern = "**{0}** is proposing a change."; |
| | | sb.append(MessageFormat.format(pattern, user.getDisplayName())); |
| | | fieldExclusions.add(Field.status); |
| | | fieldExclusions.add(Field.title); |
| | | fieldExclusions.add(Field.body); |
| | | } else { |
| | | // describe the patchset |
| | | if (patchset.isFF()) { |
| | |
| | | instructions = instructions.replace("${ticketRef}", ticketBranch); |
| | | instructions = instructions.replace("${patchsetRef}", patchsetBranch); |
| | | instructions = instructions.replace("${reviewBranch}", reviewBranch); |
| | | instructions = instructions.replace("${ticketBranch}", ticketBranch); |
| | | |
| | | return instructions; |
| | | } |
| | |
| | | |
| | | // |
| | | // Direct TO recipients |
| | | // reporter & responsible |
| | | // |
| | | Set<String> tos = new TreeSet<String>(); |
| | | tos.add(ticket.createdBy); |
| | | if (!StringUtils.isEmpty(ticket.responsible)) { |
| | | tos.add(ticket.responsible); |
| | | } |
| | | |
| | | Set<String> toAddresses = new TreeSet<String>(); |
| | | for (String name : ticket.getParticipants()) { |
| | | for (String name : tos) { |
| | | UserModel user = userManager.getUserModel(name); |
| | | if (user != null) { |
| | | if (user != null && !user.disabled) { |
| | | if (!StringUtils.isEmpty(user.emailAddress)) { |
| | | if (user.canView(repository)) { |
| | | toAddresses.add(user.emailAddress); |
| | |
| | | } |
| | | } |
| | | } |
| | | mailing.setRecipients(toAddresses); |
| | | |
| | | // |
| | | // CC recipients |
| | | // |
| | | Set<String> ccs = new TreeSet<String>(); |
| | | |
| | | // repository owners |
| | | if (!ArrayUtils.isEmpty(repository.owners)) { |
| | | ccs.addAll(repository.owners); |
| | | } |
| | | |
| | | // cc users mentioned in last comment |
| | | Change lastChange = ticket.changes.get(ticket.changes.size() - 1); |
| | |
| | | Set<String> ccAddresses = new TreeSet<String>(); |
| | | for (String name : ccs) { |
| | | UserModel user = userManager.getUserModel(name); |
| | | if (user != null) { |
| | | if (user != null && !user.disabled) { |
| | | if (!StringUtils.isEmpty(user.emailAddress)) { |
| | | if (user.canView(repository)) { |
| | | ccAddresses.add(user.emailAddress); |
| | |
| | | } |
| | | ccAddresses.addAll(settings.getStrings(Keys.mail.mailingLists)); |
| | | |
| | | // respect the author's email preference |
| | | UserModel lastAuthor = userManager.getUserModel(lastChange.author); |
| | | if (lastAuthor != null && !lastAuthor.getPreferences().isEmailMeOnMyTicketChanges()) { |
| | | toAddresses.remove(lastAuthor.emailAddress); |
| | | ccAddresses.remove(lastAuthor.emailAddress); |
| | | } |
| | | |
| | | mailing.setRecipients(toAddresses); |
| | | mailing.setCCs(ccAddresses); |
| | | } |
| | | |
| | |
| | | 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; |