diff --git a/files/assets/js/submit.js b/files/assets/js/submit.js index de7e5efaa..f2aa6ab24 100644 --- a/files/assets/js/submit.js +++ b/files/assets/js/submit.js @@ -113,10 +113,14 @@ function checkRepost(t) { form.append("url", url); xhr.onload=function(){ - const permalink = xhr.response - console.log(permalink) - if (permalink) { - system.innerHTML = `This is a repost of ${permalink}`; + try {data = JSON.parse(xhr.response)} + catch(e) {console.log(e)} + + if (data && data["permalink"]) { + const permalink = data["permalink"] + if (permalink) { + system.innerHTML = `This is a repost of ${permalink}`; + } } } xhr.send(form) diff --git a/files/routes/posts.py b/files/routes/posts.py index b72d319a4..82ca9d5f6 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -854,8 +854,8 @@ def api_is_repost(): Submission.deleted_utc == 0, Submission.is_banned == False ).first() - if repost: return repost.permalink - else: return '' + if repost: return {'permalink': repost.permalink} + else: return {'permalink': ''} @app.post("/submit") @app.post("/h//submit") diff --git a/files/templates/submit.html b/files/templates/submit.html index fec53ebbd..0c53d1c96 100644 --- a/files/templates/submit.html +++ b/files/templates/submit.html @@ -268,7 +268,7 @@ - + {% include "emoji_modal.html" %} {% include "gif_modal.html" %}