fix emojis in polls
parent
089bac8dc6
commit
17330c073b
|
@ -295,8 +295,8 @@ class Comment(Base):
|
||||||
elif o.exclusive: s = '&&'
|
elif o.exclusive: s = '&&'
|
||||||
else: s = '$$'
|
else: s = '$$'
|
||||||
|
|
||||||
if f'{s}{o.body}{s}' in body:
|
if f'{s}{o.body_html}{s}' in body:
|
||||||
body = body.replace(f'{s}{o.body}{s}', option_body)
|
body = body.replace(f'{s}{o.body_html}{s}', option_body)
|
||||||
elif not o.created_utc or o.created_utc < 1677622270:
|
elif not o.created_utc or o.created_utc < 1677622270:
|
||||||
body += option_body
|
body += option_body
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ class SubmissionOption(Base):
|
||||||
|
|
||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
parent_id = Column(Integer, ForeignKey("submissions.id"))
|
parent_id = Column(Integer, ForeignKey("submissions.id"))
|
||||||
body = Column(Text)
|
|
||||||
body_html = Column(Text)
|
body_html = Column(Text)
|
||||||
exclusive = Column(Integer)
|
exclusive = Column(Integer)
|
||||||
created_utc = Column(Integer)
|
created_utc = Column(Integer)
|
||||||
|
@ -68,7 +67,6 @@ class CommentOption(Base):
|
||||||
|
|
||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
parent_id = Column(Integer, ForeignKey("comments.id"))
|
parent_id = Column(Integer, ForeignKey("comments.id"))
|
||||||
body = Column(Text)
|
|
||||||
body_html = Column(Text)
|
body_html = Column(Text)
|
||||||
exclusive = Column(Integer)
|
exclusive = Column(Integer)
|
||||||
created_utc = Column(Integer)
|
created_utc = Column(Integer)
|
||||||
|
|
|
@ -324,8 +324,8 @@ class Submission(Base):
|
||||||
elif o.exclusive: s = '&&'
|
elif o.exclusive: s = '&&'
|
||||||
else: s = '$$'
|
else: s = '$$'
|
||||||
|
|
||||||
if f'{s}{o.body}{s}' in body:
|
if f'{s}{o.body_html}{s}' in body:
|
||||||
body = body.replace(f'{s}{o.body}{s}', option_body)
|
body = body.replace(f'{s}{o.body_html}{s}', option_body)
|
||||||
elif not o.created_utc or o.created_utc < 1677622270:
|
elif not o.created_utc or o.created_utc < 1677622270:
|
||||||
body += option_body
|
body += option_body
|
||||||
|
|
||||||
|
|
|
@ -500,18 +500,19 @@ def process_poll_options(v:User, target:Union[Submission, Comment]):
|
||||||
else:
|
else:
|
||||||
cls = CommentOption
|
cls = CommentOption
|
||||||
|
|
||||||
|
body_html=filter_emojis_only(body)
|
||||||
|
|
||||||
g.db.flush()
|
g.db.flush()
|
||||||
existing = g.db.query(cls).filter_by(
|
existing = g.db.query(cls).filter_by(
|
||||||
parent_id=target.id,
|
parent_id=target.id,
|
||||||
body=body,
|
body_html=body_html,
|
||||||
exclusive=exclusive,
|
exclusive=exclusive,
|
||||||
).one_or_none()
|
).one_or_none()
|
||||||
|
|
||||||
if not existing:
|
if not existing:
|
||||||
option = cls(
|
option = cls(
|
||||||
parent_id=target.id,
|
parent_id=target.id,
|
||||||
body=body,
|
body_html=body_html,
|
||||||
body_html=filter_emojis_only(body),
|
|
||||||
exclusive=exclusive,
|
exclusive=exclusive,
|
||||||
)
|
)
|
||||||
g.db.add(option)
|
g.db.add(option)
|
||||||
|
|
|
@ -1,11 +1,3 @@
|
||||||
alter table submission_options add column body character varying(500);
|
|
||||||
update submission_options set body=body_html;
|
|
||||||
alter table submission_options alter column body set not null;
|
|
||||||
|
|
||||||
alter table comment_options add column body character varying(500);
|
|
||||||
update comment_options set body=body_html;
|
|
||||||
alter table comment_options alter column body set not null;
|
|
||||||
|
|
||||||
alter table submission_options rename column submission_id to parent_id;
|
alter table submission_options rename column submission_id to parent_id;
|
||||||
|
|
||||||
alter table comment_options rename column comment_id to parent_id;
|
alter table comment_options rename column comment_id to parent_id;
|
||||||
|
|
Loading…
Reference in New Issue