]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Use document owner for matching if set 3198/head
authorshamoon <4887959+shamoon@users.noreply.github.com>
Wed, 26 Apr 2023 16:37:43 +0000 (09:37 -0700)
committershamoon <4887959+shamoon@users.noreply.github.com>
Wed, 26 Apr 2023 16:42:03 +0000 (09:42 -0700)
src/documents/matching.py

index 39a3d52b5cf448f3b6b519c6719e99d85d163392..521d492844d4273d94c38e684ea26537e2010ec8 100644 (file)
@@ -22,6 +22,9 @@ def log_reason(matching_model, document, reason):
 def match_correspondents(document, classifier, user=None):
     pred_id = classifier.predict_correspondent(document.content) if classifier else None
 
+    if user is None and document.owner is not None:
+        user = document.owner
+
     if user is not None:
         correspondents = get_objects_for_user_owner_aware(
             user,
@@ -39,6 +42,9 @@ def match_correspondents(document, classifier, user=None):
 def match_document_types(document, classifier, user=None):
     pred_id = classifier.predict_document_type(document.content) if classifier else None
 
+    if user is None and document.owner is not None:
+        user = document.owner
+
     if user is not None:
         document_types = get_objects_for_user_owner_aware(
             user,
@@ -56,6 +62,9 @@ def match_document_types(document, classifier, user=None):
 def match_tags(document, classifier, user=None):
     predicted_tag_ids = classifier.predict_tags(document.content) if classifier else []
 
+    if user is None and document.owner is not None:
+        user = document.owner
+
     if user is not None:
         tags = get_objects_for_user_owner_aware(user, "documents.view_tag", Tag)
     else:
@@ -69,6 +78,9 @@ def match_tags(document, classifier, user=None):
 def match_storage_paths(document, classifier, user=None):
     pred_id = classifier.predict_storage_path(document.content) if classifier else None
 
+    if user is None and document.owner is not None:
+        user = document.owner
+
     if user is not None:
         storage_paths = get_objects_for_user_owner_aware(
             user,