Skip to content

Commit

Permalink
add new search filter deleted:boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
slatinsky committed Aug 29, 2023
1 parent 0b14e6b commit b46c1ba
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions backend/fastapi/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,14 @@ def enrich_messages(list_of_messages: list) -> list:
"multiple": False,
"mapTo": "is_edited",
"autocompleteApi": None,
},
{
"key": 'deleted',
"description": 'true/false',
"type": 'boolean',
"multiple": False,
"mapTo": "is_deleted",
"autocompleteApi": None,
},
{
"key": 'limit',
Expand Down Expand Up @@ -703,6 +711,7 @@ def parse_prompt(prompt: str):
"attachment_is_other": None, # boolean (None means both) (or in group attachment_is)
"containing_links": None, # boolean (None means both)
"is_edited": None, # boolean (None means both)
"is_deleted": None, # boolean (None means both)
"limit": 100000 # max number of messages to return (int)
}

Expand Down Expand Up @@ -798,6 +807,7 @@ async def search_messages(prompt: str = None, guild_id: str = None, only_ids: bo
attachment_is_other = search["attachment_is_other"]
containing_links = search["containing_links"]
is_edited = search["is_edited"]
is_deleted = search["is_deleted"]
limit = search["limit"]

# clean up
Expand Down Expand Up @@ -965,6 +975,12 @@ async def search_messages(prompt: str = None, guild_id: str = None, only_ids: bo
else:
query["timestampEdited"] = None

if is_deleted is not None:
if is_deleted:
query["isDeleted"] = True
else:
query["$or"] = [{"isDeleted": False}, {"isDeleted": None}]


if len(message_contains) > 0:
and_ = []
Expand Down

0 comments on commit b46c1ba

Please sign in to comment.