fix
This commit is contained in:
parent
08b8bf94ef
commit
dfa66e6e2a
|
@ -1706,6 +1706,14 @@ export interface Locale extends ILocale {
|
||||||
* Botアカウントを除外
|
* Botアカウントを除外
|
||||||
*/
|
*/
|
||||||
"antennaExcludeBots": string;
|
"antennaExcludeBots": string;
|
||||||
|
/**
|
||||||
|
* 正規表現を使用する
|
||||||
|
*/
|
||||||
|
"antennaUseRegex": string;
|
||||||
|
/**
|
||||||
|
* {src}の{line}行目にエラーがあります。
|
||||||
|
*/
|
||||||
|
"antennaUseRegexError": ParameterizedString<"src" | "line">;
|
||||||
/**
|
/**
|
||||||
* スペースで区切るとAND指定になり、改行で区切るとOR指定になります
|
* スペースで区切るとAND指定になり、改行で区切るとOR指定になります
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -422,6 +422,8 @@ antennaSource: "受信ソース"
|
||||||
antennaKeywords: "受信キーワード"
|
antennaKeywords: "受信キーワード"
|
||||||
antennaExcludeKeywords: "除外キーワード"
|
antennaExcludeKeywords: "除外キーワード"
|
||||||
antennaExcludeBots: "Botアカウントを除外"
|
antennaExcludeBots: "Botアカウントを除外"
|
||||||
|
antennaUseRegex: "正規表現を使用する"
|
||||||
|
antennaUseRegexError: "{src}の{line}行目にエラーがあります。"
|
||||||
antennaKeywordsDescription: "スペースで区切るとAND指定になり、改行で区切るとOR指定になります"
|
antennaKeywordsDescription: "スペースで区切るとAND指定になり、改行で区切るとOR指定になります"
|
||||||
notifyAntenna: "新しいノートを通知する"
|
notifyAntenna: "新しいノートを通知する"
|
||||||
withFileAntenna: "ファイルが添付されたノートのみ"
|
withFileAntenna: "ファイルが添付されたノートのみ"
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { antennaSources } from '@/models/Antenna.js';
|
||||||
|
|
||||||
export const packedAntennaSchema = {
|
export const packedAntennaSchema = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
|
@ -47,7 +49,7 @@ export const packedAntennaSchema = {
|
||||||
src: {
|
src: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
optional: false, nullable: false,
|
optional: false, nullable: false,
|
||||||
enum: ['home', 'all', 'users', 'list', 'users_blacklist'],
|
enum: antennaSources,
|
||||||
},
|
},
|
||||||
userListId: {
|
userListId: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
|
|
|
@ -13,21 +13,16 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<MkSelect v-model="src">
|
<MkSelect v-model="src">
|
||||||
<template #label>{{ i18n.ts.antennaSource }}</template>
|
<template #label>{{ i18n.ts.antennaSource }}</template>
|
||||||
<option value="all">{{ i18n.ts._antennaSources.all }}</option>
|
<option value="all">{{ i18n.ts._antennaSources.all }}</option>
|
||||||
<!--<option value="home">{{ i18n.ts._antennaSources.homeTimeline }}</option>-->
|
|
||||||
<option value="users">{{ i18n.ts._antennaSources.users }}</option>
|
<option value="users">{{ i18n.ts._antennaSources.users }}</option>
|
||||||
<!--<option value="list">{{ i18n.ts._antennaSources.userList }}</option>-->
|
|
||||||
<option value="users_blacklist">{{ i18n.ts._antennaSources.userBlacklist }}</option>
|
<option value="users_blacklist">{{ i18n.ts._antennaSources.userBlacklist }}</option>
|
||||||
</MkSelect>
|
</MkSelect>
|
||||||
<MkSelect v-if="src === 'list'" v-model="userListId">
|
<MkTextarea v-if="src === 'users' || src === 'users_blacklist'" v-model="users">
|
||||||
<template #label>{{ i18n.ts.userList }}</template>
|
|
||||||
<option v-for="list in userLists" :key="list.id" :value="list.id">{{ list.name }}</option>
|
|
||||||
</MkSelect>
|
|
||||||
<MkTextarea v-else-if="src === 'users' || src === 'users_blacklist'" v-model="users">
|
|
||||||
<template #label>{{ i18n.ts.users }}</template>
|
<template #label>{{ i18n.ts.users }}</template>
|
||||||
<template #caption>{{ i18n.ts.antennaUsersDescription }} <button class="_textButton" @click="addUser">{{ i18n.ts.addUser }}</button></template>
|
<template #caption>{{ i18n.ts.antennaUsersDescription }} <button class="_textButton" @click="addUser">{{ i18n.ts.addUser }}</button></template>
|
||||||
</MkTextarea>
|
</MkTextarea>
|
||||||
<MkSwitch v-model="excludeBots">{{ i18n.ts.antennaExcludeBots }}</MkSwitch>
|
<MkSwitch v-model="excludeBots">{{ i18n.ts.antennaExcludeBots }}</MkSwitch>
|
||||||
<MkSwitch v-model="withReplies">{{ i18n.ts.withReplies }}</MkSwitch>
|
<MkSwitch v-model="withReplies">{{ i18n.ts.withReplies }}</MkSwitch>
|
||||||
|
<MkSwitch v-model="useRegex">{{ i18n.ts.antennaUseRegex }}</MkSwitch>
|
||||||
<MkTextarea v-model="keywords">
|
<MkTextarea v-model="keywords">
|
||||||
<template #label>{{ i18n.ts.antennaKeywords }}</template>
|
<template #label>{{ i18n.ts.antennaKeywords }}</template>
|
||||||
<template #caption>{{ i18n.ts.antennaKeywordsDescription }}</template>
|
<template #caption>{{ i18n.ts.antennaKeywordsDescription }}</template>
|
||||||
|
@ -53,6 +48,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { watch, ref } from 'vue';
|
import { watch, ref } from 'vue';
|
||||||
import * as Misskey from 'misskey-js';
|
import * as Misskey from 'misskey-js';
|
||||||
|
import type { DeepPartial } from '@/scripts/merge.js';
|
||||||
import MkButton from '@/components/MkButton.vue';
|
import MkButton from '@/components/MkButton.vue';
|
||||||
import MkInput from '@/components/MkInput.vue';
|
import MkInput from '@/components/MkInput.vue';
|
||||||
import MkTextarea from '@/components/MkTextarea.vue';
|
import MkTextarea from '@/components/MkTextarea.vue';
|
||||||
|
@ -62,7 +58,6 @@ import * as os from '@/os.js';
|
||||||
import { misskeyApi } from '@/scripts/misskey-api.js';
|
import { misskeyApi } from '@/scripts/misskey-api.js';
|
||||||
import { i18n } from '@/i18n.js';
|
import { i18n } from '@/i18n.js';
|
||||||
import { deepMerge } from '@/scripts/merge.js';
|
import { deepMerge } from '@/scripts/merge.js';
|
||||||
import type { DeepPartial } from '@/scripts/merge.js';
|
|
||||||
|
|
||||||
type PartialAllowedAntenna = Omit<Misskey.entities.Antenna, 'id' | 'createdAt' | 'updatedAt'> & {
|
type PartialAllowedAntenna = Omit<Misskey.entities.Antenna, 'id' | 'createdAt' | 'updatedAt'> & {
|
||||||
id?: string;
|
id?: string;
|
||||||
|
@ -86,6 +81,7 @@ const initialAntenna = deepMerge<PartialAllowedAntenna>(props.antenna ?? {}, {
|
||||||
caseSensitive: false,
|
caseSensitive: false,
|
||||||
localOnly: false,
|
localOnly: false,
|
||||||
withFile: false,
|
withFile: false,
|
||||||
|
useRegex: false,
|
||||||
isActive: true,
|
isActive: true,
|
||||||
hasUnreadNote: false,
|
hasUnreadNote: false,
|
||||||
notify: false,
|
notify: false,
|
||||||
|
@ -107,16 +103,50 @@ const caseSensitive = ref<boolean>(initialAntenna.caseSensitive);
|
||||||
const localOnly = ref<boolean>(initialAntenna.localOnly);
|
const localOnly = ref<boolean>(initialAntenna.localOnly);
|
||||||
const excludeBots = ref<boolean>(initialAntenna.excludeBots);
|
const excludeBots = ref<boolean>(initialAntenna.excludeBots);
|
||||||
const withReplies = ref<boolean>(initialAntenna.withReplies);
|
const withReplies = ref<boolean>(initialAntenna.withReplies);
|
||||||
|
const useRegex = ref<boolean>(initialAntenna.useRegex);
|
||||||
const withFile = ref<boolean>(initialAntenna.withFile);
|
const withFile = ref<boolean>(initialAntenna.withFile);
|
||||||
const userLists = ref<Misskey.entities.UserList[] | null>(null);
|
|
||||||
|
|
||||||
watch(() => src.value, async () => {
|
|
||||||
if (src.value === 'list' && userLists.value === null) {
|
|
||||||
userLists.value = await misskeyApi('users/lists/list');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
async function saveAntenna() {
|
async function saveAntenna() {
|
||||||
|
const _keywords: string[][] = [];
|
||||||
|
const _excludeKeywords: string[][] = [];
|
||||||
|
|
||||||
|
if (useRegex.value) {
|
||||||
|
function checkRegExError(words: string[], type: string) {
|
||||||
|
const errLineNumbers = words
|
||||||
|
.map((x, i) => {
|
||||||
|
try {
|
||||||
|
// RE2にしてバックエンドと揃える?
|
||||||
|
new RegExp(x);
|
||||||
|
return null;
|
||||||
|
} catch {
|
||||||
|
return i + 1;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.filter(x => x != null);
|
||||||
|
if (errLineNumbers.length > 0) {
|
||||||
|
os.alert({
|
||||||
|
type: 'error',
|
||||||
|
text: i18n.tsx.antennaUseRegexError({ src: type, line: errLineNumbers.join(', ') }),
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const keywordsDraft = keywords.value.trim().split('\n').map(x => x.trim()).filter(x => x.length > 0);
|
||||||
|
if (!checkRegExError(keywordsDraft, i18n.ts.antennaKeywords)) return;
|
||||||
|
|
||||||
|
const excludeKeywordsDraft = excludeKeywords.value.trim().split('\n').map(x => x.trim()).filter(x => x.length > 0);
|
||||||
|
if (!checkRegExError(excludeKeywordsDraft, i18n.ts.antennaExcludeKeywords)) return;
|
||||||
|
|
||||||
|
_keywords.push(...keywordsDraft.map(x => [x]));
|
||||||
|
_excludeKeywords.push(...excludeKeywordsDraft.map(x => [x]));
|
||||||
|
} else {
|
||||||
|
_keywords.push(...keywords.value.trim().split('\n').map(x => x.trim().split(' ')).filter(x => x.length > 0));
|
||||||
|
_excludeKeywords.push(...excludeKeywords.value.trim().split('\n').map(x => x.trim().split(' ')).filter(x => x.length > 0));
|
||||||
|
}
|
||||||
|
|
||||||
const antennaData = {
|
const antennaData = {
|
||||||
name: name.value,
|
name: name.value,
|
||||||
src: src.value,
|
src: src.value,
|
||||||
|
@ -126,9 +156,10 @@ async function saveAntenna() {
|
||||||
withFile: withFile.value,
|
withFile: withFile.value,
|
||||||
caseSensitive: caseSensitive.value,
|
caseSensitive: caseSensitive.value,
|
||||||
localOnly: localOnly.value,
|
localOnly: localOnly.value,
|
||||||
users: users.value.trim().split('\n').map(x => x.trim()),
|
useRegex: useRegex.value,
|
||||||
keywords: keywords.value.trim().split('\n').map(x => x.trim().split(' ')),
|
users: users.value.trim().split('\n').map(x => x.trim()).filter(x => x.length > 0),
|
||||||
excludeKeywords: excludeKeywords.value.trim().split('\n').map(x => x.trim().split(' ')),
|
keywords: _keywords,
|
||||||
|
excludeKeywords: _excludeKeywords,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (initialAntenna.id == null) {
|
if (initialAntenna.id == null) {
|
||||||
|
|
|
@ -4643,7 +4643,7 @@ export type components = {
|
||||||
keywords: string[][];
|
keywords: string[][];
|
||||||
excludeKeywords: string[][];
|
excludeKeywords: string[][];
|
||||||
/** @enum {string} */
|
/** @enum {string} */
|
||||||
src: 'home' | 'all' | 'users' | 'list' | 'users_blacklist';
|
src: 'all' | 'users' | 'users_blacklist';
|
||||||
/** Format: id */
|
/** Format: id */
|
||||||
userListId: string | null;
|
userListId: string | null;
|
||||||
users: string[];
|
users: string[];
|
||||||
|
|
Loading…
Reference in New Issue