fix comment after signal moderation

This commit is contained in:
j 2023-09-02 11:08:26 +01:00
parent eeed2fe503
commit df947f9523
3 changed files with 14 additions and 2 deletions

View file

@ -166,5 +166,6 @@ SIGNAL_MODERATORS = []
RATELIMIT_CACHE_BACKEND = "app.brake_backend.BrakeBackend"
SITENAME = "Phantas.ma"
URL = "https://phantas.ma"
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

View file

@ -31,8 +31,18 @@ def main():
if group == settings.SIGNAL_MODERATORS_GROUP:
if emoji == "👍" and target_author == settings.SIGNAL_ACCOUNT:
if source in settings.SIGNAL_MODERATORS:
from ..item import models
from ..item import models, tasks
now = timezone.now()
try:
comment = models.Comment.objects.filter(data__moderator_ts=target_ts).first()
if comment:
link = settings.URL + comment.item.get_absolute_url()
msg = '%s commented on <b>%s</b> at <a href="%s">%s</a>' % (
comment.name, comment.item.title, link, link
)
tasks.notify_telegram.delay(msg)
except:
pass
models.Comment.objects.filter(data__moderator_ts=target_ts).update(published=now)
rpc.send_reaction(target_author, target_ts, "🎉", group=group)
else:

View file

@ -22,7 +22,8 @@ def send(msg, to=None, channel=None, preview_url=None, preview_title=None, previ
asyncio.run(bot.send_message(
chat_id=channel,
text=msg,
parse_mode='html'
parse_mode='html',
disable_web_page_preview=True
))
except:
logger.error("failed to send message to telegram: %s", msg, exc_info=True)