 8d06a6475e
			
		
	
	8d06a6475e
	
	
	
		
			
			* chore: 著作権とライセンスについての情報を各ファイルに追加する * chore: Add the SPDX information to each file Add copyright and licensing information as defined in version 3.0 of the REUSE Specification. * tweak format --------- Co-authored-by: syuilo <Syuilotan@yahoo.co.jp> * chore: Add SPDX-License-Identifier [skip ci] * add missing SPDX-License-Identifier * remove unused file --------- Co-authored-by: Shun Sakai <sorairolake@protonmail.ch> Co-authored-by: syuilo <Syuilotan@yahoo.co.jp> Co-authored-by: Chocolate Pie <106949016+chocolate-pie@users.noreply.github.com>
		
			
				
	
	
		
			46 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| /*
 | |
|  * SPDX-FileCopyrightText: syuilo and other misskey contributors
 | |
|  * SPDX-License-Identifier: AGPL-3.0-only
 | |
|  */
 | |
| 
 | |
| import { Inject, Injectable } from '@nestjs/common';
 | |
| import { DI } from '@/di-symbols.js';
 | |
| import type { UsersRepository } from '@/models/index.js';
 | |
| import type { Config } from '@/config.js';
 | |
| import type { User } from '@/models/entities/User.js';
 | |
| import { ApRendererService } from '@/core/activitypub/ApRendererService.js';
 | |
| import { RelayService } from '@/core/RelayService.js';
 | |
| import { ApDeliverManagerService } from '@/core/activitypub/ApDeliverManagerService.js';
 | |
| import { UserEntityService } from '@/core/entities/UserEntityService.js';
 | |
| import { bindThis } from '@/decorators.js';
 | |
| 
 | |
| @Injectable()
 | |
| export class AccountUpdateService {
 | |
| 	constructor(
 | |
| 		@Inject(DI.config)
 | |
| 		private config: Config,
 | |
| 
 | |
| 		@Inject(DI.usersRepository)
 | |
| 		private usersRepository: UsersRepository,
 | |
| 
 | |
| 		private userEntityService: UserEntityService,
 | |
| 		private apRendererService: ApRendererService,
 | |
| 		private apDeliverManagerService: ApDeliverManagerService,
 | |
| 		private relayService: RelayService,
 | |
| 	) {
 | |
| 	}
 | |
| 
 | |
| 	@bindThis
 | |
| 	public async publishToFollowers(userId: User['id']) {
 | |
| 		const user = await this.usersRepository.findOneBy({ id: userId });
 | |
| 		if (user == null) throw new Error('user not found');
 | |
| 
 | |
| 		// フォロワーがリモートユーザーかつ投稿者がローカルユーザーならUpdateを配信
 | |
| 		if (this.userEntityService.isLocalUser(user)) {
 | |
| 			const content = this.apRendererService.addContext(this.apRendererService.renderUpdate(await this.apRendererService.renderPerson(user), user));
 | |
| 			this.apDeliverManagerService.deliverToFollowers(user, content);
 | |
| 			this.relayService.deliverToRelays(user, content);
 | |
| 		}
 | |
| 	}
 | |
| }
 |