mirror of
https://github.com/hotomoe/hotomoe
synced 2024-11-29 15:28:13 +09:00
refactor: ApDeliverManagerService.tsの型とJSDocを適切に置き換え (#11096)
* refactor: ApDeliverManagerService.ts のanyを適切な型に置き換え Signed-off-by: Umisyo <kusunokisouta@gmail.com> * fix: quote to single quote Signed-off-by: Umisyo <kusunokisouta@gmail.com> * refactor: JSDocを実態に合わせて修正 Signed-off-by: Umisyo <kusunokisouta@gmail.com> * fix: activityのnullを許容するよう変更 Signed-off-by: Umisyo <kusunokisouta@gmail.com> --------- Signed-off-by: Umisyo <kusunokisouta@gmail.com> Co-authored-by: tamaina <tamaina@hotmail.co.jp>
This commit is contained in:
parent
22227fa641
commit
8f94b36732
@ -7,6 +7,7 @@ import type { LocalUser, RemoteUser, User } from '@/models/entities/User.js';
|
|||||||
import { QueueService } from '@/core/QueueService.js';
|
import { QueueService } from '@/core/QueueService.js';
|
||||||
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
|
import type { IActivity } from '@/core/activitypub/type.js';
|
||||||
import { ThinUser } from '@/queue/types.js';
|
import { ThinUser } from '@/queue/types.js';
|
||||||
|
|
||||||
interface IRecipe {
|
interface IRecipe {
|
||||||
@ -22,10 +23,10 @@ interface IDirectRecipe extends IRecipe {
|
|||||||
to: RemoteUser;
|
to: RemoteUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isFollowers = (recipe: any): recipe is IFollowersRecipe =>
|
const isFollowers = (recipe: IRecipe): recipe is IFollowersRecipe =>
|
||||||
recipe.type === 'Followers';
|
recipe.type === 'Followers';
|
||||||
|
|
||||||
const isDirect = (recipe: any): recipe is IDirectRecipe =>
|
const isDirect = (recipe: IRecipe): recipe is IDirectRecipe =>
|
||||||
recipe.type === 'Direct';
|
recipe.type === 'Direct';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -47,11 +48,11 @@ export class ApDeliverManagerService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Deliver activity to followers
|
* Deliver activity to followers
|
||||||
|
* @param actor
|
||||||
* @param activity Activity
|
* @param activity Activity
|
||||||
* @param from Followee
|
|
||||||
*/
|
*/
|
||||||
@bindThis
|
@bindThis
|
||||||
public async deliverToFollowers(actor: { id: LocalUser['id']; host: null; }, activity: any) {
|
public async deliverToFollowers(actor: { id: LocalUser['id']; host: null; }, activity: IActivity) {
|
||||||
const manager = new DeliverManager(
|
const manager = new DeliverManager(
|
||||||
this.userEntityService,
|
this.userEntityService,
|
||||||
this.followingsRepository,
|
this.followingsRepository,
|
||||||
@ -65,11 +66,12 @@ export class ApDeliverManagerService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Deliver activity to user
|
* Deliver activity to user
|
||||||
|
* @param actor
|
||||||
* @param activity Activity
|
* @param activity Activity
|
||||||
* @param to Target user
|
* @param to Target user
|
||||||
*/
|
*/
|
||||||
@bindThis
|
@bindThis
|
||||||
public async deliverToUser(actor: { id: LocalUser['id']; host: null; }, activity: any, to: RemoteUser) {
|
public async deliverToUser(actor: { id: LocalUser['id']; host: null; }, activity: IActivity, to: RemoteUser) {
|
||||||
const manager = new DeliverManager(
|
const manager = new DeliverManager(
|
||||||
this.userEntityService,
|
this.userEntityService,
|
||||||
this.followingsRepository,
|
this.followingsRepository,
|
||||||
@ -82,7 +84,7 @@ export class ApDeliverManagerService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public createDeliverManager(actor: { id: User['id']; host: null; }, activity: any) {
|
public createDeliverManager(actor: { id: User['id']; host: null; }, activity: IActivity | null) {
|
||||||
return new DeliverManager(
|
return new DeliverManager(
|
||||||
this.userEntityService,
|
this.userEntityService,
|
||||||
this.followingsRepository,
|
this.followingsRepository,
|
||||||
@ -96,11 +98,14 @@ export class ApDeliverManagerService {
|
|||||||
|
|
||||||
class DeliverManager {
|
class DeliverManager {
|
||||||
private actor: ThinUser;
|
private actor: ThinUser;
|
||||||
private activity: any;
|
private activity: IActivity | null;
|
||||||
private recipes: IRecipe[] = [];
|
private recipes: IRecipe[] = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
* @param userEntityService
|
||||||
|
* @param followingsRepository
|
||||||
|
* @param queueService
|
||||||
* @param actor Actor
|
* @param actor Actor
|
||||||
* @param activity Activity to deliver
|
* @param activity Activity to deliver
|
||||||
*/
|
*/
|
||||||
@ -110,7 +115,7 @@ class DeliverManager {
|
|||||||
private queueService: QueueService,
|
private queueService: QueueService,
|
||||||
|
|
||||||
actor: { id: User['id']; host: null; },
|
actor: { id: User['id']; host: null; },
|
||||||
activity: any,
|
activity: IActivity | null,
|
||||||
) {
|
) {
|
||||||
// 型で弾いてはいるが一応ローカルユーザーかチェック
|
// 型で弾いてはいるが一応ローカルユーザーかチェック
|
||||||
if (actor.host != null) throw new Error('actor.host must be null');
|
if (actor.host != null) throw new Error('actor.host must be null');
|
||||||
|
Loading…
Reference in New Issue
Block a user