Skip to content

Commit 5f57934

Browse files
committed
new update gogogogo!
1 parent 35e4446 commit 5f57934

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1914
-584
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ file(GLOB SOURCES
1313
src/nodes/*.cpp
1414
src/ui/*.cpp
1515
src/ui/popups/*.cpp
16+
src/ui/admin/*.cpp
1617
src/ui/auth/*.cpp
1718
)
1819

changelog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# v1.4.0
2+
- Allowed clicking on users profiles in comments (will only work for players that authenticated with Object Workshop before)
3+
- Added \n for descriptions and comments
4+
- Changed clicking on usernames in comments to redirect to the users objects rather than profile
5+
- Allowed symbols in object names
6+
- Changed descriptions (mainly editing) to use RobTop's textarea (like comments)
7+
- Fixed bug where selecting an object in the workshop will not allow you to select in the editor unless you re-enter
8+
- Added warnings
19
# v1.3.1
210
- Fixed bug where going to a users profile while on another page will assume you want to go to that page
311
# v1.3.0

mod.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"geode": "3.7.1",
2+
"geode": "3.9.0",
33
"gd": {
44
"win": "2.206",
55
"android": "2.206",
@@ -8,7 +8,7 @@
88
},
99
"id": "firee.object-workshop",
1010
"name": "Object Workshop",
11-
"version": "v1.3.1",
11+
"version": "v1.4.0",
1212
"developer": "Firee",
1313
"description": "Download, upload, or find custom objects made by other creators!",
1414
"resources": {
@@ -61,6 +61,11 @@
6161
"id": "alphalaneous.editortab_api",
6262
"version": ">=v1.0.0",
6363
"importance": "required"
64+
},
65+
{
66+
"id": "geode.node-ids",
67+
"version": ">=1.14.1",
68+
"importance": "required"
6469
}
6570
]
6671
}

resources/blueButton.png

4.1 KB
Loading

resources/profileObjBtn.png

10.8 KB
Loading

server/src/Components/Case.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export default interface CaseData {
2+
id: number;
3+
case_type: number;
4+
account_id: number;
5+
staff_account_id: number;
6+
reason: string;
7+
timestamp: Date | number;
8+
expiration: Date | number;
9+
ack: boolean;
10+
ack_timestamp: Date | number;
11+
};

server/src/controllers/objects.ts

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import ObjectData from '@/Components/Object';
44
import { getCache } from '../postgres';
55
import { Router, Request, Response } from 'express'
66
import { query, body, param, validationResult, CustomValidator } from 'express-validator';
7-
import { verifyToken } from './user';
7+
import { verifyToken, banCheck } from './user';
88
import axios from 'axios';
99
import moment from 'moment'
1010
import { UserData } from '@/Components/User';
1111

12-
const allowedTags = ["Font", "Decoration", "Gameplay", "Art", "Structure", "Custom", "Icon", "Meme", "Technical", "Particles", "Triggers", "SFX", "Effects", "Auto Build"];
12+
const allowedTags = ["Font", "Decoration", "Gameplay", "Art", "Structure", "Custom", "Icon", "Meme", "Technical", "Particles", "Triggers", "SFX", "Effects", "Auto Build", "Recreation"];
1313

1414
const oRouter = Router();
1515

@@ -138,7 +138,7 @@ oRouter.post('/objects/upload',
138138
const { token, name, description, data } = req.body;
139139
let tags = req.body.tags as Array<string>;
140140
if (name.length > 64) return res.status(413).json({error: "The name cannot be more than 64 characters long!"});
141-
if (description.length > 300) return res.status(413).json({error: "The description cannot be more than 300 characters long!"});
141+
if (description.length > 500) return res.status(413).json({error: "The description cannot be more than 500 characters long!"});
142142
const splitData: Array<string> = data.split(";");
143143
if (splitData.length > 50000) return res.status(413).json({error: "You cannot upload a custom object with more than 50,000 objects!"})
144144
const hasBlacklistedIDs = splitData.find(objStr => {
@@ -164,7 +164,7 @@ oRouter.post('/objects/upload',
164164
return res.status(401).json({ error: verifyRes.message });
165165
}
166166
if (!verifyRes.user) return res.status(404).json({error: "Couldn't retrieve user."});
167-
if (verifyRes.user.role == -1) return res.status(403).json({error: "You are banned! Reason: " + verifyRes.user.ban_reason});
167+
if (banCheck(res, verifyRes.user, 1)) return;
168168
try {
169169
const dupCheck = await pool.query("SELECT id FROM objects WHERE data = $1 LIMIT 1;", [data]);
170170
if (dupCheck.rowCount != null && dupCheck.rowCount > 0) return res.status(409).json({error: "You cannot upload an object that already exists!"});
@@ -243,13 +243,13 @@ oRouter.post('/objects/:id/overwrite',
243243
return res.status(401).json({ error: verifyRes.message });
244244
}
245245
if (!verifyRes.user) return res.status(404).json({error: "Couldn't retrieve user."});
246-
if (verifyRes.user.role == -1) return res.status(403).json({error: "You are banned! Reason: " + verifyRes.user.ban_reason});
246+
if (banCheck(res, verifyRes.user, 1)) return;
247247
try {
248248
const query = await pool.query("SELECT * FROM objects WHERE id = $1 AND status != 3", [objectID])
249249
if (!query.rows.length) return res.status(404).json({error: "Object not found."});
250250
const objData: ObjectData = query.rows[0];
251251
if (objData.account_id != verifyRes.user.account_id) return res.status(403).json({error: "This is not your object!"});
252-
if (verifyRes.user.role == 0) {
252+
if (verifyRes.user.role == 0 && !objData.featured) {
253253
await pool.query("UPDATE objects SET data = $1, status = 0, updated_at = $2, version = version + 1 WHERE id = $3", [data, new Date(), objectID]);
254254
} else {
255255
await pool.query("UPDATE objects SET data = $1, updated_at = $2, version = version + 1 WHERE id = $3", [data, new Date(), objectID]);
@@ -333,7 +333,8 @@ oRouter.post('/objects/:id/rate',
333333
return res.status(401).json({ error: verifyRes.message });
334334
}
335335
const accountID = verifyRes.user?.account_id;
336-
if (verifyRes.user?.role == -1) return res.status(403).json({error: "You are banned! Reason: " + verifyRes.user.ban_reason});
336+
if (!verifyRes.user) return;
337+
if (banCheck(res, verifyRes.user, 3)) return;
337338
try {
338339
const objExists = await pool.query("SELECT EXISTS (SELECT 1 FROM objects WHERE id = $1 AND status = 1)", [objectID])
339340
if (!objExists.rows[0].exists) return res.status(404).json({error: "Object not found."});
@@ -377,8 +378,9 @@ oRouter.post('/objects/:id/comment',
377378
} else if (!verifyRes.valid) {
378379
return res.status(401).json({ error: verifyRes.message });
379380
}
380-
const accountID = verifyRes.user?.account_id;
381-
if (verifyRes.user?.role == -1) return res.status(403).json({error: "You are banned! Reason: " + verifyRes.user.ban_reason});
381+
if (!verifyRes.user) return;
382+
const accountID = verifyRes.user.account_id;
383+
if (banCheck(res, verifyRes.user, 2)) return;
382384
try {
383385
const objExists = await pool.query("SELECT EXISTS (SELECT 1 FROM objects WHERE id = $1 AND status = 1)", [objectID])
384386
if (!objExists.rows[0].exists) return res.status(404).json({error: "Object not found."});
@@ -415,8 +417,9 @@ oRouter.post('/objects/:id/comments/:commentid/pin',
415417
} else if (!verifyRes.valid) {
416418
return res.status(401).json({ error: verifyRes.message });
417419
}
418-
const accountID = verifyRes.user?.account_id;
419-
if (verifyRes.user?.role == -1) return res.status(403).json({error: "You are banned! Reason: " + verifyRes.user.ban_reason});
420+
if (!verifyRes.user) return;
421+
const accountID = verifyRes.user.account_id;
422+
if (banCheck(res, verifyRes.user, 3)) return;
420423
try {
421424
if (verifyRes.user && verifyRes.user.role == 3) {
422425
const objExists = await pool.query("SELECT EXISTS (SELECT 1 FROM objects WHERE id = $1)", [objectID])
@@ -520,8 +523,9 @@ oRouter.post('/objects/:id/comments/:commentid/delete',
520523
} else if (!verifyRes.valid) {
521524
return res.status(401).json({ error: verifyRes.message });
522525
}
526+
if (!verifyRes.user) return;
523527
const accountID = verifyRes.user?.account_id;
524-
if (verifyRes.user?.role == -1) return res.status(403).json({error: "You are banned! Reason: " + verifyRes.user.ban_reason});
528+
if (banCheck(res, verifyRes.user, 3)) return;
525529
try {
526530
const query = await pool.query("SELECT * FROM objects WHERE id = $1 AND status = 1", [objectID])
527531
if (!query.rows.length) return res.status(404).json({error: "Object not found."});
@@ -567,8 +571,9 @@ oRouter.post('/objects/:id/report',
567571
} else if (!verifyRes.valid) {
568572
return res.status(401).json({ error: verifyRes.message });
569573
}
570-
const accountID = verifyRes.user?.account_id;
571-
if (verifyRes.user?.role == -1) return res.status(403).json({error: "You are banned! Reason: " + verifyRes.user.ban_reason});
574+
if (!verifyRes.user) return;
575+
const accountID = verifyRes.user.account_id;
576+
if (banCheck(res, verifyRes.user, 1)) return;
572577
try {
573578
const objExists = await pool.query("SELECT EXISTS (SELECT 1 FROM objects WHERE id = $1 AND status = 1)", [objectID])
574579
if (!objExists.rows[0].exists) return res.status(404).json({error: "Object not found."});
@@ -736,7 +741,7 @@ oRouter.post('/objects/:id/update',
736741
const { token, name, description } = req.body;
737742
let tags = req.body.tags as Array<string>;
738743
if (name.length > 64) return res.status(413).json({error: "The name cannot be more than 64 characters long!"});
739-
if (description.length > 300) return res.status(413).json({error: "The description cannot be more than 300 characters long!"});
744+
if (description.length > 500) return res.status(413).json({error: "The description cannot be more than 500 characters long!"});
740745
if (!tags || !tags.length) tags = [];
741746
if (tags.length > 5) return res.status(413).json({error: "You can only add a maximum of 5 tags!"});
742747
getCache().then(pool => { // returns a PoolClient
@@ -1219,7 +1224,7 @@ oRouter.post('/objects/reports',
12191224
} else if (!verifyRes.valid) {
12201225
return res.status(401).json({ error: verifyRes.message });
12211226
}
1222-
if (verifyRes.user && verifyRes.user.role != 3) return res.status(403).json({ error: "No permission" });
1227+
if (verifyRes.user && verifyRes.user.role < 2) return res.status(403).json({ error: "No permission" });
12231228
const page = parseInt(req.query.page as string) || 1;
12241229
const limit = 9;
12251230
const offset = (page - 1) * limit;
@@ -1231,7 +1236,12 @@ oRouter.post('/objects/reports',
12311236
COALESCE(AVG(orate.stars), 0) as rating,
12321237
COUNT(orate.stars) as rating_count,
12331238
COUNT(*) OVER() AS total_records,
1234-
COUNT(rep) AS report_count
1239+
COUNT(rep) AS report_count,
1240+
COALESCE(ARRAY_AGG(DISTINCT jsonb_build_object(
1241+
'reason', rep.reason,
1242+
'account_id', rep.account_id,
1243+
'timestamp', rep.timestamp
1244+
)) FILTER (WHERE rep.object_id IS NOT NULL), '{}') AS reports
12351245
FROM
12361246
objects o
12371247
LEFT JOIN
@@ -1248,7 +1258,11 @@ oRouter.post('/objects/reports',
12481258
const totalRecords = (result.rows.length > 0) ? parseInt(result.rows[0].total_records) : 0;
12491259
const totalPages = Math.ceil(totalRecords / limit);
12501260

1251-
const objectData = convertRowsToObjects(result.rows)
1261+
const objectData = (convertRowsToObjects(result.rows) as Array<any>).map((value, index) => {
1262+
value.report_count = parseInt(result.rows[index].report_count);
1263+
value.reports = result.rows[index].reports;
1264+
return value;
1265+
});
12521266
res.json({
12531267
results: objectData,
12541268
page,

0 commit comments

Comments
 (0)