2021-08-19 14:55:45 +02:00
|
|
|
import define from '../../../define';
|
|
|
|
import { UserGroups } from '@/models/index';
|
2019-05-18 13:36:33 +02:00
|
|
|
|
|
|
|
export const meta = {
|
|
|
|
tags: ['groups', 'account'],
|
|
|
|
|
2020-02-15 13:33:32 +01:00
|
|
|
requireCredential: true as const,
|
2019-05-18 13:36:33 +02:00
|
|
|
|
|
|
|
kind: 'read:user-groups',
|
|
|
|
|
|
|
|
res: {
|
2019-06-27 11:04:09 +02:00
|
|
|
type: 'array' as const,
|
|
|
|
optional: false as const, nullable: false as const,
|
2019-05-18 13:36:33 +02:00
|
|
|
items: {
|
2019-06-27 11:04:09 +02:00
|
|
|
type: 'object' as const,
|
|
|
|
optional: false as const, nullable: false as const,
|
2019-05-18 13:36:33 +02:00
|
|
|
ref: 'UserGroup',
|
2021-12-09 15:58:30 +01:00
|
|
|
},
|
2019-05-18 13:36:33 +02:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
export default define(meta, async (ps, me) => {
|
|
|
|
const userGroups = await UserGroups.find({
|
|
|
|
userId: me.id,
|
|
|
|
});
|
|
|
|
|
|
|
|
return await Promise.all(userGroups.map(x => UserGroups.pack(x)));
|
|
|
|
});
|