2022-09-17 18:27:08 +00:00
|
|
|
import { Inject, Injectable } from '@nestjs/common';
|
|
|
|
import { DI } from '@/di-symbols.js';
|
2022-09-20 20:33:11 +00:00
|
|
|
import type { HashtagsRepository } from '@/models/index.js';
|
2023-03-10 05:22:37 +00:00
|
|
|
import type { Packed } from '@/misc/json-schema.js';
|
2022-09-17 18:27:08 +00:00
|
|
|
import type { } from '@/models/entities/Blocking.js';
|
|
|
|
import type { Hashtag } from '@/models/entities/Hashtag.js';
|
2022-12-04 06:03:09 +00:00
|
|
|
import { bindThis } from '@/decorators.js';
|
2023-03-10 05:22:37 +00:00
|
|
|
import { UserEntityService } from './UserEntityService.js';
|
2022-09-17 18:27:08 +00:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class HashtagEntityService {
|
|
|
|
constructor(
|
|
|
|
@Inject(DI.hashtagsRepository)
|
|
|
|
private hashtagsRepository: HashtagsRepository,
|
|
|
|
|
|
|
|
private userEntityService: UserEntityService,
|
|
|
|
) {
|
|
|
|
}
|
|
|
|
|
2022-12-04 06:03:09 +00:00
|
|
|
@bindThis
|
2022-09-17 18:27:08 +00:00
|
|
|
public async pack(
|
|
|
|
src: Hashtag,
|
|
|
|
): Promise<Packed<'Hashtag'>> {
|
|
|
|
return {
|
|
|
|
tag: src.name,
|
|
|
|
mentionedUsersCount: src.mentionedUsersCount,
|
|
|
|
mentionedLocalUsersCount: src.mentionedLocalUsersCount,
|
|
|
|
mentionedRemoteUsersCount: src.mentionedRemoteUsersCount,
|
|
|
|
attachedUsersCount: src.attachedUsersCount,
|
|
|
|
attachedLocalUsersCount: src.attachedLocalUsersCount,
|
|
|
|
attachedRemoteUsersCount: src.attachedRemoteUsersCount,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-12-04 06:03:09 +00:00
|
|
|
@bindThis
|
2022-09-17 18:27:08 +00:00
|
|
|
public packMany(
|
|
|
|
hashtags: Hashtag[],
|
|
|
|
) {
|
|
|
|
return Promise.all(hashtags.map(x => this.pack(x)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|