perf: limit number of antennas

This commit is contained in:
ThatOneCalculator 2023-06-06 18:47:06 -07:00
parent 71d4f5d516
commit 0c5be99d77
No known key found for this signature in database
GPG Key ID: 8703CACD01000000
1 changed files with 14 additions and 0 deletions

View File

@ -23,6 +23,12 @@ export const meta = {
code: "NO_SUCH_USER_GROUP", code: "NO_SUCH_USER_GROUP",
id: "aa3c0b9a-8cae-47c0-92ac-202ce5906682", id: "aa3c0b9a-8cae-47c0-92ac-202ce5906682",
}, },
tooManyAntennas: {
message: "Too many antennas.",
code: "TOO_MANY_ANTENNAS",
id: "c3a5a51e-04d4-11ee-be56-0242ac120002",
},
}, },
res: { res: {
@ -97,6 +103,14 @@ export default define(meta, paramDef, async (ps, user) => {
let userList; let userList;
let userGroupJoining; let userGroupJoining;
const antennas = await Antennas.findBy({
userId: user.id,
});
if (antennas.length > 5 && !user.isAdmin) {
throw new ApiError(meta.errors.tooManyAntennas)
}
if (ps.src === "list" && ps.userListId) { if (ps.src === "list" && ps.userListId) {
userList = await UserLists.findOneBy({ userList = await UserLists.findOneBy({
id: ps.userListId, id: ps.userListId,