Johann150
6ce4b3fe2f
Many of these were fixed automatically with eslint --fix. Some of them (e.g. adding return types to functions) were done manually.
20 lines
635 B
TypeScript
20 lines
635 B
TypeScript
import { db } from '@/db/postgre.js';
|
|
import { AuthSession } from '@/models/entities/auth-session.js';
|
|
import { User } from '@/models/entities/user.js';
|
|
import { awaitAll } from '@/prelude/await-all.js';
|
|
import { Apps } from '../index.js';
|
|
|
|
export const AuthSessionRepository = db.getRepository(AuthSession).extend({
|
|
async pack(
|
|
src: AuthSession['id'] | AuthSession,
|
|
me?: { id: User['id'] } | null | undefined,
|
|
) {
|
|
const session = typeof src === 'object' ? src : await this.findOneByOrFail({ id: src });
|
|
|
|
return await awaitAll({
|
|
id: session.id,
|
|
app: Apps.pack(session.appId, me),
|
|
token: session.token,
|
|
});
|
|
},
|
|
});
|