Skip to content

Commit

Permalink
feat: add support for making communities in admin panel (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
CaramelKat committed Jul 29, 2024
1 parent 6cdddce commit 4c39b25
Show file tree
Hide file tree
Showing 11 changed files with 653 additions and 178 deletions.
194 changes: 28 additions & 166 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"mongoose-fuzzy-search-next": "^1.0.13",
"mongoose-unique-validator": "^3.0.0",
"morgan": "^1.10.0",
"multer": "^1.4.5-lts.1",
"nice-grpc": "^2.1.4",
"node-rsa": "^1.1.1",
"node-snowflake": "0.0.1",
Expand All @@ -60,7 +61,6 @@
"eslint": "^8.42.0",
"express-slow-down": "^1.4.0",
"express-subdomain": "^1.0.5",
"multer": "^1.4.2",
"request": "^2.88.2",
"tsc-alias": "^1.8.6",
"typescript": "^5.1.3"
Expand Down
19 changes: 16 additions & 3 deletions src/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,24 @@ function verifyConnected() {
}
}

async function getCommunities(numberOfCommunities) {
async function getCommunities(numberOfCommunities, offset) {
verifyConnected();
if (!offset) {
offset = 0;
}
if (numberOfCommunities === -1) {
return COMMUNITY.find({ parent: null, type: [0,2] });
return COMMUNITY.find({ parent: null, type: [0,2] }).skip(offset);
} else {
return COMMUNITY.find({ parent: null, type: [0,2] }).skip(offset).limit(numberOfCommunities);
}
}

async function getCommunitiesFuzzySearch(search_key, limit, offset) {
verifyConnected();
if (limit === -1) {
return COMMUNITY.find(FuzzySearch(['name'], search_key)).skip(offset);
} else {
return COMMUNITY.find({ parent: null, type: [0,2] }).limit(numberOfCommunities);
return COMMUNITY.find(FuzzySearch(['name'], search_key)).skip(offset).limit(limit);
}
}

Expand Down Expand Up @@ -492,6 +504,7 @@ async function getReportById(id) {
module.exports = {
connect,
getCommunities,
getCommunitiesFuzzySearch,
getMostPopularCommunities,
getNewCommunities,
getSubCommunities,
Expand Down
1 change: 1 addition & 0 deletions src/middleware/checkBan.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ async function checkBan(request, response, next) {
}
// Set moderator status
request.moderator = request.user.accessLevel == 2 || request.user.accessLevel == 3;
request.developer = request.user.accessLevel == 3;
const user = await db.getUserSettings(request.pid);
if (user && moment(user.ban_lift_date) <= moment() && user.account_status !== 3) {
user.account_status = 0;
Expand Down
Loading

0 comments on commit 4c39b25

Please sign in to comment.