refactor(server): Improve readability
This commit is contained in:
parent
99e34e9ee2
commit
58a8fff895
@ -39,11 +39,16 @@ export async function checkHitAntenna(antenna: Antenna, note: Note, noteUser: Us
|
|||||||
if (!accts.includes(getFullApAccount(noteUser.username, noteUser.host).toLowerCase())) return false;
|
if (!accts.includes(getFullApAccount(noteUser.username, noteUser.host).toLowerCase())) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (antenna.keywords.length > 0) {
|
const keywords = antenna.keywords
|
||||||
|
// Clean up
|
||||||
|
.map(xs => xs.filter(x => x !== ''))
|
||||||
|
.filter(xs => xs.length > 0);
|
||||||
|
|
||||||
|
if (keywords.length > 0) {
|
||||||
if (note.text == null) return false;
|
if (note.text == null) return false;
|
||||||
|
|
||||||
const matched = antenna.keywords.some(keywords =>
|
const matched = keywords.some(and =>
|
||||||
keywords.filter(keyword => keyword !== '').every(keyword =>
|
and.every(keyword =>
|
||||||
antenna.caseSensitive
|
antenna.caseSensitive
|
||||||
? note.text!.includes(keyword)
|
? note.text!.includes(keyword)
|
||||||
: note.text!.toLowerCase().includes(keyword.toLowerCase())
|
: note.text!.toLowerCase().includes(keyword.toLowerCase())
|
||||||
@ -52,11 +57,16 @@ export async function checkHitAntenna(antenna: Antenna, note: Note, noteUser: Us
|
|||||||
if (!matched) return false;
|
if (!matched) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (antenna.excludeKeywords.length > 0) {
|
const excludeKeywords = antenna.excludeKeywords
|
||||||
|
// Clean up
|
||||||
|
.map(xs => xs.filter(x => x !== ''))
|
||||||
|
.filter(xs => xs.length > 0);
|
||||||
|
|
||||||
|
if (excludeKeywords.length > 0) {
|
||||||
if (note.text == null) return false;
|
if (note.text == null) return false;
|
||||||
|
|
||||||
const matched = antenna.excludeKeywords.some(keywords =>
|
const matched = excludeKeywords.some(and =>
|
||||||
keywords.filter(keyword => keyword !== '').every(keyword =>
|
and.every(keyword =>
|
||||||
antenna.caseSensitive
|
antenna.caseSensitive
|
||||||
? note.text!.includes(keyword)
|
? note.text!.includes(keyword)
|
||||||
: note.text!.toLowerCase().includes(keyword.toLowerCase())
|
: note.text!.toLowerCase().includes(keyword.toLowerCase())
|
||||||
|
Loading…
Reference in New Issue
Block a user