Skip to content

Commit

Permalink
enhance(server): make antenna handle cw
Browse files Browse the repository at this point in the history
Resolve #10140
  • Loading branch information
syuilo committed Feb 28, 2023
1 parent c1e69e7 commit 83a6760
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ You should also include the user name that made the change.

### Improvements
- プッシュ通知でカスタム絵文字リアクションを表示できるように
- アンテナでCWも検索対象にするように

### Bugfixes
- 外部メディアプロキシ使用時にアバタークロップができない問題を修正
Expand Down
18 changes: 11 additions & 7 deletions packages/backend/src/core/AntennaService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,15 @@ export class AntennaService implements OnApplicationShutdown {
.filter(xs => xs.length > 0);

if (keywords.length > 0) {
if (note.text == null) return false;
if (note.text == null && note.cw == null) return false;

const _text = (note.text ?? '') + '\n' + (note.cw ?? '');

const matched = keywords.some(and =>
and.every(keyword =>
antenna.caseSensitive
? note.text!.includes(keyword)
: note.text!.toLowerCase().includes(keyword.toLowerCase()),
? _text.includes(keyword)
: _text.toLowerCase().includes(keyword.toLowerCase()),
));

if (!matched) return false;
Expand All @@ -189,13 +191,15 @@ export class AntennaService implements OnApplicationShutdown {
.filter(xs => xs.length > 0);

if (excludeKeywords.length > 0) {
if (note.text == null) return false;

if (note.text == null && note.cw == null) return false;

const _text = (note.text ?? '') + '\n' + (note.cw ?? '');

const matched = excludeKeywords.some(and =>
and.every(keyword =>
antenna.caseSensitive
? note.text!.includes(keyword)
: note.text!.toLowerCase().includes(keyword.toLowerCase()),
? _text.includes(keyword)
: _text.toLowerCase().includes(keyword.toLowerCase()),
));

if (matched) return false;
Expand Down

0 comments on commit 83a6760

Please sign in to comment.