WIP: New submission system
This commit is contained in:
@@ -55,11 +55,13 @@ async def upload_pic(filepath: str) -> Tuple[bool, list]:
|
||||
try:
|
||||
pic_name = path.basename(filepath)
|
||||
files = {'file': (pic_name, open(filepath, 'rb'), 'image/jpeg')}
|
||||
response = post(f'{configGet("address", "posting", "api")}/albums/{configGet("album", "posting", "api")}/photos&caption=queue', headers={"Authorization": f"Bearer {token}"}, files=files).json()
|
||||
print(response, flush=True)
|
||||
response = post(f'{configGet("address", "posting", "api")}/albums/{configGet("album", "posting", "api")}/photos', params={"caption": "queue", "compress": False}, headers={"Authorization": f"Bearer {token}"}, files=files)
|
||||
if response.status_code != 200 and response.status_code != 409:
|
||||
logWrite(f"Could not upload '{filepath}' to API: HTTP {response.status_code} with message '{response.content}'")
|
||||
return False, []
|
||||
duplicates = []
|
||||
if "duplicates" in response:
|
||||
for duplicate in response["duplicates"]:
|
||||
if "duplicates" in response.json():
|
||||
for duplicate in response.json()["duplicates"]:
|
||||
duplicates.append(f'{configGet("address", "posting", "api")}/photos/{duplicate["id"]}')
|
||||
return True, duplicates
|
||||
except:
|
||||
|
@@ -14,7 +14,7 @@ def subLimited(user: User) -> bool:
|
||||
db_record = col_users.find_one({"user": user.id})
|
||||
if db_record is None:
|
||||
return False
|
||||
return True if (datetime.now(tz=timezone.utc) - db_record["cooldown"]).total_seconds() < configGet("timeout", "submission") else False
|
||||
return True if (datetime.now(tz=timezone.utc) - db_record["cooldown"].astimezone(timezone.utc)).total_seconds() < configGet("timeout", "submission") else False
|
||||
|
||||
def subBlocked(user: User) -> bool:
|
||||
return False if col_banned.find_one({"user": user.id}) is None else True
|
||||
|
Reference in New Issue
Block a user