Skip to content

Commit 43f50fd

Browse files
committed
Merge branch 'main' of github.com:gerevai/gerev into main
2 parents 1a3b199 + f7f7c06 commit 43f50fd

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

app/data_source/sources/google_drive/google_drive.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def _feed_drive(self, drive):
120120
kwargs['pageToken'] = next_page_token
121121

122122
response = self._drive.files().list(
123-
fields='nextPageToken,files(kind,id,name,mimeType,lastModifyingUser,webViewLink,modifiedTime,parents)',
123+
fields='nextPageToken,files(kind,id,name,mimeType,lastModifyingUser,webViewLink,modifiedTime,parents,owners)',
124124
pageSize=1000,
125125
**kwargs
126126
).execute()
@@ -173,14 +173,21 @@ def _feed_file(self, file):
173173

174174
last_modified = datetime.strptime(file['modifiedTime'], "%Y-%m-%dT%H:%M:%S.%fZ")
175175

176+
author = file['lastModifyingUser'].get('displayName')
177+
author_image_url = file['lastModifyingUser'].get('photoLink')
178+
if not author:
179+
first_owner = file['owners'][0]
180+
author = first_owner.get('displayName')
181+
author_image_url = first_owner.get('photoLink')
182+
176183
doc = BasicDocument(
177184
id=file_id,
178185
data_source_id=self._data_source_id,
179186
type=DocumentType.DOCUMENT,
180187
title=file['name'],
181188
content=content,
182-
author=file['lastModifyingUser']['displayName'],
183-
author_image_url=file['lastModifyingUser'].get('photoLink'),
189+
author=author,
190+
author_image_url=author_image_url,
184191
location=parent_name,
185192
url=file['webViewLink'],
186193
timestamp=last_modified,

0 commit comments

Comments
 (0)