allow poll options with the same text

pull/136/head
Aevann 2023-03-01 01:46:11 +02:00
parent bb86347362
commit 96ce985cd6
3 changed files with 3 additions and 4 deletions

View File

@ -296,7 +296,7 @@ class Comment(Base):
else: s = '$$'
if f'{s}{o.body_html}{s}' in body:
body = body.replace(f'{s}{o.body_html}{s}', option_body)
body = body.replace(f'{s}{o.body_html}{s}', option_body, 1)
elif not o.created_utc or o.created_utc < 1677622270:
body += option_body

View File

@ -325,7 +325,7 @@ class Submission(Base):
else: s = '$$'
if f'{s}{o.body_html}{s}' in body:
body = body.replace(f'{s}{o.body_html}{s}', option_body)
body = body.replace(f'{s}{o.body_html}{s}', option_body, 1)
elif not o.created_utc or o.created_utc < 1677622270:
body += option_body

View File

@ -502,12 +502,11 @@ def process_poll_options(v:User, target:Union[Submission, Comment]):
body_html=filter_emojis_only(body)
g.db.flush()
existing = g.db.query(cls).filter_by(
parent_id=target.id,
body_html=body_html,
exclusive=exclusive,
).one_or_none()
).first()
if not existing:
option = cls(