From 8b55bd582838a3e54647a92ac90a8ed5c96f2ad6 Mon Sep 17 00:00:00 2001 From: yusuke_ten Date: Tue, 13 Aug 2024 15:05:57 +0900 Subject: [PATCH] fix: display notion document title correctly (#7215) --- api/libs/oauth_data_source.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/api/libs/oauth_data_source.py b/api/libs/oauth_data_source.py index a5c7814a54..358858ceb1 100644 --- a/api/libs/oauth_data_source.py +++ b/api/libs/oauth_data_source.py @@ -154,11 +154,11 @@ class NotionOAuth(OAuthDataSource): for page_result in page_results: page_id = page_result['id'] page_name = 'Untitled' - for key in ['Name', 'title', 'Title', 'Page']: - if key in page_result['properties']: - if len(page_result['properties'][key].get('title', [])) > 0: - page_name = page_result['properties'][key]['title'][0]['plain_text'] - break + for key in page_result['properties']: + if 'title' in page_result['properties'][key] and page_result['properties'][key]['title']: + title_list = page_result['properties'][key]['title'] + if len(title_list) > 0 and 'plain_text' in title_list[0]: + page_name = title_list[0]['plain_text'] page_icon = page_result['icon'] if page_icon: icon_type = page_icon['type']