From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Wed, 26 Apr 2023 16:37:43 +0000 (-0700) Subject: Use document owner for matching if set X-Git-Tag: v1.14.1~1^2~4^2 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F3198%2Fhead;p=thirdparty%2Fpaperless-ngx.git Use document owner for matching if set --- diff --git a/src/documents/matching.py b/src/documents/matching.py index 39a3d52b5c..521d492844 100644 --- a/src/documents/matching.py +++ b/src/documents/matching.py @@ -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,