mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-25 00:49:17 +09:00
WIP(ApPersonService.ts
): analyzeAttachments
- Field型を事前に定義しておくように - `attachments`が`IObject`だった場合、返り値が`{ fields: [] }`になるようだが構わないのか? - `toArray()`を通すべきでは?
This commit is contained in:
parent
d276dabf26
commit
785a5f6f68
@ -48,6 +48,8 @@ import type { IActor, IObject } from '../type.js';
|
|||||||
const nameLength = 128;
|
const nameLength = 128;
|
||||||
const summaryLength = 2048;
|
const summaryLength = 2048;
|
||||||
|
|
||||||
|
type Field = Record<'name' | 'value', string>;
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ApPersonService implements OnModuleInit {
|
export class ApPersonService implements OnModuleInit {
|
||||||
private utilityService: UtilityService;
|
private utilityService: UtilityService;
|
||||||
@ -576,11 +578,10 @@ export class ApPersonService implements OnModuleInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public analyzeAttachments(attachments: IObject | IObject[] | undefined) {
|
// TODO: `attachments`が`IObject`だった場合、返り値が`{ fields: [] }`になるようだが構わないのか?
|
||||||
const fields: {
|
public analyzeAttachments(attachments: IObject | IObject[] | undefined): { fields: Field[] } {
|
||||||
name: string,
|
const fields: Field[] = [];
|
||||||
value: string
|
|
||||||
}[] = [];
|
|
||||||
if (Array.isArray(attachments)) {
|
if (Array.isArray(attachments)) {
|
||||||
for (const attachment of attachments.filter(isPropertyValue)) {
|
for (const attachment of attachments.filter(isPropertyValue)) {
|
||||||
fields.push({
|
fields.push({
|
||||||
|
Loading…
Reference in New Issue
Block a user