Frostbite is gone????
Some checks failed
Galvanic Corrosion Cross-Compile / build (push) Failing after 38s

* Rewrite rooms backend, "RoomFactory" and "SubroomFactory"
    - Used for modifying and fetching rooms
* Progression and reputation bulk endpoints
* Announcement endpoint temp
* OOBE is now the only initial pref key
    - Will be removed in the future when cohortnux is implemented
* Misc minor fixes and clarifications
* Simplified namegen dictionary
    - The previous one was generated with ChatGPT, hence the duplicated strings. I googled "random username generator" and borrowed a random result's generation dictionary.
* QuickPlay support with "initialRoom" in config (untested)
This commit is contained in:
2025-04-15 21:15:15 -04:00
parent 1672f2af91
commit 5c69269b70
22 changed files with 1021 additions and 680 deletions

View File

@@ -0,0 +1,30 @@
/* Galvanic Corrosion - Rec Room custom server for communities.
<https://gitea.proxnet.dev/zombieb/galvanic-corrosion>
Copyright (C) 2025 @zombieb (Discord / proxnet Gitea)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
import { APIUtils } from "../../apiutils.ts";
import { AuthType } from "../../data/users.ts";
export const route = APIUtils.createRouter("/announcement");
route.router.get('/v1/get',
APIUtils.Authentication,
APIUtils.AuthenticationType(AuthType.Game),
APIUtils.emptyArrayResponse
);

View File

@@ -15,7 +15,8 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
import { APIUtils } from "../../apiutils.ts";
import { z } from "zod";
import { APIUtils, NoBody } from "../../apiutils.ts";
import UnifiedProfile from "../../data/profiles.ts";
import { AuthType } from "../../data/users.ts";
import express from "express";
@@ -40,14 +41,36 @@ route.router.get('/v1/:id',
);
route.router.get('/v1/bulk',
interface ReputationBulkBody {
Ids: string[] | string
}
const reputationBulkSchema = z.object({
Ids: z.union([
z.array(z.string()),
z.string()
])
});
route.router.post('/v1/bulk',
APIUtils.Authentication,
APIUtils.AuthenticationType(AuthType.Game),
express.urlencoded({ extended: true }),
APIUtils.logBody,
APIUtils.validateRequestBody(reputationBulkSchema),
APIUtils.emptyArrayResponse
async (rq: express.Request<NoBody, {}, ReputationBulkBody>, rs: express.Response) => {
if (typeof rq.body.Ids == 'object') {
const reputations = rq.body.Ids
.map(id => parseInt(id)).filter(id => !isNaN(id)) // parse as int[] and filter out non-numbers
.map(id => UnifiedProfile.get(id).Reputation.getReputation()); // get all reputations
rs.json(await Promise.all(reputations));
} else {
const id = parseInt(rq.body.Ids);
if (isNaN(id)) {
rs.sendStatus(400);
return;
}
rs.json([await UnifiedProfile.get(id).Reputation.getReputation()]);
}
},
);

View File

@@ -16,10 +16,11 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
import Logging from "@proxnet/undead-logging";
import { APIUtils } from "../../apiutils.ts";
import { APIUtils, NoBody } from "../../apiutils.ts";
import express from "express";
import UnifiedProfile from "../../data/profiles.ts";
import { AuthType } from "../../data/users.ts";
import { z } from "zod";
const log = new Logging("ProgressionRoute");
@@ -51,13 +52,36 @@ route.router.get('/v1/progression/:id',
);
interface ProgressionBulkBody {
Ids: string[] | string
}
const progressionBulkSchema = z.object({
Ids: z.union([
z.array(z.string()),
z.string()
])
});
route.router.post('/v1/progression/bulk',
APIUtils.Authentication,
APIUtils.AuthenticationType(AuthType.Game),
express.urlencoded({ extended: true }),
APIUtils.logBody,
APIUtils.validateRequestBody(progressionBulkSchema),
APIUtils.emptyArrayResponse
async (rq: express.Request<NoBody, {}, ProgressionBulkBody>, rs: express.Response) => {
if (typeof rq.body.Ids == 'object') {
const progressions = rq.body.Ids
.map(id => parseInt(id)).filter(id => !isNaN(id)) // filter out non-numbers
.map(id => UnifiedProfile.get(id).Progression.export()); // get all progressions
rs.json(await Promise.all(progressions));
} else {
const id = parseInt(rq.body.Ids);
if (isNaN(id)) {
rs.sendStatus(400);
return;
}
rs.json([await UnifiedProfile.get(id).Progression.export()]);
}
},
);

View File

@@ -16,17 +16,21 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
import { APIUtils } from "../../apiutils.ts";
import { Config } from "../../config.ts";
import { AuthType } from "../../data/users.ts";
export const route = APIUtils.createRouter("/quickPlay");
const config = Config.getConfig();
route.router.get('/v1/getandclear',
APIUtils.Authentication,
APIUtils.AuthenticationType(AuthType.Game),
(_rq, rs) => {
rs.json({});
if (!config.public.initialRoom) rs.json({});
else rs.json({ RoomName: config.public.initialRoom });
}
);

View File

@@ -17,7 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. */
import { APIUtils } from "../../apiutils.ts";
import Rooms from "../../data/content/rooms.ts";
import { RoomAccessibility } from "../../data/content/roomtypes.ts";
import { RoomDataTypes } from "../../data/content/rooms/DataTypes.ts";
import { AuthType } from "../../data/users.ts";
import express from "express";
@@ -66,7 +66,7 @@ route.router.get('/v1/hot',
async (_rq, rs) => {
// temporary: return all public AG rooms for testing
const rooms = await Rooms.getAllBuiltinRoomGenerations();
rs.json(rooms.map(room => room.Room).filter(room => room.Accessibility == RoomAccessibility.Public));
rs.json(rooms.map(room => room.Room).filter(room => room.Accessibility == RoomDataTypes.RoomAccessibility.Public));
},
);