From e410535b301469730973b420025554352e6a773b Mon Sep 17 00:00:00 2001 From: exmanka Date: Tue, 30 Jan 2024 19:31:42 +0300 Subject: [PATCH] fix(admin): fix /logs handler parse_mode --- docker-compose.yml | 18 ++++++++++-------- src/handlers/admin.py | 5 +++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 1060cef..9774544 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,7 +8,7 @@ services: container_name: tgbot-container restart: unless-stopped env_file: - - .env + - .confs/.data/.env ports: - 80:80 # - 443:443 @@ -30,12 +30,14 @@ services: ADDITIONAL_LANGUAGE: ${ADDITIONAL_LANGUAGE} container_name: postgres-container restart: unless-stopped - environment: - TZ: ${TZ} - POSTGRES_USER: ${POSTGRES_USER} - POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} - POSTGRES_DB: ${POSTGRES_DB} - POSTGRES_INITDB_ARGS: ${POSTGRES_INITDB_ARGS} + env_file: + - .confs/.data/.env + # environment: + # TZ: ${TZ} + # POSTGRES_USER: ${POSTGRES_USER} + # POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} + # POSTGRES_DB: ${POSTGRES_DB} + # POSTGRES_INITDB_ARGS: ${POSTGRES_INITDB_ARGS} ports: - 5432:5432 healthcheck: @@ -48,7 +50,7 @@ services: volumes: - db-data:/var/lib/postgresql/data - db-backups:/var/lib/postgresql/backups - - ./init-database.sql:/docker-entrypoint-initdb.d/init-database.sql + - .confs/.data/init-database.sql:/docker-entrypoint-initdb.d/init-database.sql networks: appnet: diff --git a/src/handlers/admin.py b/src/handlers/admin.py index d1812d7..c94dde8 100644 --- a/src/handlers/admin.py +++ b/src/handlers/admin.py @@ -1,5 +1,6 @@ import logging import aiofiles +import html from decimal import Decimal from aiogram import Dispatcher from aiogram.types import Message, CallbackQuery @@ -432,7 +433,7 @@ async def show_logs(message: Message): if last_rows_number_list: last_rows_number = int(last_rows_number_list[0]) else: - last_rows_number = 25 + last_rows_number = 50 # read only last rows of file last_rows_counter = 0 @@ -453,7 +454,7 @@ async def show_logs(message: Message): last_lines = (await f.read()).decode() # set markdown YAML code block language because it has acceptable log file syntax highlighting - await message.answer(f"```yaml\n{last_lines}```", parse_mode='MarkdownV2') + await message.answer(f"
{html.escape(last_lines)}
", parse_mode='HTML') @admin_mw.admin_only()