fix runtime error
This commit is contained in:
parent
35ffe3c52f
commit
af30959cb9
1 changed files with 67 additions and 67 deletions
|
@ -29,73 +29,6 @@ const isFollowers = (recipe: IRecipe): recipe is IFollowersRecipe =>
|
||||||
const isDirect = (recipe: IRecipe): recipe is IDirectRecipe =>
|
const isDirect = (recipe: IRecipe): recipe is IDirectRecipe =>
|
||||||
recipe.type === 'Direct';
|
recipe.type === 'Direct';
|
||||||
|
|
||||||
@Injectable()
|
|
||||||
export class ApDeliverManagerService {
|
|
||||||
constructor(
|
|
||||||
@Inject(DI.config)
|
|
||||||
private config: Config,
|
|
||||||
|
|
||||||
@Inject(DI.usersRepository)
|
|
||||||
private usersRepository: UsersRepository,
|
|
||||||
|
|
||||||
@Inject(DI.followingsRepository)
|
|
||||||
private followingsRepository: FollowingsRepository,
|
|
||||||
|
|
||||||
private userEntityService: UserEntityService,
|
|
||||||
private queueService: QueueService,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deliver activity to followers
|
|
||||||
* @param actor
|
|
||||||
* @param activity Activity
|
|
||||||
*/
|
|
||||||
@bindThis
|
|
||||||
public async deliverToFollowers(actor: { id: LocalUser['id']; host: null; }, activity: IActivity): Promise<void> {
|
|
||||||
const manager = new DeliverManager(
|
|
||||||
this.userEntityService,
|
|
||||||
this.followingsRepository,
|
|
||||||
this.queueService,
|
|
||||||
actor,
|
|
||||||
activity,
|
|
||||||
);
|
|
||||||
manager.addFollowersRecipe();
|
|
||||||
await manager.execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deliver activity to user
|
|
||||||
* @param actor
|
|
||||||
* @param activity Activity
|
|
||||||
* @param to Target user
|
|
||||||
*/
|
|
||||||
@bindThis
|
|
||||||
public async deliverToUser(actor: { id: LocalUser['id']; host: null; }, activity: IActivity, to: RemoteUser): Promise<void> {
|
|
||||||
const manager = new DeliverManager(
|
|
||||||
this.userEntityService,
|
|
||||||
this.followingsRepository,
|
|
||||||
this.queueService,
|
|
||||||
actor,
|
|
||||||
activity,
|
|
||||||
);
|
|
||||||
manager.addDirectRecipe(to);
|
|
||||||
await manager.execute();
|
|
||||||
}
|
|
||||||
|
|
||||||
@bindThis
|
|
||||||
public createDeliverManager(actor: { id: User['id']; host: null; }, activity: IActivity | null): DeliverManager {
|
|
||||||
return new DeliverManager(
|
|
||||||
this.userEntityService,
|
|
||||||
this.followingsRepository,
|
|
||||||
this.queueService,
|
|
||||||
|
|
||||||
actor,
|
|
||||||
activity,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class DeliverManager {
|
class DeliverManager {
|
||||||
private actor: ThinUser;
|
private actor: ThinUser;
|
||||||
private activity: IActivity | null;
|
private activity: IActivity | null;
|
||||||
|
@ -210,3 +143,70 @@ class DeliverManager {
|
||||||
this.queueService.deliverMany(this.actor, this.activity, inboxes);
|
this.queueService.deliverMany(this.actor, this.activity, inboxes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class ApDeliverManagerService {
|
||||||
|
constructor(
|
||||||
|
@Inject(DI.config)
|
||||||
|
private config: Config,
|
||||||
|
|
||||||
|
@Inject(DI.usersRepository)
|
||||||
|
private usersRepository: UsersRepository,
|
||||||
|
|
||||||
|
@Inject(DI.followingsRepository)
|
||||||
|
private followingsRepository: FollowingsRepository,
|
||||||
|
|
||||||
|
private userEntityService: UserEntityService,
|
||||||
|
private queueService: QueueService,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deliver activity to followers
|
||||||
|
* @param actor
|
||||||
|
* @param activity Activity
|
||||||
|
*/
|
||||||
|
@bindThis
|
||||||
|
public async deliverToFollowers(actor: { id: LocalUser['id']; host: null; }, activity: IActivity): Promise<void> {
|
||||||
|
const manager = new DeliverManager(
|
||||||
|
this.userEntityService,
|
||||||
|
this.followingsRepository,
|
||||||
|
this.queueService,
|
||||||
|
actor,
|
||||||
|
activity,
|
||||||
|
);
|
||||||
|
manager.addFollowersRecipe();
|
||||||
|
await manager.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deliver activity to user
|
||||||
|
* @param actor
|
||||||
|
* @param activity Activity
|
||||||
|
* @param to Target user
|
||||||
|
*/
|
||||||
|
@bindThis
|
||||||
|
public async deliverToUser(actor: { id: LocalUser['id']; host: null; }, activity: IActivity, to: RemoteUser): Promise<void> {
|
||||||
|
const manager = new DeliverManager(
|
||||||
|
this.userEntityService,
|
||||||
|
this.followingsRepository,
|
||||||
|
this.queueService,
|
||||||
|
actor,
|
||||||
|
activity,
|
||||||
|
);
|
||||||
|
manager.addDirectRecipe(to);
|
||||||
|
await manager.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
@bindThis
|
||||||
|
public createDeliverManager(actor: { id: User['id']; host: null; }, activity: IActivity | null): DeliverManager {
|
||||||
|
return new DeliverManager(
|
||||||
|
this.userEntityService,
|
||||||
|
this.followingsRepository,
|
||||||
|
this.queueService,
|
||||||
|
|
||||||
|
actor,
|
||||||
|
activity,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue