Merge branch 'develop'
This commit is contained in:
commit
9c1d79909d
@ -12,4 +12,7 @@
|
||||
cache: false,
|
||||
},
|
||||
assets_base_dir: 'downloads',
|
||||
user_redirections: [
|
||||
{from: 'arisu', to: 'ashpie'}
|
||||
],
|
||||
}
|
||||
|
@ -2,4 +2,5 @@
|
||||
log_level: "DEBUG",
|
||||
db_log_level: "ERROR",
|
||||
public_url: "https://update.eternae.ink",
|
||||
user_redirections: [],
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "eternae.ink.update",
|
||||
"version": "1.2.4",
|
||||
"version": "1.3.0",
|
||||
"description": "A simple redirection to serve a gitea instance's repositories' latest release files as an http file server. (302 redirections)",
|
||||
"repository": "https://eternae.ink/arisu/update.eternae.ink",
|
||||
"author": "Alice Gaudon <alice@gaudon.pro>",
|
||||
|
@ -9,6 +9,7 @@ import path from "path";
|
||||
import sendRanges, {SendRangeGetStreamFn} from "send-ranges";
|
||||
import mime from "mime";
|
||||
import {logger} from "swaf/Logger";
|
||||
import {ParsedUrlQueryInput} from "querystring";
|
||||
|
||||
export const ASSETS_BASE_DIR = config.get<string>('assets_base_dir');
|
||||
|
||||
@ -22,6 +23,14 @@ export default class GiteaRepoLatestReleaseController extends Controller {
|
||||
const {owner, name, file} = req.params;
|
||||
if (!owner || !name) return next();
|
||||
|
||||
// User redirections
|
||||
const userRedirections = config.get<{ from: string, to: string }[]>('user_redirections');
|
||||
for (const redirection of userRedirections) {
|
||||
if (owner === redirection.from) {
|
||||
return res.redirect(Controller.route('get-repo-release-file', [redirection.to, name, file], req.query as ParsedUrlQueryInput));
|
||||
}
|
||||
}
|
||||
|
||||
const httpRequest = https.get(`${config.get('gitea_instance_url')}/api/v1/repos/${owner}/${name}/releases`, {
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
|
Loading…
Reference in New Issue
Block a user