diff --git a/discord_embed/api/post.mjs b/discord_embed/api/post.mjs index 401161c..a79a7bc 100644 --- a/discord_embed/api/post.mjs +++ b/discord_embed/api/post.mjs @@ -16,7 +16,8 @@ export default class IndexPost { server.flaska.post('/', [ server.formidable({ maxFileSize: 8 * 1024 * 1024, }), ], this.createNewLink.bind(this)) - server.flaska.get('/video/:id', this.videoRedirect.bind(this)) + server.flaska.get('/video/secondary/:id', this.videoRedirect.bind(this)) + server.flaska.get('/video/:id', this.videoInbetweenRedirect.bind(this)) } async videoRedirect(ctx) { @@ -52,6 +53,17 @@ Redirecting return this.serve.serveIndex(ctx) } + async videoInbetweenRedirect(ctx) { + let location = '/video/secondary/' + ctx.params.id + ctx.status = 302 + ctx.headers['Location'] = location + ctx.type = 'application/octet-stream' + ctx.body = ` +Redirecting +Click here if it doesn't redirect +` + } + hasErrors(ctx, hasMedia) { if (!ctx.req.body.video) { return 'Missing video link' @@ -87,7 +99,6 @@ Redirecting try { let val = (await ctx.redis.get(redisKey)) - console.log(redisKey, val) val = val && Number(val) || 0 if (val > 3) { rateLimited = true @@ -136,7 +147,7 @@ Redirecting ctx.req.ip, ] let res = await ctx.db.safeCallProc('discord_embed.link_add', params) - id = AlphabeticID.encode(res.first[0].id + 3843) + let id = AlphabeticID.encode(res.first[0].id + 3843) redirect = `${this.frontend}/${id}` } catch (err) { diff --git a/discord_embed/package.json b/discord_embed/package.json index dfc4dc9..38e7737 100644 --- a/discord_embed/package.json +++ b/discord_embed/package.json @@ -1,6 +1,6 @@ { "name": "discord_embed", - "version": "1.0.6", + "version": "1.0.7", "port": 4120, "description": "AV1 discord server embed helper", "main": "index.js", diff --git a/discord_embed/public/index.html b/discord_embed/public/index.html index 18d44a0..3de97eb 100644 --- a/discord_embed/public/index.html +++ b/discord_embed/public/index.html @@ -2,7 +2,7 @@ - Discord Embedder from AV1 server 1.0.6 + Discord Embedder from AV1 server 1.0.7 {{ if (imageLink) { }}