mirror of
https://codeberg.org/yeentown/barkey
synced 2024-11-22 11:25:13 +00:00
enhance(backend): antennas/updateの必須項目をantennaIdのみに (#13542)
* refactor: antennas/updateの必須項目を最小限に * fix: userListIdがnullにできない
This commit is contained in:
parent
e4eaf1220e
commit
6b676a928d
3 changed files with 17 additions and 15 deletions
|
@ -26,7 +26,7 @@
|
||||||
- Fix: カスタム絵文字の画像読み込みに失敗した際はテキストではなくダミー画像を表示 #13487
|
- Fix: カスタム絵文字の画像読み込みに失敗した際はテキストではなくダミー画像を表示 #13487
|
||||||
|
|
||||||
### Server
|
### Server
|
||||||
-
|
- Enhance: エンドポイント`antennas/update`の必須項目を`antennaId`のみに
|
||||||
|
|
||||||
## 2024.3.0
|
## 2024.3.0
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ export const paramDef = {
|
||||||
withFile: { type: 'boolean' },
|
withFile: { type: 'boolean' },
|
||||||
notify: { type: 'boolean' },
|
notify: { type: 'boolean' },
|
||||||
},
|
},
|
||||||
required: ['antennaId', 'name', 'src', 'keywords', 'excludeKeywords', 'users', 'caseSensitive', 'withReplies', 'withFile', 'notify'],
|
required: ['antennaId'],
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
@ -83,8 +83,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
private globalEventService: GlobalEventService,
|
private globalEventService: GlobalEventService,
|
||||||
) {
|
) {
|
||||||
super(meta, paramDef, async (ps, me) => {
|
super(meta, paramDef, async (ps, me) => {
|
||||||
if (ps.keywords.flat().every(x => x === '') && ps.excludeKeywords.flat().every(x => x === '')) {
|
if (ps.keywords && ps.excludeKeywords) {
|
||||||
throw new Error('either keywords or excludeKeywords is required.');
|
if (ps.keywords.flat().every(x => x === '') && ps.excludeKeywords.flat().every(x => x === '')) {
|
||||||
|
throw new Error('either keywords or excludeKeywords is required.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Fetch the antenna
|
// Fetch the antenna
|
||||||
const antenna = await this.antennasRepository.findOneBy({
|
const antenna = await this.antennasRepository.findOneBy({
|
||||||
|
@ -98,7 +100,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
|
|
||||||
let userList;
|
let userList;
|
||||||
|
|
||||||
if (ps.src === 'list' && ps.userListId) {
|
if ((ps.src === 'list' || antenna.src === 'list') && ps.userListId) {
|
||||||
userList = await this.userListsRepository.findOneBy({
|
userList = await this.userListsRepository.findOneBy({
|
||||||
id: ps.userListId,
|
id: ps.userListId,
|
||||||
userId: me.id,
|
userId: me.id,
|
||||||
|
@ -112,7 +114,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
await this.antennasRepository.update(antenna.id, {
|
await this.antennasRepository.update(antenna.id, {
|
||||||
name: ps.name,
|
name: ps.name,
|
||||||
src: ps.src,
|
src: ps.src,
|
||||||
userListId: userList ? userList.id : null,
|
userListId: ps.userListId !== undefined ? userList ? userList.id : null : undefined,
|
||||||
keywords: ps.keywords,
|
keywords: ps.keywords,
|
||||||
excludeKeywords: ps.excludeKeywords,
|
excludeKeywords: ps.excludeKeywords,
|
||||||
users: ps.users,
|
users: ps.users,
|
||||||
|
|
|
@ -9925,19 +9925,19 @@ export type operations = {
|
||||||
'application/json': {
|
'application/json': {
|
||||||
/** Format: misskey:id */
|
/** Format: misskey:id */
|
||||||
antennaId: string;
|
antennaId: string;
|
||||||
name: string;
|
name?: string;
|
||||||
/** @enum {string} */
|
/** @enum {string} */
|
||||||
src: 'home' | 'all' | 'users' | 'list' | 'users_blacklist';
|
src?: 'home' | 'all' | 'users' | 'list' | 'users_blacklist';
|
||||||
/** Format: misskey:id */
|
/** Format: misskey:id */
|
||||||
userListId?: string | null;
|
userListId?: string | null;
|
||||||
keywords: string[][];
|
keywords?: string[][];
|
||||||
excludeKeywords: string[][];
|
excludeKeywords?: string[][];
|
||||||
users: string[];
|
users?: string[];
|
||||||
caseSensitive: boolean;
|
caseSensitive?: boolean;
|
||||||
localOnly?: boolean;
|
localOnly?: boolean;
|
||||||
withReplies: boolean;
|
withReplies?: boolean;
|
||||||
withFile: boolean;
|
withFile?: boolean;
|
||||||
notify: boolean;
|
notify?: boolean;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue