Commit c31c47d6 authored by Deimos's avatar Deimos

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.
parent 6f1377fe
......@@ -4,6 +4,7 @@
"""Views related to posting/viewing topics and comments on them."""
from collections import namedtuple
from datetime import timedelta
from difflib import SequenceMatcher
from typing import Any, Optional, Union
......@@ -63,10 +64,13 @@ def post_group_topics(
group = request.context
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 = (
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))
.limit(5)
.all()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment