This commit is contained in:
syuilo
2021-12-09 23:58:30 +09:00
parent 0abe2dfee0
commit c69b72e199
573 changed files with 3318 additions and 3318 deletions

View File

@ -14,8 +14,8 @@ export const meta = {
params: {
name: {
validator: $.str.range(1, 100)
}
validator: $.str.range(1, 100),
},
},
res: {
@ -38,7 +38,7 @@ export default define(meta, async (ps, user) => {
id: genId(),
createdAt: new Date(),
userId: user.id,
userGroupId: userGroup.id
userGroupId: userGroup.id,
} as UserGroupJoining);
return await UserGroups.pack(userGroup);

View File

@ -14,22 +14,22 @@ export const meta = {
params: {
groupId: {
validator: $.type(ID),
}
},
},
errors: {
noSuchGroup: {
message: 'No such group.',
code: 'NO_SUCH_GROUP',
id: '63dbd64c-cd77-413f-8e08-61781e210b38'
}
}
id: '63dbd64c-cd77-413f-8e08-61781e210b38',
},
},
};
export default define(meta, async (ps, user) => {
const userGroup = await UserGroups.findOne({
id: ps.groupId,
userId: user.id
userId: user.id,
});
if (userGroup == null) {

View File

@ -23,9 +23,9 @@ export const meta = {
noSuchInvitation: {
message: 'No such invitation.',
code: 'NO_SUCH_INVITATION',
id: '98c11eca-c890-4f42-9806-c8c8303ebb5e'
id: '98c11eca-c890-4f42-9806-c8c8303ebb5e',
},
}
},
};
export default define(meta, async (ps, user) => {
@ -47,7 +47,7 @@ export default define(meta, async (ps, user) => {
id: genId(),
createdAt: new Date(),
userId: user.id,
userGroupId: invitation.userGroupId
userGroupId: invitation.userGroupId,
} as UserGroupJoining);
UserGroupInvitations.delete(invitation.id);

View File

@ -21,9 +21,9 @@ export const meta = {
noSuchInvitation: {
message: 'No such invitation.',
code: 'NO_SUCH_INVITATION',
id: 'ad7471d4-2cd9-44b4-ac68-e7136b4ce656'
id: 'ad7471d4-2cd9-44b4-ac68-e7136b4ce656',
},
}
},
};
export default define(meta, async (ps, user) => {

View File

@ -29,27 +29,27 @@ export const meta = {
noSuchGroup: {
message: 'No such group.',
code: 'NO_SUCH_GROUP',
id: '583f8bc0-8eee-4b78-9299-1e14fc91e409'
id: '583f8bc0-8eee-4b78-9299-1e14fc91e409',
},
noSuchUser: {
message: 'No such user.',
code: 'NO_SUCH_USER',
id: 'da52de61-002c-475b-90e1-ba64f9cf13a8'
id: 'da52de61-002c-475b-90e1-ba64f9cf13a8',
},
alreadyAdded: {
message: 'That user has already been added to that group.',
code: 'ALREADY_ADDED',
id: '7e35c6a0-39b2-4488-aea6-6ee20bd5da2c'
id: '7e35c6a0-39b2-4488-aea6-6ee20bd5da2c',
},
alreadyInvited: {
message: 'That user has already been invited to that group.',
code: 'ALREADY_INVITED',
id: 'ee0f58b4-b529-4d13-b761-b9a3e69f97e6'
}
}
id: 'ee0f58b4-b529-4d13-b761-b9a3e69f97e6',
},
},
};
export default define(meta, async (ps, me) => {
@ -71,7 +71,7 @@ export default define(meta, async (ps, me) => {
const joining = await UserGroupJoinings.findOne({
userGroupId: userGroup.id,
userId: user.id
userId: user.id,
});
if (joining) {
@ -80,7 +80,7 @@ export default define(meta, async (ps, me) => {
const existInvitation = await UserGroupInvitations.findOne({
userGroupId: userGroup.id,
userId: user.id
userId: user.id,
});
if (existInvitation) {
@ -91,12 +91,12 @@ export default define(meta, async (ps, me) => {
id: genId(),
createdAt: new Date(),
userId: user.id,
userGroupId: userGroup.id
userGroupId: userGroup.id,
} as UserGroupInvitation).then(x => UserGroupInvitations.findOneOrFail(x.identifiers[0]));
// 通知を作成
createNotification(user.id, 'groupInvited', {
notifierId: me.id,
userGroupInvitationId: invitation.id
userGroupInvitationId: invitation.id,
});
});

View File

@ -16,7 +16,7 @@ export const meta = {
type: 'object' as const,
optional: false as const, nullable: false as const,
ref: 'UserGroup',
}
},
},
};
@ -28,8 +28,8 @@ export default define(meta, async (ps, me) => {
const joinings = await UserGroupJoinings.find({
userId: me.id,
...(ownedGroups.length > 0 ? {
userGroupId: Not(In(ownedGroups.map(x => x.id)))
} : {})
userGroupId: Not(In(ownedGroups.map(x => x.id))),
} : {}),
});
return await Promise.all(joinings.map(x => UserGroups.pack(x.userGroupId)));

View File

@ -21,15 +21,15 @@ export const meta = {
noSuchGroup: {
message: 'No such group.',
code: 'NO_SUCH_GROUP',
id: '62780270-1f67-5dc0-daca-3eb510612e31'
id: '62780270-1f67-5dc0-daca-3eb510612e31',
},
youAreOwner: {
message: 'Your are the owner.',
code: 'YOU_ARE_OWNER',
id: 'b6d6e0c2-ef8a-9bb8-653d-79f4a3107c69'
id: 'b6d6e0c2-ef8a-9bb8-653d-79f4a3107c69',
},
}
},
};
export default define(meta, async (ps, me) => {

View File

@ -15,7 +15,7 @@ export const meta = {
type: 'object' as const,
optional: false as const, nullable: false as const,
ref: 'UserGroup',
}
},
},
};

View File

@ -26,21 +26,21 @@ export const meta = {
noSuchGroup: {
message: 'No such group.',
code: 'NO_SUCH_GROUP',
id: '4662487c-05b1-4b78-86e5-fd46998aba74'
id: '4662487c-05b1-4b78-86e5-fd46998aba74',
},
noSuchUser: {
message: 'No such user.',
code: 'NO_SUCH_USER',
id: '0b5cc374-3681-41da-861e-8bc1146f7a55'
id: '0b5cc374-3681-41da-861e-8bc1146f7a55',
},
isOwner: {
message: 'The user is the owner.',
code: 'IS_OWNER',
id: '1546eed5-4414-4dea-81c1-b0aec4f6d2af'
id: '1546eed5-4414-4dea-81c1-b0aec4f6d2af',
},
}
},
};
export default define(meta, async (ps, me) => {

View File

@ -27,9 +27,9 @@ export const meta = {
noSuchGroup: {
message: 'No such group.',
code: 'NO_SUCH_GROUP',
id: 'ea04751e-9b7e-487b-a509-330fb6bd6b9b'
id: 'ea04751e-9b7e-487b-a509-330fb6bd6b9b',
},
}
},
};
export default define(meta, async (ps, me) => {
@ -44,7 +44,7 @@ export default define(meta, async (ps, me) => {
const joining = await UserGroupJoinings.findOne({
userId: me.id,
userGroupId: userGroup.id
userGroupId: userGroup.id,
});
if (joining == null && userGroup.userId !== me.id) {

View File

@ -32,21 +32,21 @@ export const meta = {
noSuchGroup: {
message: 'No such group.',
code: 'NO_SUCH_GROUP',
id: '8e31d36b-2f88-4ccd-a438-e2d78a9162db'
id: '8e31d36b-2f88-4ccd-a438-e2d78a9162db',
},
noSuchUser: {
message: 'No such user.',
code: 'NO_SUCH_USER',
id: '711f7ebb-bbb9-4dfa-b540-b27809fed5e9'
id: '711f7ebb-bbb9-4dfa-b540-b27809fed5e9',
},
noSuchGroupMember: {
message: 'No such group member.',
code: 'NO_SUCH_GROUP_MEMBER',
id: 'd31bebee-196d-42c2-9a3e-9474d4be6cc4'
id: 'd31bebee-196d-42c2-9a3e-9474d4be6cc4',
},
}
},
};
export default define(meta, async (ps, me) => {
@ -68,7 +68,7 @@ export default define(meta, async (ps, me) => {
const joining = await UserGroupJoinings.findOne({
userGroupId: userGroup.id,
userId: user.id
userId: user.id,
});
if (joining == null) {
@ -76,7 +76,7 @@ export default define(meta, async (ps, me) => {
}
await UserGroups.update(userGroup.id, {
userId: ps.userId
userId: ps.userId,
});
return await UserGroups.pack(userGroup.id);

View File

@ -18,7 +18,7 @@ export const meta = {
name: {
validator: $.str.range(1, 100),
}
},
},
res: {
@ -31,16 +31,16 @@ export const meta = {
noSuchGroup: {
message: 'No such group.',
code: 'NO_SUCH_GROUP',
id: '9081cda3-7a9e-4fac-a6ce-908d70f282f6'
id: '9081cda3-7a9e-4fac-a6ce-908d70f282f6',
},
}
},
};
export default define(meta, async (ps, me) => {
// Fetch the group
const userGroup = await UserGroups.findOne({
id: ps.groupId,
userId: me.id
userId: me.id,
});
if (userGroup == null) {
@ -48,7 +48,7 @@ export default define(meta, async (ps, me) => {
}
await UserGroups.update(userGroup.id, {
name: ps.name
name: ps.name,
});
return await UserGroups.pack(userGroup.id);