Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance(backend): antennas/updateの必須項目をantennaIdのみに #13542

Merged
merged 3 commits into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
- Fix: カスタム絵文字の画像読み込みに失敗した際はテキストではなくダミー画像を表示 #13487

### Server
-
- Enhance: エンドポイント`antennas/update`の必須項目を`antennaId`のみに

## 2024.3.0

Expand Down
12 changes: 7 additions & 5 deletions packages/backend/src/server/api/endpoints/antennas/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const paramDef = {
withFile: { type: 'boolean' },
notify: { type: 'boolean' },
},
required: ['antennaId', 'name', 'src', 'keywords', 'excludeKeywords', 'users', 'caseSensitive', 'withReplies', 'withFile', 'notify'],
required: ['antennaId'],
} as const;

@Injectable()
Expand All @@ -83,8 +83,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
private globalEventService: GlobalEventService,
) {
super(meta, paramDef, async (ps, me) => {
if (ps.keywords.flat().every(x => x === '') && ps.excludeKeywords.flat().every(x => x === '')) {
throw new Error('either keywords or excludeKeywords is required.');
if (ps.keywords && ps.excludeKeywords) {
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
const antenna = await this.antennasRepository.findOneBy({
Expand All @@ -98,7 +100,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-

let userList;

if (ps.src === 'list' && ps.userListId) {
if ((ps.src === 'list' || antenna.src === 'list') && ps.userListId) {
userList = await this.userListsRepository.findOneBy({
id: ps.userListId,
userId: me.id,
Expand All @@ -112,7 +114,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
await this.antennasRepository.update(antenna.id, {
name: ps.name,
src: ps.src,
userListId: userList ? userList.id : null,
userListId: ps.userListId ? userList ? userList.id : null : undefined,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nullに設定することができなくなるかも?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ほんとですね...、 ps.userListId !== undefined で比較するように変更してみました。

keywords: ps.keywords,
excludeKeywords: ps.excludeKeywords,
users: ps.users,
Expand Down
18 changes: 9 additions & 9 deletions packages/misskey-js/src/autogen/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9925,19 +9925,19 @@ export type operations = {
'application/json': {
/** Format: misskey:id */
antennaId: string;
name: string;
name?: string;
/** @enum {string} */
src: 'home' | 'all' | 'users' | 'list' | 'users_blacklist';
src?: 'home' | 'all' | 'users' | 'list' | 'users_blacklist';
/** Format: misskey:id */
userListId?: string | null;
keywords: string[][];
excludeKeywords: string[][];
users: string[];
caseSensitive: boolean;
keywords?: string[][];
excludeKeywords?: string[][];
users?: string[];
caseSensitive?: boolean;
localOnly?: boolean;
withReplies: boolean;
withFile: boolean;
notify: boolean;
withReplies?: boolean;
withFile?: boolean;
notify?: boolean;
};
};
};
Expand Down
Loading