mirror of
https://github.com/haiwen/seahub.git
synced 2025-07-12 14:38:58 +00:00
update
This commit is contained in:
parent
7d1e9e11ea
commit
3bde4555d0
@ -344,7 +344,7 @@ class AllNotificationsView(APIView):
|
|||||||
sdoc_notice_list = SeadocNotification.objects.list_all_by_user(username)[start:end]
|
sdoc_notice_list = SeadocNotification.objects.list_all_by_user(username)[start:end]
|
||||||
|
|
||||||
general_result_notices = update_notice_detail(request, general_notice_list)
|
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 = []
|
notification_list = []
|
||||||
sdoc_notification_list = []
|
sdoc_notification_list = []
|
||||||
|
@ -404,27 +404,29 @@ def update_notice_detail(request, notices):
|
|||||||
return notices
|
return notices
|
||||||
|
|
||||||
|
|
||||||
def update_sdoc_notice_detail(request, notices):
|
def update_sdoc_notice_detail(notices):
|
||||||
doc_uuid_set = set()
|
doc_uuid_set = set()
|
||||||
for notice in notices:
|
for notice in notices:
|
||||||
doc_uuid_set.add(notice.doc_uuid)
|
doc_uuid_set.add(notice.doc_uuid)
|
||||||
doc_uuid_map = {}
|
uuid_doc_map = {}
|
||||||
uuids = FileUUIDMap.objects.get_fileuuidmap_in_uuids(doc_uuid_set)
|
uuids = FileUUIDMap.objects.get_fileuuidmap_in_uuids(doc_uuid_set)
|
||||||
for uuid in uuids:
|
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)
|
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:
|
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():
|
if notice.is_comment():
|
||||||
try:
|
try:
|
||||||
d = json.loads(notice.detail)
|
d = json.loads(notice.detail)
|
||||||
url, _, _ = api_avatar_url(d['author'])
|
url, _, _ = api_avatar_url(d['author'])
|
||||||
d['avatar_url'] = url
|
d['avatar_url'] = url
|
||||||
d['sdoc_path'] = uuid[0]
|
d['sdoc_path'] = doc[0]
|
||||||
d['sdoc_name'] = uuid[1]
|
d['sdoc_name'] = doc[1]
|
||||||
d['repo_id'] = uuid[2]
|
d['repo_id'] = doc[2]
|
||||||
notice.detail = d
|
notice.detail = d
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
@ -433,9 +435,9 @@ def update_sdoc_notice_detail(request, notices):
|
|||||||
d = json.loads(notice.detail)
|
d = json.loads(notice.detail)
|
||||||
url, _, _ = api_avatar_url(d['author'])
|
url, _, _ = api_avatar_url(d['author'])
|
||||||
d['avatar_url'] = url
|
d['avatar_url'] = url
|
||||||
d['sdoc_path'] = uuid[0]
|
d['sdoc_path'] = doc[0]
|
||||||
d['sdoc_name'] = uuid[1]
|
d['sdoc_name'] = doc[1]
|
||||||
d['repo_id'] = uuid[2]
|
d['repo_id'] = doc[2]
|
||||||
notice.detail = d
|
notice.detail = d
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
|
@ -23,10 +23,8 @@ class FileUUIDMapManager(models.Manager):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def get_fileuuidmap_in_uuids(self, uuids):
|
def get_fileuuidmap_in_uuids(self, uuids):
|
||||||
try:
|
|
||||||
return super(FileUUIDMapManager, self).filter(uuid__in=uuids)
|
return super(FileUUIDMapManager, self).filter(uuid__in=uuids)
|
||||||
except self.model.DoesNotExist:
|
|
||||||
return None
|
|
||||||
|
|
||||||
def get_or_create_fileuuidmap(self, repo_id, parent_path, filename, is_dir):
|
def get_or_create_fileuuidmap(self, repo_id, parent_path, filename, is_dir):
|
||||||
""" create filemap by repo_id、 parent_path、filename、id_dir
|
""" create filemap by repo_id、 parent_path、filename、id_dir
|
||||||
|
Loading…
Reference in New Issue
Block a user