すべてのフォロー中の人のwithRepliesを変える機能 (#12049)
* feat: endpoint to update all following * feat(frontend): change show replies for all * docs(changelog): すでにフォローしたすべての人の返信をTLに追加できるように * fix: cancel not working
This commit is contained in:
		| @@ -165,6 +165,7 @@ import * as ep___federation_stats from './endpoints/federation/stats.js'; | ||||
| import * as ep___following_create from './endpoints/following/create.js'; | ||||
| import * as ep___following_delete from './endpoints/following/delete.js'; | ||||
| import * as ep___following_update from './endpoints/following/update.js'; | ||||
| import * as ep___following_update_all from './endpoints/following/update-all.js'; | ||||
| import * as ep___following_invalidate from './endpoints/following/invalidate.js'; | ||||
| import * as ep___following_requests_accept from './endpoints/following/requests/accept.js'; | ||||
| import * as ep___following_requests_cancel from './endpoints/following/requests/cancel.js'; | ||||
| @@ -520,6 +521,7 @@ const $federation_stats: Provider = { provide: 'ep:federation/stats', useClass: | ||||
| const $following_create: Provider = { provide: 'ep:following/create', useClass: ep___following_create.default }; | ||||
| const $following_delete: Provider = { provide: 'ep:following/delete', useClass: ep___following_delete.default }; | ||||
| const $following_update: Provider = { provide: 'ep:following/update', useClass: ep___following_update.default }; | ||||
| const $following_update_all: Provider = { provide: 'ep:following/update-all', useClass: ep___following_update_all.default }; | ||||
| const $following_invalidate: Provider = { provide: 'ep:following/invalidate', useClass: ep___following_invalidate.default }; | ||||
| const $following_requests_accept: Provider = { provide: 'ep:following/requests/accept', useClass: ep___following_requests_accept.default }; | ||||
| const $following_requests_cancel: Provider = { provide: 'ep:following/requests/cancel', useClass: ep___following_requests_cancel.default }; | ||||
| @@ -879,6 +881,7 @@ const $retention: Provider = { provide: 'ep:retention', useClass: ep___retention | ||||
| 		$following_create, | ||||
| 		$following_delete, | ||||
| 		$following_update, | ||||
| 		$following_update_all, | ||||
| 		$following_invalidate, | ||||
| 		$following_requests_accept, | ||||
| 		$following_requests_cancel, | ||||
| @@ -1232,6 +1235,7 @@ const $retention: Provider = { provide: 'ep:retention', useClass: ep___retention | ||||
| 		$following_create, | ||||
| 		$following_delete, | ||||
| 		$following_update, | ||||
| 		$following_update_all, | ||||
| 		$following_invalidate, | ||||
| 		$following_requests_accept, | ||||
| 		$following_requests_cancel, | ||||
|   | ||||
| @@ -165,6 +165,7 @@ import * as ep___federation_stats from './endpoints/federation/stats.js'; | ||||
| import * as ep___following_create from './endpoints/following/create.js'; | ||||
| import * as ep___following_delete from './endpoints/following/delete.js'; | ||||
| import * as ep___following_update from './endpoints/following/update.js'; | ||||
| import * as ep___following_update_all from './endpoints/following/update-all.js'; | ||||
| import * as ep___following_invalidate from './endpoints/following/invalidate.js'; | ||||
| import * as ep___following_requests_accept from './endpoints/following/requests/accept.js'; | ||||
| import * as ep___following_requests_cancel from './endpoints/following/requests/cancel.js'; | ||||
| @@ -518,6 +519,7 @@ const eps = [ | ||||
| 	['following/create', ep___following_create], | ||||
| 	['following/delete', ep___following_delete], | ||||
| 	['following/update', ep___following_update], | ||||
| 	['following/update-all', ep___following_update_all], | ||||
| 	['following/invalidate', ep___following_invalidate], | ||||
| 	['following/requests/accept', ep___following_requests_accept], | ||||
| 	['following/requests/cancel', ep___following_requests_cancel], | ||||
|   | ||||
| @@ -0,0 +1,54 @@ | ||||
| /* | ||||
|  * SPDX-FileCopyrightText: syuilo and other misskey contributors | ||||
|  * SPDX-License-Identifier: AGPL-3.0-only | ||||
|  */ | ||||
|  | ||||
| import ms from 'ms'; | ||||
| import { Inject, Injectable } from '@nestjs/common'; | ||||
| import { Endpoint } from '@/server/api/endpoint-base.js'; | ||||
| import type { FollowingsRepository } from '@/models/_.js'; | ||||
| import { UserEntityService } from '@/core/entities/UserEntityService.js'; | ||||
| import { UserFollowingService } from '@/core/UserFollowingService.js'; | ||||
| import { DI } from '@/di-symbols.js'; | ||||
| import { GetterService } from '@/server/api/GetterService.js'; | ||||
| import { ApiError } from '../../error.js'; | ||||
|  | ||||
| export const meta = { | ||||
| 	tags: ['following', 'users'], | ||||
|  | ||||
| 	limit: { | ||||
| 		duration: ms('1hour'), | ||||
| 		max: 10, | ||||
| 	}, | ||||
|  | ||||
| 	requireCredential: true, | ||||
|  | ||||
| 	kind: 'write:following', | ||||
| } as const; | ||||
|  | ||||
| export const paramDef = { | ||||
| 	type: 'object', | ||||
| 	properties: { | ||||
| 		notify: { type: 'string', enum: ['normal', 'none'] }, | ||||
| 		withReplies: { type: 'boolean' }, | ||||
| 	}, | ||||
| } as const; | ||||
|  | ||||
| @Injectable() | ||||
| export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export | ||||
| 	constructor( | ||||
| 		@Inject(DI.followingsRepository) | ||||
| 		private followingsRepository: FollowingsRepository, | ||||
| 	) { | ||||
| 		super(meta, paramDef, async (ps, me) => { | ||||
| 			await this.followingsRepository.update({ | ||||
| 				followerId: me.id, | ||||
| 			}, { | ||||
| 				notify: ps.notify != null ? (ps.notify === 'none' ? null : ps.notify) : undefined, | ||||
| 				withReplies: ps.withReplies != null ? ps.withReplies : undefined, | ||||
| 			}); | ||||
|  | ||||
| 			return; | ||||
| 		}); | ||||
| 	} | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 anatawa12
					anatawa12