Added some little fix

This commit is contained in:
Даня Вакуленков 2024-12-21 11:53:35 +03:00
parent b0c0fecee9
commit 71f7c4be26
4 changed files with 20 additions and 20 deletions

View File

@ -19,6 +19,8 @@ def handle_mailing_list(mailing_list_id):
)
no_errors = True
for mailing_list_receiver_info in mailing_list_receiver_infos:
if mailing_list_receiver_info.sent:
continue
user = mailing_list_receiver_info.user
body = {
'tg_id': user.tg_id,
@ -44,7 +46,7 @@ def handle_mailing_list(mailing_list_id):
@app.task
def check_mailing_lists():
for mailing_list in MailingList.objects.filter(time__lte=timezone.now() + timedelta(hours=1), status=MailingListStatus.WAITING):
for mailing_list in MailingList.objects.filter(time__lte=timezone.now() + timedelta(hours=1), status__in=[MailingListStatus.WAITING, MailingListStatus.PARTLY_FINISHED]):
mailing_list.status = MailingListStatus.QUEUED
mailing_list.save(update_fields=('status',))
handle_mailing_list.apply_async(

View File

@ -36,21 +36,22 @@ send_message_router = APIRouter(
@send_message_router.post('/dispatch/')
async def handle_dispatch(data: DispatchSchema, background_tasks: BackgroundTasks):
try:
media = io.BytesIO(requests.get(data.attachment_path).content)
media.seek(0)
attachment = types.InputFile(media)
keyboard = InlineKeyboardMarkup()
if data.button_name and data.button_url:
button1 = InlineKeyboardButton(f'{data.button_name}', url=f"{data.button_url}")
keyboard.add(button1)
if data.web_app_button_name:
button2 = InlineKeyboardButton(f'{data.web_app_button_name}', web_app=WebAppInfo(url=f"{url}"))
keyboard.add(button2)
await bot.send_message(data.tg_id, data.text)
# media = io.BytesIO(requests.get(data.attachment_path).content)
# media.seek(0)
# attachment = types.InputFile(media)
# keyboard = InlineKeyboardMarkup()
# if data.button_name and data.button_url:
# button1 = InlineKeyboardButton(f'{data.button_name}', url=f"{data.button_url}")
# keyboard.add(button1)
# if data.web_app_button_name:
# button2 = InlineKeyboardButton(f'{data.web_app_button_name}', web_app=WebAppInfo(url=f"{url}"))
# keyboard.add(button2)
if not data.button_name and not data.web_app_button_name:
await bot.send_photo(data.tg_id, attachment, caption=data.text, parse_mode=types.ParseMode.MARKDOWN, reply_markup=ReplyKeyboardRemove())
else:
await bot.send_photo(data.tg_id, attachment, caption=data.text, reply_markup=keyboard, parse_mode=types.ParseMode.MARKDOWN)
# if not data.button_name and not data.web_app_button_name:
# await bot.send_photo(data.tg_id, attachment, caption=data.text, parse_mode=types.ParseMode.MARKDOWN, reply_markup=ReplyKeyboardRemove())
# else:
# await bot.send_photo(data.tg_id, attachment, caption=data.text, reply_markup=keyboard, parse_mode=types.ParseMode.MARKDOWN)
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))
return {'ok': True}

View File

@ -31,16 +31,12 @@ services:
backend: &started-dependency
condition: service_started
batcher: *started-dependency
memcached: *started-dependency
env_file:
- .env/prod/bot
- .env/prod/web
command: /app/scripts/gunicorn.sh
restart: on-failure
memcached:
image: memcached:latest
postgres: &pg-conf
image: postgres:17-alpine
volumes:
@ -65,6 +61,7 @@ services:
bot: *started-dependency
volumes:
- backend_static:/static/
- backend_media:/media/
restart: unless-stopped
celery:

View File

@ -87,7 +87,7 @@ http {
}
# backend static
location ~ ^/(static)/(.*)$ {
location ~ ^/(static|media)/(.*)$ {
alias /$1/$2;
}