Small improvements
Some checks failed
docker-image / docker (push) Failing after 5s

This commit is contained in:
Stefan Bethke 2024-05-19 00:34:36 +02:00
commit b74873ae23
2 changed files with 15 additions and 8 deletions

View file

@ -10,6 +10,7 @@ from email.mime.base import MIMEBase
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from os import getenv
from textwrap import dedent
import humanize
import pgsql
@ -73,6 +74,7 @@ def notes_to_be_expired(cutoff: datetime) -> list[any]:
FROM "Notes", "Users"
WHERE "Notes"."updatedAt" < $1
AND "Notes"."ownerId" = "Users"."id"
ORDER BY "Notes"."updatedAt"
''') as notes_older_than:
for row in notes_older_than(cutoff):
notes.append({
@ -94,7 +96,6 @@ def revisions_to_be_expired(cutoff: datetime) -> list[any]:
"""
Obtain a list of revisions to be expired.
:param cutoff:
:param users:
:return:
"""
revisions = []
@ -111,6 +112,7 @@ def revisions_to_be_expired(cutoff: datetime) -> list[any]:
WHERE "Revisions"."createdAt" < $1
AND "Revisions"."noteId" = "Notes"."id"
AND "Notes"."ownerId" = "Users"."id"
ORDER BY "Notes"."createdAt"
''') as revs_older_than:
for row in revs_older_than(cutoff):
revisions.append({
@ -169,10 +171,10 @@ def expire_old_notes(age: timedelta, config: Config, mail: EmailSender) -> None:
Please find attached the contents of the latest revision of your note.
The Hedgedoc Admin team
The admin team for {config.url}
'''
)))
)))
md = MIMEBase('text', "markdown")
md.add_header('Content-Disposition', f'attachment; filename={note["title"]}')
md.set_payload(note["content"])
@ -202,7 +204,7 @@ if __name__ == '__main__':
epilog='See https://git.hamburg.ccc.de/CCCHH/hedgedoc-expire')
parser.add_argument('-c', '--check', action='store_true',
help='print what would be done, then exit')
parser.add_argument('-n', '--notes', metavar='DAYS', type=float, default=90,
parser.add_argument('-n', '--notes', metavar='DAYS', type=float, default=95,
help='remove all notes not changed in these many days')
parser.add_argument('-r', '--revisions', metavar='DAYS', type=float, default=14,
help='remove all revisions created more than these many days ago')