diff --git a/files/routes/comments.py b/files/routes/comments.py index b62bf8585..6c4a10520 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -379,7 +379,7 @@ def api_comment(v): c.upvotes += 1 g.db.add(c) - if "rama" in request.host and len(body) >= 1000 and v.username != "Snappy" and "" not in body_html: + if "rama" in request.host and len(c.body) >= 1000 and v.username != "Snappy" and "" not in body_html: body = random.choice(LONGPOST_REPLIES) body = re.sub('([^\n])\n([^\n])', r'\1\n\n\2', body) diff --git a/files/routes/users.py b/files/routes/users.py index 23ebea3ef..a13eac7a3 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -192,7 +192,8 @@ def songs(id): try: id = int(id) except: return "", 400 user = g.db.query(User).options(lazyload('*')).filter_by(id=id).first() - return redirect(f"/song/{user.song}.mp3") + if user and user.song: return redirect(f"/song/{user.song}.mp3") + else: abort(404) @app.get("/song/") def song(song):