In Youtrack Helpdesk we had written a small workflow for sending Comments by Email. All works fine, only the images are not correct:
var entities = require('@jetbrains/youtrack-scripting-api/entities');
var notification = require('@jetbrains/youtrack-scripting-api/notifications');
const resolveLinks = function (text) {
var baseUrl = 'https://test.com/images/';
var updatedText = text.replace(/![([^]]*)](([^)]+))/g, function(match, altText, url) {
// Check if the URL is already absolute
if (url.startsWith('http://') || url.startsWith('https://')) {
return match;
}
// Replace with absolute URL
return ``;
});
if (text !== updatedText) {
text = updatedText;
}
return text;
};
exports.rule = entities.Issue.onChange({
title: 'Send Email Notification',
guard: function(ctx) {
return true;
},
action: function(ctx) {
var issue = ctx.issue;
if (issue.comments.added.isNotEmpty()) {
var authorName = issue.comments.added.first().author.fullName;
var emailReporter = issue.reporter.email;
var emailWorker = issue.fields.Bearbeiter.email;
var emailObserver = "";
issue.fields.Beobachten.forEach(function(user) {
emailObserver = emailObserver + user.email + ",";
});
if(emailObserver.endsWith(",")) {
emailObserver = emailObserver.substring(0,emailObserver.length-1);
}
var message = {
fromName: authorName,
to: [emailReporter],
cc: [emailWorker],
bcc: [emailObserver],
subject: 'New comment in ' + issue.id,
headers: {
'X-Custom-Header': 'Important value'
},
body: [
'<div style="font-family: sans-serif">',
' <div style="padding: 10px 10px; font-size: 13px; border-bottom: 1px solid #D4D5D6;">',
' New comment was added in issue <a href=https://service-desk.dhge.de/tickets/'+issue.id+'>'+issue.id+'</a> by ' + authorName + ': ',
' <br> <br>' + resolveLinks (issue.comments.last().text) ,
' </div>',
'<div>'
].join('n')
};
console.log("Send mail from "+authorName+" to: "+emailReporter);
console.log("Send mail from "+authorName+" to: "+emailWorker);
console.log("Send mail from "+authorName+" to: "+emailObserver);
console.log("Send mail text "+issue.comments.last().text);
notification.sendEmail(message, issue);
}
}
});
How can I replace images with the correct ones?
Kind regards,
Matthias
I expected to see the attachments in the Email send by the comment-workflow. But only the markup syntax is in the Email – not the correct image or attachement.
Sending a comment by mail in youtrack – including attachements (images, zip etc.)
In Youtrack Helpdesk we had written a small workflow for sending Comments by Email. All works fine, only the images are not correct:
How can I replace images with the correct ones?
Kind regards,
Matthias
I expected to see the attachments in the Email send by the comment-workflow. But only the markup syntax is in the Email – not the correct image or attachement.
Matthias Jakob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Filed under: Kiến thức lập trình - @ 18:12
Thẻ: imageemailcommentsattachmentyoutrack
« Mongo query: find document where each embeded element equals to given value ⇐ More Pages ⇒ Unexpected Loss of User Authenticated State Between Two Seperate Django Views »