mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-14 11:13:08 +02:00
1c67c26bd8
* wip * wip * wip * Update following.ts * wip * wip * wip * Update resolve-user.ts * maxQueryExecutionTime * wip * wip
24 lines
589 B
TypeScript
24 lines
589 B
TypeScript
import { db } from '@/db/postgre.js';
|
|
import { GalleryLike } from '@/models/entities/gallery-like.js';
|
|
import { GalleryPosts } from '../index.js';
|
|
|
|
export const GalleryLikeRepository = db.getRepository(GalleryLike).extend({
|
|
async pack(
|
|
src: GalleryLike['id'] | GalleryLike,
|
|
me?: any
|
|
) {
|
|
const like = typeof src === 'object' ? src : await this.findOneByOrFail({ id: src });
|
|
|
|
return {
|
|
id: like.id,
|
|
post: await GalleryPosts.pack(like.post || like.postId, me),
|
|
};
|
|
},
|
|
|
|
packMany(
|
|
likes: any[],
|
|
me: any
|
|
) {
|
|
return Promise.all(likes.map(x => this.pack(x, me)));
|
|
},
|
|
});
|