mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-15 06:53:08 +02:00
d071d18dd7
* wip * wip * fix * clean up * Update tsconfig.json * Update activitypub.ts * wip
39 lines
1.3 KiB
TypeScript
39 lines
1.3 KiB
TypeScript
import { EntityRepository, Repository } from 'typeorm';
|
|
import { Instance } from '@/models/entities/instance.js';
|
|
import { Packed } from '@/misc/schema.js';
|
|
|
|
@EntityRepository(Instance)
|
|
export class InstanceRepository extends Repository<Instance> {
|
|
public async pack(
|
|
instance: Instance,
|
|
): Promise<Packed<'FederationInstance'>> {
|
|
return {
|
|
id: instance.id,
|
|
caughtAt: instance.caughtAt.toISOString(),
|
|
host: instance.host,
|
|
usersCount: instance.usersCount,
|
|
notesCount: instance.notesCount,
|
|
followingCount: instance.followingCount,
|
|
followersCount: instance.followersCount,
|
|
latestRequestSentAt: instance.latestRequestSentAt ? instance.latestRequestSentAt.toISOString() : null,
|
|
lastCommunicatedAt: instance.lastCommunicatedAt.toISOString(),
|
|
isNotResponding: instance.isNotResponding,
|
|
isSuspended: instance.isSuspended,
|
|
softwareName: instance.softwareName,
|
|
softwareVersion: instance.softwareVersion,
|
|
openRegistrations: instance.openRegistrations,
|
|
name: instance.name,
|
|
description: instance.description,
|
|
maintainerName: instance.maintainerName,
|
|
maintainerEmail: instance.maintainerEmail,
|
|
iconUrl: instance.iconUrl,
|
|
infoUpdatedAt: instance.infoUpdatedAt ? instance.infoUpdatedAt.toISOString() : null,
|
|
};
|
|
}
|
|
|
|
public packMany(
|
|
instances: Instance[],
|
|
) {
|
|
return Promise.all(instances.map(x => this.pack(x)));
|
|
}
|
|
}
|