discord_embed: Added some debug code for testing
All checks were successful
continuous-integration/appveyor/branch AppVeyor build succeeded

This commit is contained in:
Jonatan Nilsson 2022-10-29 12:16:00 +00:00
parent 3ac90b5eb6
commit 02c1f699fa
3 changed files with 16 additions and 5 deletions

View file

@ -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
<a href="${location}">Click here if it doesn't redirect</a>
`
}
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) {

View file

@ -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",

View file

@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
<title>Discord Embedder from AV1 server 1.0.6</title>
<title>Discord Embedder from AV1 server 1.0.7</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
{{ if (imageLink) { }}