Update gitea-rocketchat.hooks.js

Support x-gitea-event== issue_comment &&  action == reviewed /
This commit is contained in:
Austin Su 2021-07-22 14:55:42 +08:00 committed by GitHub
parent 5e750a6556
commit f9a4dd36e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -225,29 +225,19 @@ const giteaEvents = {
},
/* Comment on existing issues or pull request*/
issue_comment(request) {
const user = request.content.comment.user;
const user = request.content.sender;
const repo = request.content.repository;
const action = request.content.action;
if (action == "created") {
// Do nothing
} else if (action == "edited") {
// Do nothing
} else if (action == "deleted") {
// Do nothing
} else {
return {
error: {
success: false,
message: 'Unsupported issue_comment action'
}
};
}
if (action == "created" || action == "edited" || action == "deleted") {
var body = request.content.comment.body;
var number = request.content.issue.number;
var title = request.content.issue.title;
var url = request.content.comment.html_url;
if (request.content.comment.pull_request_url) {
var type = "pull request";
} else if (request.content.comment.issue_url) {
} else if (request.content.comment.issue_url) {
var type = "issue";
} else {
return {
@ -257,12 +247,26 @@ const giteaEvents = {
}
};
}
} else if (action == "reviewed") {
var body = request.content.review.content;
var number = request.content.pull_request.number;
var title = request.content.pull_request.title;
var url = request.content.pull_request.url;
var type = "pull request";
} else {
return {
error: {
success: false,
message: 'Unsupported issue_comment action'
}
};
}
const text =
action.capitalizeFirstLetter() + ' comment on **[' + type + ' #' + request.content.issue.number +
' - ' + request.content.issue.title + '](' +
request.content.comment.html_url + ')**' + ' at [' + repo.full_name + '](' + repo.html_url + ')\n\n';
action.capitalizeFirstLetter() + ' comment on **[' + type + ' #' + number +
' - ' + title + '](' + url + ')**' + ' at [' + repo.full_name + '](' + repo.html_url + ')\n\n';
return {
content: {
@ -271,7 +275,7 @@ const giteaEvents = {
text: text,
attachments: [
{
text: request.content.comment.body
text: body
}
]
}