mirror of
https://github.com/spacebarchat/server.git
synced 2026-04-15 09:15:40 +00:00
Merge branch 'master' into dupedEvents
This commit is contained in:
2
.idea/workspace.xml
generated
2
.idea/workspace.xml
generated
@@ -161,7 +161,7 @@
|
||||
<workItem from="1760044946282" duration="43683000" />
|
||||
<workItem from="1760402350251" duration="49898000" />
|
||||
<workItem from="1760538864442" duration="1330000" />
|
||||
<workItem from="1764432507485" duration="21512000" />
|
||||
<workItem from="1764432507485" duration="22274000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
|
||||
@@ -23,7 +23,7 @@ import { ApplicationDetectableResponse } from "@spacebar/schemas*";
|
||||
const router: Router = Router({ mergeParams: true });
|
||||
const cache = {
|
||||
data: {},
|
||||
lastUpdated: 0
|
||||
expires: 0
|
||||
}
|
||||
|
||||
router.get(
|
||||
@@ -37,14 +37,16 @@ router.get(
|
||||
}),
|
||||
async (req: Request, res: Response) => {
|
||||
// cache for 6 hours
|
||||
if (Date.now() - cache.lastUpdated > 6 * 60 * 60 * 1000) {
|
||||
const response = await fetch("https://discord.com/api/v10/applications/detectable"); // because, well, it's unauthenticated anyways
|
||||
if (Date.now() > cache.expires) {
|
||||
const response = await fetch("https://discord.com/api/v10/games/detectable"); // because, well, it's unauthenticated anyways
|
||||
const data = await response.json();
|
||||
cache.data = data as ApplicationDetectableResponse;
|
||||
cache.lastUpdated = Date.now();
|
||||
cache.expires = Date.now() + 6 * 60 * 60 * 1000;
|
||||
}
|
||||
|
||||
res.status(200).json(cache.data);
|
||||
res.set("Cache-Control", `public, max-age=${Math.floor((cache.expires - Date.now()) / 1000)}, s-maxage=${Math.floor((cache.expires - Date.now()) / 1000)}, immutable`)
|
||||
.status(200)
|
||||
.json(cache.data);
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@ import { ApplicationDetectableResponse } from "@spacebar/schemas*";
|
||||
const router: Router = Router({ mergeParams: true });
|
||||
const cache = {
|
||||
data: {},
|
||||
lastUpdated: 0
|
||||
}
|
||||
expires: 0,
|
||||
};
|
||||
|
||||
// modern dclients call this, is /applications/detectable deprecated?
|
||||
router.get(
|
||||
@@ -38,14 +38,16 @@ router.get(
|
||||
}),
|
||||
async (req: Request, res: Response) => {
|
||||
// cache for 6 hours
|
||||
if (Date.now() - cache.lastUpdated > 6 * 60 * 60 * 1000) {
|
||||
if (Date.now() > cache.expires) {
|
||||
const response = await fetch("https://discord.com/api/v10/games/detectable"); // because, well, it's unauthenticated anyways
|
||||
const data = await response.json();
|
||||
cache.data = data as ApplicationDetectableResponse;
|
||||
cache.lastUpdated = Date.now();
|
||||
cache.expires = Date.now() + 6 * 60 * 60 * 1000;
|
||||
}
|
||||
|
||||
res.status(200).json(cache.data);
|
||||
res.set("Cache-Control", `public, max-age=${Math.floor((cache.expires - Date.now()) / 1000)}, s-maxage=${Math.floor((cache.expires - Date.now()) / 1000)}, immutable`)
|
||||
.status(200)
|
||||
.json(cache.data);
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ router.patch(
|
||||
event: "PRESENCE_UPDATE",
|
||||
user_id: user.id,
|
||||
data: {
|
||||
user: user,
|
||||
user: user.toPublicUser(),
|
||||
activities: session.activities,
|
||||
client_status: session?.client_status,
|
||||
status: session.getPublicStatus(),
|
||||
|
||||
Reference in New Issue
Block a user