Browse Source

Restrict link topic repost check to last 6 months

Previously, when checking if a link had been posted before, there was no
restriction on the time limit, so even posts from years ago would come
up. This restricts it to only the last 6 months, which I think is a
pretty reasonable time period for reposting.
merge-requests/126/merge
Deimos 4 years ago
parent
commit
c31c47d6b1
  1. 8
      tildes/tildes/views/topic.py

8
tildes/tildes/views/topic.py

@ -4,6 +4,7 @@
"""Views related to posting/viewing topics and comments on them.""" """Views related to posting/viewing topics and comments on them."""
from collections import namedtuple from collections import namedtuple
from datetime import timedelta
from difflib import SequenceMatcher from difflib import SequenceMatcher
from typing import Any, Optional, Union from typing import Any, Optional, Union
@ -63,10 +64,13 @@ def post_group_topics(
group = request.context group = request.context
if link: if link:
# check to see if this link has been posted before
# check to see if this link has already been posted in the last 6 months
previous_topics = ( previous_topics = (
request.query(Topic) request.query(Topic)
.filter(Topic.link == link)
.filter(
Topic.link == link,
Topic.created_time >= utc_now() - timedelta(days=180),
)
.order_by(desc(Topic.created_time)) .order_by(desc(Topic.created_time))
.limit(5) .limit(5)
.all() .all()

Loading…
Cancel
Save