forked from FoundKeyGang/FoundKey
Fix bug
This commit is contained in:
parent
318d7f2652
commit
9dbe12135d
1 changed files with 10 additions and 2 deletions
|
@ -2,7 +2,7 @@ import $ from 'cafy';
|
||||||
import { ID } from '../../../../../misc/cafy-id';
|
import { ID } from '../../../../../misc/cafy-id';
|
||||||
import define from '../../../define';
|
import define from '../../../define';
|
||||||
import { ApiError } from '../../../error';
|
import { ApiError } from '../../../error';
|
||||||
import { UserGroups } from '../../../../../models';
|
import { UserGroups, UserGroupJoinings } from '../../../../../models';
|
||||||
import { types, bool } from '../../../../../misc/schema';
|
import { types, bool } from '../../../../../misc/schema';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
|
@ -42,12 +42,20 @@ export default define(meta, async (ps, me) => {
|
||||||
// Fetch the group
|
// Fetch the group
|
||||||
const userGroup = await UserGroups.findOne({
|
const userGroup = await UserGroups.findOne({
|
||||||
id: ps.groupId,
|
id: ps.groupId,
|
||||||
userId: me.id,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (userGroup == null) {
|
if (userGroup == null) {
|
||||||
throw new ApiError(meta.errors.noSuchGroup);
|
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);
|
return await UserGroups.pack(userGroup);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue