Frostbite is gone????
Some checks failed
Galvanic Corrosion Cross-Compile / build (push) Failing after 38s
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:
@@ -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()]);
|
||||
}
|
||||
},
|
||||
|
||||
);
|
||||
Reference in New Issue
Block a user