1
0
forked from mirror/misskey
This commit is contained in:
syuilo 2019-05-18 22:54:02 +09:00
parent 318d7f2652
commit 9dbe12135d
No known key found for this signature in database
GPG Key ID: BDC4C49D06AB9D69

View File

@ -2,7 +2,7 @@ import $ from 'cafy';
import { ID } from '../../../../../misc/cafy-id';
import define from '../../../define';
import { ApiError } from '../../../error';
import { UserGroups } from '../../../../../models';
import { UserGroups, UserGroupJoinings } from '../../../../../models';
import { types, bool } from '../../../../../misc/schema';
export const meta = {
@ -42,12 +42,20 @@ export default define(meta, async (ps, me) => {
// Fetch the group
const userGroup = await UserGroups.findOne({
id: ps.groupId,
userId: me.id,
});
if (userGroup == null) {
throw new ApiError(meta.errors.noSuchGroup);
}
const joining = await UserGroupJoinings.findOne({
userId: me.id,
userGroupId: userGroup.id
});
if (joining == null && userGroup.userId !== me.id) {
throw new ApiError(meta.errors.noSuchGroup);
}
return await UserGroups.pack(userGroup);
});