refac
This commit is contained in:
1 parent
bd250a0e24
commit
5cd9a39534
1 file changed
+14
-1
@@ -1416,8 +1416,21 @@ async def get_sources_from_items(
|
|||||||
elif item.get('type') == 'chat':
|
elif item.get('type') == 'chat':
|
||||||
# Chat Attached
|
# Chat Attached
|
||||||
chat = await Chats.get_chat_by_id(item.get('id'))
|
chat = await Chats.get_chat_by_id(item.get('id'))
|
||||||
|
has_read_access = bool(chat and (user.role == 'admin' or chat.user_id == user.id))
|
||||||
|
|
||||||
if chat and (user.role == 'admin' or chat.user_id == user.id):
|
if chat and not has_read_access:
|
||||||
|
has_read_access = await AccessGrants.has_access(
|
||||||
|
user_id=user.id,
|
||||||
|
resource_type='shared_chat',
|
||||||
|
resource_id=chat.id,
|
||||||
|
permission='read',
|
||||||
|
)
|
||||||
|
|
||||||
|
if chat and not has_read_access and chat.folder_id:
|
||||||
|
folder = await Folders.get_folder_by_id(chat.folder_id)
|
||||||
|
has_read_access = folder and await has_folder_access(user.id, folder, 'read', db=None)
|
||||||
|
|
||||||
|
if has_read_access:
|
||||||
messages_map = chat.chat.get('history', {}).get('messages', {})
|
messages_map = chat.chat.get('history', {}).get('messages', {})
|
||||||
message_id = chat.chat.get('history', {}).get('currentId')
|
message_id = chat.chat.get('history', {}).get('currentId')
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user