fixes-inbox-topics-authors

This commit is contained in:
tonyrewin 2022-10-04 02:43:08 +03:00
parent 5c056525ed
commit e16265a0c3
3 changed files with 5 additions and 3 deletions

View File

@ -74,7 +74,7 @@ async def add_user_to_chat(user_slug, chat_id, chat=None):
await redis.execute("SET", f"chats/{chat_id}", json.dumps(chat)) await redis.execute("SET", f"chats/{chat_id}", json.dumps(chat))
@mutation.query("inviteChat") @mutation.field("inviteChat")
async def invite_to_chat(_, info, invited, chat_id): async def invite_to_chat(_, info, invited, chat_id):
user = info.context["request"].user user = info.context["request"].user
chat = await redis.execute("GET", f"chats/{chat_id}") chat = await redis.execute("GET", f"chats/{chat_id}")

View File

@ -130,6 +130,7 @@ async def shouts_by_authors(_, _info, slugs, offset, limit):
for a in s.authors: for a in s.authors:
a.caption = await ShoutAuthorStorage.get_author_caption(s.slug, a.slug) a.caption = await ShoutAuthorStorage.get_author_caption(s.slug, a.slug)
shouts_prepared.append(s) shouts_prepared.append(s)
shouts_prepared = list(set(shouts_prepared))
shouts_prepared.sort(key=lambda s: s.publishedAt, reverse=True) shouts_prepared.sort(key=lambda s: s.publishedAt, reverse=True)
return shouts_prepared[offset : offset + limit] return shouts_prepared[offset : offset + limit]
@ -146,6 +147,7 @@ async def shouts_by_topics(_, _info, slugs, offset, limit):
for a in s.authors: for a in s.authors:
a.caption = await ShoutAuthorStorage.get_author_caption(s.slug, a.slug) a.caption = await ShoutAuthorStorage.get_author_caption(s.slug, a.slug)
shouts_prepared.append(s) shouts_prepared.append(s)
shouts_prepared = list(set(shouts_prepared))
shouts_prepared.sort(key=lambda s: s.publishedAt, reverse=True) shouts_prepared.sort(key=lambda s: s.publishedAt, reverse=True)
return shouts_prepared[offset : offset + limit] return shouts_prepared[offset : offset + limit]

View File

@ -146,6 +146,7 @@ enum FollowingEntity {
type Mutation { type Mutation {
# inbox # inbox
createChat(description: String): CreateChatResult! createChat(description: String): CreateChatResult!
inviteChat(chatId: String!, userslug: String!): Result!
createMessage(chatId: String!, body: String!, replyTo: Int): MessageResult! createMessage(chatId: String!, body: String!, replyTo: Int): MessageResult!
updateMessage(chatId: String!, id: Int!, body: String!): MessageResult! updateMessage(chatId: String!, id: Int!, body: String!): MessageResult!
deleteMessage(chatId: String!, id: Int!): Result! deleteMessage(chatId: String!, id: Int!): Result!
@ -210,7 +211,6 @@ type Query {
myChats: [ChatResult]! myChats: [ChatResult]!
enterChat(chatId: String!): ChatResult! enterChat(chatId: String!): ChatResult!
loadChat(chatId: String!, size: Int!, page: Int!): [Message]! loadChat(chatId: String!, size: Int!, page: Int!): [Message]!
inviteChat(chatId: String!, userslug: String!): Result!
# auth # auth
isEmailUsed(email: String!): Boolean! isEmailUsed(email: String!): Boolean!
@ -503,7 +503,7 @@ type Chat {
createdAt: DateTime! createdAt: DateTime!
createdBy: User! createdBy: User!
updatedAt: DateTime! updatedAt: DateTime!
title: string title: String
description: String description: String
users: [User]! users: [User]!
messages: [Message] messages: [Message]