1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-04-27 19:05:16 +00:00
This commit is contained in:
r350178982 2024-11-28 15:05:01 +08:00 committed by 孙永强
parent 7d1e9e11ea
commit 3bde4555d0
3 changed files with 16 additions and 16 deletions

View File

@ -344,7 +344,7 @@ class AllNotificationsView(APIView):
sdoc_notice_list = SeadocNotification.objects.list_all_by_user(username)[start:end]
general_result_notices = update_notice_detail(request, general_notice_list)
sdoc_result_notices = update_sdoc_notice_detail(request, sdoc_notice_list)
sdoc_result_notices = update_sdoc_notice_detail(sdoc_notice_list)
notification_list = []
sdoc_notification_list = []

View File

@ -404,27 +404,29 @@ def update_notice_detail(request, notices):
return notices
def update_sdoc_notice_detail(request, notices):
def update_sdoc_notice_detail(notices):
doc_uuid_set = set()
for notice in notices:
doc_uuid_set.add(notice.doc_uuid)
doc_uuid_map = {}
uuid_doc_map = {}
uuids = FileUUIDMap.objects.get_fileuuidmap_in_uuids(doc_uuid_set)
for uuid in uuids:
if uuid not in doc_uuid_map:
if uuid not in uuid_doc_map:
origin_file_path = posixpath.join(uuid.parent_path, uuid.filename)
doc_uuid_map[str(uuid.uuid)] = (origin_file_path, uuid.filename, uuid.repo_id)
uuid_doc_map[str(uuid.uuid)] = (origin_file_path, uuid.filename, uuid.repo_id)
for notice in notices:
uuid = doc_uuid_map[notice.doc_uuid]
doc = uuid_doc_map.get(notice.doc_uuid) or None
if not doc:
continue
if notice.is_comment():
try:
d = json.loads(notice.detail)
url, _, _ = api_avatar_url(d['author'])
d['avatar_url'] = url
d['sdoc_path'] = uuid[0]
d['sdoc_name'] = uuid[1]
d['repo_id'] = uuid[2]
d['sdoc_path'] = doc[0]
d['sdoc_name'] = doc[1]
d['repo_id'] = doc[2]
notice.detail = d
except Exception as e:
logger.error(e)
@ -433,9 +435,9 @@ def update_sdoc_notice_detail(request, notices):
d = json.loads(notice.detail)
url, _, _ = api_avatar_url(d['author'])
d['avatar_url'] = url
d['sdoc_path'] = uuid[0]
d['sdoc_name'] = uuid[1]
d['repo_id'] = uuid[2]
d['sdoc_path'] = doc[0]
d['sdoc_name'] = doc[1]
d['repo_id'] = doc[2]
notice.detail = d
except Exception as e:
logger.error(e)

View File

@ -23,10 +23,8 @@ class FileUUIDMapManager(models.Manager):
return None
def get_fileuuidmap_in_uuids(self, uuids):
try:
return super(FileUUIDMapManager, self).filter(uuid__in=uuids)
except self.model.DoesNotExist:
return None
return super(FileUUIDMapManager, self).filter(uuid__in=uuids)
def get_or_create_fileuuidmap(self, repo_id, parent_path, filename, is_dir):
""" create filemap by repo_id、 parent_path、filename、id_dir