2023-07-27 00:31:52 -05:00
|
|
|
/*
|
2024-02-11 20:37:45 -06:00
|
|
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-27 00:31:52 -05:00
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2022-09-17 13:27:08 -05:00
|
|
|
import { Inject, Injectable } from '@nestjs/common';
|
|
|
|
import { DI } from '@/di-symbols.js';
|
2023-09-15 00:28:29 -05:00
|
|
|
import type { AntennasRepository } from '@/models/_.js';
|
2023-03-09 23:22:37 -06:00
|
|
|
import type { Packed } from '@/misc/json-schema.js';
|
2023-09-19 21:33:36 -05:00
|
|
|
import type { MiAntenna } from '@/models/Antenna.js';
|
2022-12-04 00:03:09 -06:00
|
|
|
import { bindThis } from '@/decorators.js';
|
2023-10-15 20:45:22 -05:00
|
|
|
import { IdService } from '@/core/IdService.js';
|
2022-09-17 13:27:08 -05:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class AntennaEntityService {
|
|
|
|
constructor(
|
|
|
|
@Inject(DI.antennasRepository)
|
|
|
|
private antennasRepository: AntennasRepository,
|
2023-10-15 20:45:22 -05:00
|
|
|
|
|
|
|
private idService: IdService,
|
2022-09-17 13:27:08 -05:00
|
|
|
) {
|
|
|
|
}
|
|
|
|
|
2022-12-04 00:03:09 -06:00
|
|
|
@bindThis
|
2022-09-17 13:27:08 -05:00
|
|
|
public async pack(
|
2023-08-16 03:51:28 -05:00
|
|
|
src: MiAntenna['id'] | MiAntenna,
|
2022-09-17 13:27:08 -05:00
|
|
|
): Promise<Packed<'Antenna'>> {
|
|
|
|
const antenna = typeof src === 'object' ? src : await this.antennasRepository.findOneByOrFail({ id: src });
|
|
|
|
|
|
|
|
return {
|
|
|
|
id: antenna.id,
|
2023-10-15 20:45:22 -05:00
|
|
|
createdAt: this.idService.parse(antenna.id).date.toISOString(),
|
2022-09-17 13:27:08 -05:00
|
|
|
name: antenna.name,
|
|
|
|
keywords: antenna.keywords,
|
|
|
|
excludeKeywords: antenna.excludeKeywords,
|
|
|
|
src: antenna.src,
|
|
|
|
userListId: antenna.userListId,
|
|
|
|
users: antenna.users,
|
|
|
|
caseSensitive: antenna.caseSensitive,
|
2023-10-16 01:06:00 -05:00
|
|
|
localOnly: antenna.localOnly,
|
2022-09-17 13:27:08 -05:00
|
|
|
notify: antenna.notify,
|
|
|
|
withReplies: antenna.withReplies,
|
|
|
|
withFile: antenna.withFile,
|
2023-03-20 06:12:38 -05:00
|
|
|
isActive: antenna.isActive,
|
2023-04-02 22:11:16 -05:00
|
|
|
hasUnreadNote: false, // TODO
|
2022-09-17 13:27:08 -05:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|