YouTrack および Hub ヘルプの開発者ポータル

冒とく的なブロッカー

このワークフローは、ブラックリストからの単語が含まれている場合、説明またはコメントの送信をブロックします。

名前

@jetbrains/youtrack-workflow-profanity-blacklist

前のタイトル

スパムブラックリスト

自動添付

いいえ

モジュール

ストップワードを含むブロックの説明とコメント (変更時のルール)

profanity-common.js (カスタムスクリプト)

ユースケース

このワークフローは、不快な言葉を含む課題やコメントをユーザーが送信できないようにします。ブラックリストに単語を追加したり、ブラックリストから単語を削除したりするようにルールを編集できます。

モジュール

このワークフローには 2 つのモジュールがあります。1 つ目は、説明とコメントをチェックしてブラックリストに単語が含まれているかどうかを確認する変更時のルールです。2 番目のモジュールはカスタムスクリプトです。

ストップワードを含むブロックの説明とコメント

課題が報告または更新されると、このルールは説明とコメントをチェックして、ブラックリストに単語が含まれているかどうかを確認します。true の場合、警告が表示されます。説明またはコメントにブラックリストの 1 つ以上の単語が含まれていることがユーザーに通知されます。

const entities = require('@jetbrains/youtrack-scripting-api/entities'); const workflow = require('@jetbrains/youtrack-scripting-api/workflow'); const profanity = require('./profanity-common'); exports.rule = entities.Issue.onChange({ title: 'Block descriptions and comments that contain stop words', action: (ctx) => { const issue = ctx.issue; const texts = []; function add(text) { if (text) { texts.push(text); } } issue.getAdded('comments').forEach(function (comment) { add(comment.text); }); const becomesReported = issue.becomesReported; if (becomesReported || issue.isChanged('summary')) { add(issue.summary); } if (becomesReported || issue.isChanged('description')) { add(issue.description); } texts.forEach(function (text) { text = text.toLowerCase(); profanity.words().forEach(function (badWord) { let index = text.indexOf(badWord); while (index !== -1) { const sepBefore = index === 0 || profanity.separators.indexOf(text.substring(index - 1, index)) > -1; const endIndex = index + badWord.length; const sepAfter = endIndex === text.length || profanity.separators.indexOf(text.substring(endIndex, endIndex + 1)) > -1; workflow.check(!(sepBefore && sepAfter), 'Using the word {0} is prohibited', badWord); index = text.indexOf(badWord, endIndex); } }); }); } });

profanity-common.js

このカスタムスクリプトには、ストップリスト内のすべての単語が含まれています。このスクリプトは、const profanity = require('./profanity-common'); 宣言の変更時ルールで参照されています。

課題で報告されている冒涜的な単語、またはブロックしたいその他の単語が見つかった場合は、ワークフロールールを変更せずにこのモジュール内の単語のリストを更新できます。

exports.words = function () { return '<a comma-separated list of stop words>' .split(', ').map(function (word) { return word.toLowerCase(); }); }; exports.separators = '~`!@#$%^&*()-_+=[]{}:;\'\"\\|,<.>/? \n\r\t';
2025 年 11 月 21 日