2
1
0
1 回答
- 321
残念ながら、CONFSERVER-38891 Allow deletion of resolved comments のチケットで要望が挙げられている通り、解決済みのインラインコメントを削除することはできないようです。
そのインラインコメントを一度オープンしてから削除するという方法になるようですが、ページ本文が削除されてしまっている場合は再オープンすることができません。
ページのコメントを取得する REST API は Comments of content があります。
インラインコメントを削除する REST API は公開されていませんでしたが、画面上の操作では REST API を使用して削除しているようでしたので、少々強引ですがそれを使用して削除することはできそうでした。たとえば以下の JavaScript を、Confluence のページを開いた状態のブラウザーのコンソールから実行することで、そのページの解決済みのインラインコメントを削除することができたように思えます。
(function($) { var contextPath = AJS.contextPath(); var pageId = AJS.params.pageId; var limit = 50; (function retrieveAllComments(start, inlineComments) { $.ajax({ type: 'GET', url: contextPath + '/rest/api/content/' + pageId + '/child/comment?expand=body.view%2Chistory%2Cextensions.resolution%2Cextensions.inlineProperties%2Ccontainer.history%2Cchildren.comment&limit=' + limit + '&start=' + start, dataType: 'json' }).done(function(commentsResponse) { var margedComments = inlineComments.concat(commentsResponse.results); if (commentsResponse.limit === commentsResponse.size) { retrieveAllComments(start + limit, margedComments) } else { deleteResolvedInlineComments(margedComments); } }).fail(function(xhr) { console.log('Could not retrieve inline comments.'); console.log(xhr); }); })(0, []); function deleteResolvedInlineComments(comments) { for (var i = 0, len = comments.length; i < len; i++) { var comment = comments[i]; if (comment.extensions.location != 'inline') continue; if (comment.extensions.resolution.status !== 'open') { // Delete child comments if this comment has children. if (comment.children.comment.results.length !== 0) { for (var j = 0, len2 = comment.children.comment.results.length; j < len2; j++) { deleteInlineComment(comment.children.comment.results[j].id, logDelete); } } // Finaly, delete this comment itself. deleteInlineComment(comment.id, logDelete); } } console.log('Done!'); } function deleteInlineComment(inlineCommentId, f) { $.ajax({ url: AJS.contextPath() + '/rest/inlinecomments/1.0/comments/' + inlineCommentId, type: 'DELETE', async: false }).done(f).fail(function(xhr) { console.log('Could not delete inline comment.'); console.log(xhr); }); } function logDelete(number) { console.log(number + ' is deleted.'); } })(AJS.$);
非同期して大量のアクセスを発生させるとエラーが返ってきてしまうことがあったので同期処理にしています...
大量のコメントが存在している場合は Confluence へ負荷をかけることになりますので注意が必要です。
また記載いたしました通り、インラインコメントを削除する REST API 辞退は Atlassian 社より公開されているものではないので、変更される可能性があったりサポートされていませんので
こちらもご注意ください。コメントを追加...
Confluence のページ内にインラインコメントがありますが、解決された不要なものを削除したいです。
何かいい方法はあるでしょうか。