From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Fri, 3 Feb 2023 22:23:50 +0000 (-0800) Subject: Merge branch 'dev' into feature-permissions X-Git-Tag: v1.14.0-beta.rc1~109^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d2a6f79612973f3cdd66f6c8e15da6a0654f8432;p=thirdparty%2Fpaperless-ngx.git Merge branch 'dev' into feature-permissions --- d2a6f79612973f3cdd66f6c8e15da6a0654f8432 diff --cc src/documents/index.py index 5adbcc5b69,e11708f459..c0b3f54659 --- a/src/documents/index.py +++ b/src/documents/index.py @@@ -5,9 -5,9 +5,10 @@@ from contextlib import contextmanage from dateutil.parser import isoparse from django.conf import settings + from django.utils import timezone from documents.models import Comment from documents.models import Document +from guardian.shortcuts import get_users_with_perms from whoosh import classify from whoosh import highlight from whoosh import query @@@ -98,11 -94,18 +99,23 @@@ def update_document(writer: AsyncWriter tags = ",".join([t.name for t in doc.tags.all()]) tags_ids = ",".join([str(t.id) for t in doc.tags.all()]) comments = ",".join([str(c.comment) for c in Comment.objects.filter(document=doc)]) + asn = doc.archive_serial_number + if asn is not None and ( + asn < Document.ARCHIVE_SERIAL_NUMBER_MIN + or asn > Document.ARCHIVE_SERIAL_NUMBER_MAX + ): + logger.error( + f"Not indexing Archive Serial Number {asn} of document {doc.pk}. " + f"ASN is out of range " + f"[{Document.ARCHIVE_SERIAL_NUMBER_MIN:,}, " + f"{Document.ARCHIVE_SERIAL_NUMBER_MAX:,}.", + ) + asn = 0 + users_with_perms = get_users_with_perms( + doc, + only_with_perms_in=["view_document"], + ) + viewer_ids = ",".join([str(u.id) for u in users_with_perms]) writer.update_document( id=doc.pk, title=doc.title,