notification manager

This commit is contained in:
Egor Matveev
2022-03-23 22:39:54 +03:00
parent c457f37247
commit 05af84d569
8 changed files with 33 additions and 7 deletions

View File

@@ -28,7 +28,10 @@ class MessagingSupport(BaseCommand):
raise NotImplementedError
def consume(self, ch, method, properties, body):
self.process(json.loads(body.decode('utf-8')))
data = json.loads(body.decode('utf-8'))
print(f"Got {data}, processing...")
self.process(data)
print("Process finished successfully")
def handle(self, *args, **options):
if self.queue_name is None:

View File

@@ -1,4 +1,5 @@
import datetime
import os
from random import choice
from requests import get, post
@@ -9,19 +10,19 @@ from Sprint import settings
def write_bytes(data: bytes):
url = settings.FS_HOST + ":" + str(settings.FS_PORT) + "/upload_file"
print(url)
return post(url, data=data).json()["id"]
return post(url, data=data, headers={'token': os.getenv('FS_TOKEN')}).json()["id"]
def get_bytes(num: int) -> bytes:
url = settings.FS_HOST + ":" + str(settings.FS_PORT) + "/get_file?id=" + str(num)
print(url)
return get(url).content
return get(url, headers={'token': os.getenv('FS_TOKEN')}).content
def delete_file(num: int):
url = settings.FS_HOST + ":" + str(settings.FS_PORT) + "/delete_file?id=" + str(num)
print(url)
post(url)
post(url, headers={'token': os.getenv('FS_TOKEN')})
def generate_token():