apply mutes to image descriptions
ci/woodpecker/push/lint-sw Pipeline failed Details
ci/woodpecker/push/build Pipeline was successful Details
ci/woodpecker/push/lint-foundkey-js Pipeline was successful Details
ci/woodpecker/push/lint-client Pipeline failed Details
ci/woodpecker/push/lint-backend Pipeline failed Details
ci/woodpecker/push/test Pipeline failed Details

Changelog: Added
This commit is contained in:
Johann150 2024-04-04 00:07:45 +02:00
parent 095802d059
commit d34f7c7faa
Signed by: Johann150
GPG Key ID: 9EE6577A2A06F8F1
2 changed files with 30 additions and 4 deletions

View File

@ -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();

View File

@ -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();