1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-25 19:52:36 +01:00

Change android and ios client downloads to use /download endpoint, update Release entity to suck less

This commit is contained in:
Madeline 2022-10-24 14:35:08 +11:00
parent 67a8c0d445
commit fc2ccc0b25
No known key found for this signature in database
GPG Key ID: 1958E017C36F2E47
6 changed files with 68 additions and 32 deletions

View File

@ -63,6 +63,23 @@ const doPatch = (content) => {
'e.exports = "/assets/',
);
// app download links
content = content.replaceAll(
"https://play.google.com/store/apps/details?id=com.discord",
"https://slowcord.understars.dev/api/download?platform=android",
);
content = content.replaceAll(
"https://itunes.apple.com/app/discord/id985746746",
"https://slowcord.understars.dev/api/download?platform=ios"
)
// TODO change public test build link
// content = content.replaceAll(
// "https://discord.com/download#ptb-card",
// ""
// )
return content;
};

View File

@ -15,7 +15,7 @@ export const NO_AUTHORIZATION_ROUTES = [
"/gateway",
"/experiments",
"/updates",
"/downloads/",
"/download",
"/scheduled-maintenances/upcoming.json",
// Public kubernetes integration
"/-/readyz",

View File

@ -0,0 +1,33 @@
import { Router, Response, Request } from "express";
import { route } from "@fosscord/api";
import { FieldErrors, Release } from "@fosscord/util";
const router = Router();
/*
TODO: Putting the download route in /routes/download.ts doesn't register the route, for some reason
But putting it here *does*
*/
router.get("/", route({}), async (req: Request, res: Response) => {
const { platform } = req.query;
if (!platform) throw FieldErrors({
platform: {
code: "BASE_TYPE_REQUIRED",
message: req.t("common:field.BASE_TYPE_REQUIRED"),
}
});
const release = await Release.findOneOrFail({
where: {
enabled: true,
platform: platform as string,
},
order: { pub_date: "DESC" }
});
res.redirect(release.url);
});
export default router;

View File

@ -1,23 +0,0 @@
import { Router, Response, Request } from "express";
import { route } from "@fosscord/api";
import { Release, Config } from "@fosscord/util";
const router = Router();
router.get("/:branch", route({}), async (req: Request, res: Response) => {
const { client } = Config.get();
const { branch } = req.params;
const { platform } = req.query;
//TODO
if (!platform || !["linux", "osx", "win"].includes(platform.toString()))
return res.status(404);
const release = await Release.findOneOrFail({
where: { name: client.releases.upstreamVersion },
});
res.redirect(release[`win_url`]);
});
export default router;

View File

@ -1,14 +1,26 @@
import { Router, Response, Request } from "express";
import { route } from "@fosscord/api";
import { Config, Release } from "@fosscord/util";
import { Config, FieldErrors, Release } from "@fosscord/util";
const router = Router();
router.get("/", route({}), async (req: Request, res: Response) => {
const { client } = Config.get();
const platform = req.query.platform;
if (!platform) throw FieldErrors({
platform: {
code: "BASE_TYPE_REQUIRED",
message: req.t("common:field.BASE_TYPE_REQUIRED"),
}
});
const release = await Release.findOneOrFail({
where: { name: client.releases.upstreamVersion },
where: {
enabled: true,
platform: platform as string,
},
order: { pub_date: "DESC" }
});
res.json({

View File

@ -7,19 +7,16 @@ export class Release extends BaseClass {
name: string;
@Column()
pub_date: string;
pub_date: Date;
@Column()
url: string;
@Column()
deb_url: string;
platform: string;
@Column()
osx_url: string;
@Column()
win_url: string;
enabled: boolean;
@Column({ nullable: true })
notes?: string;