feat: search cw comments and image alt texts in antennas (close #24)

This commit is contained in:
naskya 2023-07-20 07:23:51 +00:00
parent 86cdcc1bdf
commit e04c6e7b85
Signed by: naskya
GPG key ID: 164DFF24E2D40139
2 changed files with 9 additions and 2 deletions
packages/backend/src/misc

View file

@ -95,14 +95,19 @@ export async function checkHitAntenna(
.map((xs) => xs.filter((x) => x !== ""))
.filter((xs) => xs.length > 0);
let text = `${note.text ?? ""} ${note.cw ?? ""}`;
if (note.files != null)
text += ` ${note.files.map((f) => f.comment ?? "").join(" ")}`;
text = text.trim();
if (keywords.length > 0) {
if (note.text == null) return false;
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()),
),
);