Resolve #6043
This commit is contained in:
		
							parent
							
								
									7de915d47b
								
							
						
					
					
						commit
						c7c08b7511
					
				
					 10 changed files with 58 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -30,6 +30,10 @@
 | 
			
		|||
			<span>{{ $t('antennaKeywords') }}</span>
 | 
			
		||||
			<template #desc>{{ $t('antennaKeywordsDescription') }}</template>
 | 
			
		||||
		</mk-textarea>
 | 
			
		||||
		<mk-textarea v-model="excludeKeywords">
 | 
			
		||||
			<span>{{ $t('antennaExcludeKeywords') }}</span>
 | 
			
		||||
			<template #desc>{{ $t('antennaKeywordsDescription') }}</template>
 | 
			
		||||
		</mk-textarea>
 | 
			
		||||
		<mk-switch v-model="caseSensitive">{{ $t('caseSensitive') }}</mk-switch>
 | 
			
		||||
		<mk-switch v-model="withFile">{{ $t('withFileAntenna') }}</mk-switch>
 | 
			
		||||
		<mk-switch v-model="notify">{{ $t('notifyAntenna') }}</mk-switch>
 | 
			
		||||
| 
						 | 
				
			
			@ -75,6 +79,7 @@ export default Vue.extend({
 | 
			
		|||
			userGroupId: null,
 | 
			
		||||
			users: '',
 | 
			
		||||
			keywords: '',
 | 
			
		||||
			excludeKeywords: '',
 | 
			
		||||
			caseSensitive: false,
 | 
			
		||||
			withReplies: false,
 | 
			
		||||
			withFile: false,
 | 
			
		||||
| 
						 | 
				
			
			@ -107,6 +112,7 @@ export default Vue.extend({
 | 
			
		|||
		this.userGroupId = this.antenna.userGroupId;
 | 
			
		||||
		this.users = this.antenna.users.join('\n');
 | 
			
		||||
		this.keywords = this.antenna.keywords.map(x => x.join(' ')).join('\n');
 | 
			
		||||
		this.excludeKeywords = this.antenna.excludeKeywords.map(x => x.join(' ')).join('\n');
 | 
			
		||||
		this.caseSensitive = this.antenna.caseSensitive;
 | 
			
		||||
		this.withReplies = this.antenna.withReplies;
 | 
			
		||||
		this.withFile = this.antenna.withFile;
 | 
			
		||||
| 
						 | 
				
			
			@ -126,7 +132,8 @@ export default Vue.extend({
 | 
			
		|||
					notify: this.notify,
 | 
			
		||||
					caseSensitive: this.caseSensitive,
 | 
			
		||||
					users: this.users.trim().split('\n').map(x => x.trim()),
 | 
			
		||||
					keywords: this.keywords.trim().split('\n').map(x => x.trim().split(' '))
 | 
			
		||||
					keywords: this.keywords.trim().split('\n').map(x => x.trim().split(' ')),
 | 
			
		||||
					excludeKeywords: this.excludeKeywords.trim().split('\n').map(x => x.trim().split(' ')),
 | 
			
		||||
				});
 | 
			
		||||
				this.$emit('created');
 | 
			
		||||
			} else {
 | 
			
		||||
| 
						 | 
				
			
			@ -141,7 +148,8 @@ export default Vue.extend({
 | 
			
		|||
					notify: this.notify,
 | 
			
		||||
					caseSensitive: this.caseSensitive,
 | 
			
		||||
					users: this.users.trim().split('\n').map(x => x.trim()),
 | 
			
		||||
					keywords: this.keywords.trim().split('\n').map(x => x.trim().split(' '))
 | 
			
		||||
					keywords: this.keywords.trim().split('\n').map(x => x.trim().split(' ')),
 | 
			
		||||
					excludeKeywords: this.excludeKeywords.trim().split('\n').map(x => x.trim().split(' ')),
 | 
			
		||||
				});
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -53,6 +53,7 @@ export default Vue.extend({
 | 
			
		|||
				userGroupId: null,
 | 
			
		||||
				users: [],
 | 
			
		||||
				keywords: [],
 | 
			
		||||
				excludeKeywords: [],
 | 
			
		||||
				withReplies: false,
 | 
			
		||||
				caseSensitive: false,
 | 
			
		||||
				withFile: false,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -52,6 +52,19 @@ export async function checkHitAntenna(antenna: Antenna, note: Note, noteUser: Us
 | 
			
		|||
		if (!matched) return false;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (antenna.excludeKeywords.length > 0) {
 | 
			
		||||
		if (note.text == null) return false;
 | 
			
		||||
 | 
			
		||||
		const matched = antenna.excludeKeywords.some(keywords =>
 | 
			
		||||
			keywords.every(keyword =>
 | 
			
		||||
				antenna.caseSensitive
 | 
			
		||||
					? note.text!.includes(keyword)
 | 
			
		||||
					: note.text!.toLowerCase().includes(keyword.toLowerCase())
 | 
			
		||||
			));
 | 
			
		||||
		
 | 
			
		||||
		if (matched) return false;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (antenna.withFile) {
 | 
			
		||||
		if (note.fileIds.length === 0) return false;
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -71,6 +71,11 @@ export class Antenna {
 | 
			
		|||
	})
 | 
			
		||||
	public keywords: string[][];
 | 
			
		||||
 | 
			
		||||
	@Column('jsonb', {
 | 
			
		||||
		default: []
 | 
			
		||||
	})
 | 
			
		||||
	public excludeKeywords: string[][];
 | 
			
		||||
 | 
			
		||||
	@Column('boolean', {
 | 
			
		||||
		default: false
 | 
			
		||||
	})
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,6 +21,7 @@ export class AntennaRepository extends Repository<Antenna> {
 | 
			
		|||
			createdAt: antenna.createdAt.toISOString(),
 | 
			
		||||
			name: antenna.name,
 | 
			
		||||
			keywords: antenna.keywords,
 | 
			
		||||
			excludeKeywords: antenna.excludeKeywords,
 | 
			
		||||
			src: antenna.src,
 | 
			
		||||
			userListId: antenna.userListId,
 | 
			
		||||
			userGroupId: userGroupJoining ? userGroupJoining.userGroupId : null,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -33,6 +33,10 @@ export const meta = {
 | 
			
		|||
			validator: $.arr($.arr($.str))
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		excludeKeywords: {
 | 
			
		||||
			validator: $.arr($.arr($.str))
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		users: {
 | 
			
		||||
			validator: $.arr($.str)
 | 
			
		||||
		},
 | 
			
		||||
| 
						 | 
				
			
			@ -102,6 +106,7 @@ export default define(meta, async (ps, user) => {
 | 
			
		|||
		userListId: userList ? userList.id : null,
 | 
			
		||||
		userGroupJoiningId: userGroupJoining ? userGroupJoining.id : null,
 | 
			
		||||
		keywords: ps.keywords,
 | 
			
		||||
		excludeKeywords: ps.excludeKeywords,
 | 
			
		||||
		users: ps.users,
 | 
			
		||||
		caseSensitive: ps.caseSensitive,
 | 
			
		||||
		withReplies: ps.withReplies,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -36,6 +36,10 @@ export const meta = {
 | 
			
		|||
			validator: $.arr($.arr($.str))
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		excludeKeywords: {
 | 
			
		||||
			validator: $.arr($.arr($.str))
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		users: {
 | 
			
		||||
			validator: $.arr($.str)
 | 
			
		||||
		},
 | 
			
		||||
| 
						 | 
				
			
			@ -118,6 +122,7 @@ export default define(meta, async (ps, user) => {
 | 
			
		|||
		userListId: userList ? userList.id : null,
 | 
			
		||||
		userGroupJoiningId: userGroupJoining ? userGroupJoining.id : null,
 | 
			
		||||
		keywords: ps.keywords,
 | 
			
		||||
		excludeKeywords: ps.excludeKeywords,
 | 
			
		||||
		users: ps.users,
 | 
			
		||||
		caseSensitive: ps.caseSensitive,
 | 
			
		||||
		withReplies: ps.withReplies,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue