|
@@ -854,62 +854,65 @@ class ContentApi(object):
|
854
|
854
|
|
855
|
855
|
return active_contents
|
856
|
856
|
|
857
|
|
- def get_last_unread(self, parent_id: typing.Optional[int], content_type: str,
|
858
|
|
- workspace: Workspace=None, limit=10) -> typing.List[Content]:
|
859
|
|
- assert parent_id is None or isinstance(parent_id, int)
|
860
|
|
- assert content_type is not None
|
861
|
|
- assert isinstance(content_type, str)
|
862
|
|
-
|
863
|
|
- read_revision_ids = self._session.query(RevisionReadStatus.revision_id) \
|
864
|
|
- .filter(RevisionReadStatus.user_id==self._user_id)
|
865
|
|
-
|
866
|
|
- not_read_revisions = self._revisions_base_query(workspace) \
|
867
|
|
- .filter(~ContentRevisionRO.revision_id.in_(read_revision_ids)) \
|
868
|
|
- .filter(ContentRevisionRO.workspace_id == Workspace.workspace_id) \
|
869
|
|
- .filter(Workspace.is_deleted.is_(False)) \
|
870
|
|
- .subquery()
|
871
|
|
-
|
872
|
|
- not_read_content_ids_query = self._session.query(
|
873
|
|
- distinct(not_read_revisions.c.content_id)
|
874
|
|
- )
|
875
|
|
- not_read_content_ids = list(map(
|
876
|
|
- itemgetter(0),
|
877
|
|
- not_read_content_ids_query,
|
878
|
|
- ))
|
879
|
|
-
|
880
|
|
- not_read_contents = self._base_query(workspace) \
|
881
|
|
- .filter(Content.content_id.in_(not_read_content_ids)) \
|
882
|
|
- .order_by(desc(Content.updated))
|
883
|
|
-
|
884
|
|
- if content_type != ContentType.Any:
|
885
|
|
- not_read_contents = not_read_contents.filter(
|
886
|
|
- Content.type==content_type)
|
887
|
|
- else:
|
888
|
|
- not_read_contents = not_read_contents.filter(
|
889
|
|
- Content.type!=ContentType.Folder)
|
890
|
|
-
|
891
|
|
- if parent_id:
|
892
|
|
- not_read_contents = not_read_contents.filter(
|
893
|
|
- Content.parent_id==parent_id)
|
894
|
|
-
|
895
|
|
- result = []
|
896
|
|
- for item in not_read_contents:
|
897
|
|
- new_item = None
|
898
|
|
- if ContentType.Comment == item.type:
|
899
|
|
- new_item = item.parent
|
900
|
|
- else:
|
901
|
|
- new_item = item
|
902
|
|
-
|
903
|
|
-
|
904
|
|
-
|
905
|
|
-
|
906
|
|
- if new_item not in result:
|
907
|
|
- result.append(new_item)
|
908
|
|
-
|
909
|
|
- if len(result) >= limit:
|
910
|
|
- break
|
911
|
|
-
|
912
|
|
- return result
|
|
857
|
+
|
|
858
|
+
|
|
859
|
+
|
|
860
|
+
|
|
861
|
+
|
|
862
|
+
|
|
863
|
+
|
|
864
|
+
|
|
865
|
+
|
|
866
|
+
|
|
867
|
+
|
|
868
|
+
|
|
869
|
+
|
|
870
|
+
|
|
871
|
+
|
|
872
|
+
|
|
873
|
+
|
|
874
|
+
|
|
875
|
+
|
|
876
|
+
|
|
877
|
+
|
|
878
|
+
|
|
879
|
+
|
|
880
|
+
|
|
881
|
+
|
|
882
|
+
|
|
883
|
+
|
|
884
|
+
|
|
885
|
+
|
|
886
|
+
|
|
887
|
+
|
|
888
|
+
|
|
889
|
+
|
|
890
|
+
|
|
891
|
+
|
|
892
|
+
|
|
893
|
+
|
|
894
|
+
|
|
895
|
+
|
|
896
|
+
|
|
897
|
+
|
|
898
|
+
|
|
899
|
+
|
|
900
|
+
|
|
901
|
+
|
|
902
|
+
|
|
903
|
+
|
|
904
|
+
|
|
905
|
+
|
|
906
|
+
|
|
907
|
+
|
|
908
|
+
|
|
909
|
+
|
|
910
|
+
|
|
911
|
+
|
|
912
|
+
|
|
913
|
+
|
|
914
|
+
|
|
915
|
+
|
913
|
916
|
|
914
|
917
|
def set_allowed_content(self, folder: Content, allowed_content_dict:dict):
|
915
|
918
|
"""
|
|
@@ -1088,11 +1091,7 @@ class ContentApi(object):
|
1088
|
1091
|
do_flush: bool=True,
|
1089
|
1092
|
recursive: bool=True
|
1090
|
1093
|
):
|
1091
|
|
-
|
1092
|
|
- itemset = self.get_last_unread(None, ContentType.Any)
|
1093
|
|
-
|
1094
|
|
- for item in itemset:
|
1095
|
|
- self.mark_read(item, read_datetime, do_flush, recursive)
|
|
1094
|
+ return self.mark_read__workspace(None, read_datetime, do_flush, recursive)
|
1096
|
1095
|
|
1097
|
1096
|
def mark_read__workspace(self,
|
1098
|
1097
|
workspace : Workspace,
|
|
@@ -1100,11 +1099,10 @@ class ContentApi(object):
|
1100
|
1099
|
do_flush: bool=True,
|
1101
|
1100
|
recursive: bool=True
|
1102
|
1101
|
):
|
1103
|
|
-
|
1104
|
|
- itemset = self.get_last_unread(None, ContentType.Any, workspace)
|
1105
|
|
-
|
|
1102
|
+ itemset = self.get_last_active(workspace)
|
1106
|
1103
|
for item in itemset:
|
1107
|
|
- self.mark_read(item, read_datetime, do_flush, recursive)
|
|
1104
|
+ if item.type != ContentType.Folder and item.has_new_information_for(self._user):
|
|
1105
|
+ self.mark_read(item, read_datetime, do_flush, recursive)
|
1108
|
1106
|
|
1109
|
1107
|
def mark_read(self, content: Content,
|
1110
|
1108
|
read_datetime: datetime=None,
|