rss mention fix attempt; SITE_NAME is now required
This commit is contained in:
@@ -10,6 +10,7 @@ from .constants import (
|
|||||||
SIG_BANNED_TAGS, STRICT_BANNED_TAGS,
|
SIG_BANNED_TAGS, STRICT_BANNED_TAGS,
|
||||||
)
|
)
|
||||||
from .lib.babycode import babycode_to_html, babycode_to_rssxml, EMOJI, BABYCODE_VERSION
|
from .lib.babycode import babycode_to_html, babycode_to_rssxml, EMOJI, BABYCODE_VERSION
|
||||||
|
from .lib.exceptions import SiteNameMissingException
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
from flask_caching import Cache
|
from flask_caching import Cache
|
||||||
import os
|
import os
|
||||||
@@ -165,6 +166,8 @@ def create_app():
|
|||||||
load_dotenv()
|
load_dotenv()
|
||||||
else:
|
else:
|
||||||
app.config["DB_PATH"] = "data/db/db.prod.sqlite"
|
app.config["DB_PATH"] = "data/db/db.prod.sqlite"
|
||||||
|
if not app.config["SERVER_NAME"]:
|
||||||
|
raise SiteNameMissingException()
|
||||||
|
|
||||||
app.config["SECRET_KEY"] = os.getenv("FLASK_SECRET_KEY")
|
app.config["SECRET_KEY"] = os.getenv("FLASK_SECRET_KEY")
|
||||||
|
|
||||||
|
|||||||
@@ -196,13 +196,12 @@ class RSSXMLRenderer(BabycodeRenderer):
|
|||||||
|
|
||||||
def make_mention(self, e):
|
def make_mention(self, e):
|
||||||
from ..models import Users
|
from ..models import Users
|
||||||
from flask import url_for, current_app
|
from flask import url_for
|
||||||
with current_app.test_request_context('/'):
|
|
||||||
target_user = Users.find({'username': e['name'].lower()})
|
target_user = Users.find({'username': e['name'].lower()})
|
||||||
if not target_user:
|
if not target_user:
|
||||||
return f"@{e['name']}"
|
return f"@{e['name']}"
|
||||||
|
|
||||||
return f'<a href="{url_for('users.page', username=target_user.username, _external=True)}" title="@{target_user.username}">{target_user.get_readable_name()}</a>'
|
return f'<a href="{url_for('users.page', username=target_user.username, _external=True)}" title="@{target_user.username}">{'@' if not target_user.has_display_name() else ''}{target_user.get_readable_name()}</a>'
|
||||||
|
|
||||||
|
|
||||||
NAMED_COLORS = [
|
NAMED_COLORS = [
|
||||||
|
|||||||
9
app/lib/exceptions.py
Normal file
9
app/lib/exceptions.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
class MissingConfigurationException(Exception):
|
||||||
|
def __init__(self, configuration_field: str):
|
||||||
|
message = f"Missing configuration field '{configuration_field}'"
|
||||||
|
super().__init__(message)
|
||||||
|
|
||||||
|
|
||||||
|
class SiteNameMissingException(MissingConfigurationException):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__('SITE_NAME')
|
||||||
Reference in New Issue
Block a user