lint
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
import json
|
||||
from datetime import datetime, timedelta, timezone
|
||||
|
||||
from auth.authenticate import login_required
|
||||
from auth.credentials import AuthCredentials
|
||||
from base.orm import local_session
|
||||
from base.redis import redis
|
||||
from base.resolvers import query
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from orm.user import AuthorFollower, User
|
||||
from resolvers.inbox.load import load_messages
|
||||
|
||||
import json
|
||||
|
||||
|
||||
@query.field("searchRecipients")
|
||||
@login_required
|
||||
@@ -59,22 +59,22 @@ async def search_user_chats(by, messages, user_id: int, limit, offset):
|
||||
cids.union(set(await redis.execute("SMEMBERS", "chats_by_user/" + str(user_id))))
|
||||
messages = []
|
||||
|
||||
by_author = by.get('author')
|
||||
by_author = by.get("author")
|
||||
if by_author:
|
||||
# all author's messages
|
||||
cids.union(set(await redis.execute("SMEMBERS", f"chats_by_user/{by_author}")))
|
||||
# author's messages in filtered chat
|
||||
messages.union(set(filter(lambda m: m["author"] == by_author, list(messages))))
|
||||
for c in cids:
|
||||
c = c.decode('utf-8')
|
||||
c = c.decode("utf-8")
|
||||
messages = await load_messages(c, limit, offset)
|
||||
|
||||
body_like = by.get('body')
|
||||
body_like = by.get("body")
|
||||
if body_like:
|
||||
# search in all messages in all user's chats
|
||||
for c in cids:
|
||||
# FIXME: use redis scan here
|
||||
c = c.decode('utf-8')
|
||||
c = c.decode("utf-8")
|
||||
mmm = await load_messages(c, limit, offset)
|
||||
for m in mmm:
|
||||
if body_like in m["body"]:
|
||||
|
Reference in New Issue
Block a user