perf: limit number of antennas
This commit is contained in:
parent
71d4f5d516
commit
0c5be99d77
|
@ -23,6 +23,12 @@ export const meta = {
|
|||
code: "NO_SUCH_USER_GROUP",
|
||||
id: "aa3c0b9a-8cae-47c0-92ac-202ce5906682",
|
||||
},
|
||||
|
||||
tooManyAntennas: {
|
||||
message: "Too many antennas.",
|
||||
code: "TOO_MANY_ANTENNAS",
|
||||
id: "c3a5a51e-04d4-11ee-be56-0242ac120002",
|
||||
},
|
||||
},
|
||||
|
||||
res: {
|
||||
|
@ -97,6 +103,14 @@ export default define(meta, paramDef, async (ps, user) => {
|
|||
let userList;
|
||||
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) {
|
||||
userList = await UserLists.findOneBy({
|
||||
id: ps.userListId,
|
||||
|
|
Loading…
Reference in New Issue