fix double prepend
This commit is contained in:
parent
152c3362a0
commit
dec9efc49b
|
@ -63,12 +63,14 @@ async def create_chat(_, info, title="", members=[]):
|
||||||
cids = await redis.execute("SMEMBERS", f"chats_by_user/{user.slug}")
|
cids = await redis.execute("SMEMBERS", f"chats_by_user/{user.slug}")
|
||||||
for cid in cids:
|
for cid in cids:
|
||||||
c = await redis.execute("GET", F"chats/{cid.decode('utf-8')}")
|
c = await redis.execute("GET", F"chats/{cid.decode('utf-8')}")
|
||||||
isc = [x for x in c["users"] if x not in chat["users"]]
|
if c:
|
||||||
if isc == [] and chat["title"] == c["title"]:
|
c = json.loads(c)
|
||||||
return {
|
isc = [x for x in c["users"] if x not in chat["users"]]
|
||||||
"error": "chat was created before",
|
if isc == [] and chat["title"] == c["title"]:
|
||||||
"chat": chat
|
return {
|
||||||
}
|
"error": "chat was created before",
|
||||||
|
"chat": chat
|
||||||
|
}
|
||||||
|
|
||||||
for m in members:
|
for m in members:
|
||||||
await redis.execute("SADD", f"chats_by_user/{m}", chat_id)
|
await redis.execute("SADD", f"chats_by_user/{m}", chat_id)
|
||||||
|
|
|
@ -98,11 +98,12 @@ async def topic_follow(user, slug):
|
||||||
async def topic_unfollow(user, slug):
|
async def topic_unfollow(user, slug):
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
sub = (
|
sub = (
|
||||||
session.query(TopicFollower)
|
session.query(TopicFollower).filter(
|
||||||
.filter(
|
and_(
|
||||||
and_(TopicFollower.follower == user.slug, TopicFollower.topic == slug)
|
TopicFollower.follower == user.slug,
|
||||||
)
|
TopicFollower.topic == slug
|
||||||
.first()
|
)
|
||||||
|
).first()
|
||||||
)
|
)
|
||||||
if not sub:
|
if not sub:
|
||||||
raise Exception("[resolvers.topics] follower not exist")
|
raise Exception("[resolvers.topics] follower not exist")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user