Refactor changed are done
This commit is contained in:
@@ -108,12 +108,12 @@ async def album_patch(
|
||||
except InvalidId:
|
||||
raise AlbumNotFoundError(id)
|
||||
|
||||
if title is not None:
|
||||
if 2 > len(title) > 40:
|
||||
raise AlbumIncorrectError("title", "must be >2 and <40 characters.")
|
||||
else:
|
||||
if title is None:
|
||||
title = album["title"]
|
||||
|
||||
elif 2 > len(title) > 40:
|
||||
raise AlbumIncorrectError("title", "must be >2 and <40 characters.")
|
||||
|
||||
if name is not None:
|
||||
if re.search(re.compile("^[a-z,0-9,_]*$"), name) is False:
|
||||
raise AlbumIncorrectError(
|
||||
|
@@ -139,11 +139,9 @@ async def photo_upload(
|
||||
)
|
||||
duplicates = await get_duplicates(file_hash, album)
|
||||
|
||||
if len(duplicates) > 0 and ignore_duplicates is False:
|
||||
if len(duplicates) > 0 and not ignore_duplicates:
|
||||
if configGet("media_token_access") is True:
|
||||
duplicates_ids = []
|
||||
for entry in duplicates:
|
||||
duplicates_ids.append(entry["id"])
|
||||
duplicates_ids = [entry["id"] for entry in duplicates]
|
||||
access_token = create_access_token(
|
||||
data={
|
||||
"sub": current_user.user,
|
||||
@@ -193,7 +191,7 @@ async def photo_upload(
|
||||
}
|
||||
)
|
||||
|
||||
if compress is True:
|
||||
if compress:
|
||||
scheduler.add_job(
|
||||
compress_image,
|
||||
trigger="date",
|
||||
@@ -519,7 +517,7 @@ async def photo_find(
|
||||
}
|
||||
elif q is None and caption is None:
|
||||
raise PhotoSearchQueryEmptyError()
|
||||
elif q is None and caption is not None:
|
||||
elif q is None:
|
||||
db_query = {
|
||||
"user": current_user.user,
|
||||
"album": album,
|
||||
@@ -530,7 +528,7 @@ async def photo_find(
|
||||
"album": album,
|
||||
"caption": re.compile(caption),
|
||||
}
|
||||
elif q is not None and caption is None:
|
||||
elif caption is None:
|
||||
db_query = {
|
||||
"user": current_user.user,
|
||||
"album": album,
|
||||
|
@@ -313,7 +313,7 @@ async def video_find(
|
||||
if q is None and caption is None:
|
||||
raise VideoSearchQueryEmptyError()
|
||||
|
||||
if q is None and caption is not None:
|
||||
if q is None:
|
||||
db_query = {
|
||||
"user": current_user.user,
|
||||
"album": album,
|
||||
@@ -324,7 +324,7 @@ async def video_find(
|
||||
"album": album,
|
||||
"caption": re.compile(caption),
|
||||
}
|
||||
elif q is not None and caption is None:
|
||||
elif caption is None:
|
||||
db_query = list(
|
||||
col_videos.find(
|
||||
{"user": current_user.user, "album": album, "filename": re.compile(q)},
|
||||
|
Reference in New Issue
Block a user