apply mutes to image descriptions
Some checks failed
ci/woodpecker/push/lint-sw Pipeline failed
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/push/lint-client Pipeline failed
ci/woodpecker/push/lint-backend Pipeline failed
ci/woodpecker/push/test Pipeline failed
Some checks failed
ci/woodpecker/push/lint-sw Pipeline failed
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/push/lint-client Pipeline failed
ci/woodpecker/push/lint-backend Pipeline failed
ci/woodpecker/push/test Pipeline failed
Changelog: Added
This commit is contained in:
parent
095802d059
commit
d34f7c7faa
2 changed files with 30 additions and 4 deletions
|
@ -13,11 +13,24 @@ type UserLike = {
|
|||
};
|
||||
|
||||
export async function checkWordMute(note: NoteLike, me: UserLike | null | undefined, mutedWords: Array<string | string[]>): Promise<boolean> {
|
||||
// 自分自身
|
||||
// own posts
|
||||
if (me && (note.userId === me.id)) return false;
|
||||
|
||||
if (mutedWords.length > 0) {
|
||||
const text = ((note.cw ?? '') + '\n' + (note.text ?? '')).trim();
|
||||
const text = [
|
||||
note.cw,
|
||||
note.text,
|
||||
...note.files.map(file => file.comment)
|
||||
]
|
||||
.map(x => {
|
||||
if (x == null || x.trim() == '') {
|
||||
return null;
|
||||
} else {
|
||||
return x.trim();
|
||||
}
|
||||
})
|
||||
.filter(x => x != null)
|
||||
.join('\n');
|
||||
|
||||
if (text === '') return false;
|
||||
const textLower = text.toLowerCase();
|
||||
|
|
|
@ -1,9 +1,22 @@
|
|||
export function checkWordMute(note: Record<string, any>, me: Record<string, any> | null | undefined, mutedWords: Array<string | string[]>): boolean {
|
||||
// 自分自身
|
||||
// own posts
|
||||
if (me && (note.userId === me.id)) return false;
|
||||
|
||||
if (mutedWords.length > 0) {
|
||||
const text = ((note.cw ?? '') + '\n' + (note.text ?? '')).trim();
|
||||
const text = [
|
||||
note.cw,
|
||||
note.text,
|
||||
...note.files.map(file => file.comment)
|
||||
]
|
||||
.map(x => {
|
||||
if (x == null || x.trim() == '') {
|
||||
return null;
|
||||
} else {
|
||||
return x.trim();
|
||||
}
|
||||
})
|
||||
.filter(x => x != null)
|
||||
.join('\n');
|
||||
|
||||
if (text === '') return false;
|
||||
const textLower = text.toLowerCase();
|
||||
|
|
Loading…
Reference in a new issue