fix comment after signal moderation
This commit is contained in:
parent
eeed2fe503
commit
df947f9523
3 changed files with 14 additions and 2 deletions
|
@ -166,5 +166,6 @@ SIGNAL_MODERATORS = []
|
||||||
RATELIMIT_CACHE_BACKEND = "app.brake_backend.BrakeBackend"
|
RATELIMIT_CACHE_BACKEND = "app.brake_backend.BrakeBackend"
|
||||||
|
|
||||||
SITENAME = "Phantas.ma"
|
SITENAME = "Phantas.ma"
|
||||||
|
URL = "https://phantas.ma"
|
||||||
|
|
||||||
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
||||||
|
|
|
@ -31,8 +31,18 @@ def main():
|
||||||
if group == settings.SIGNAL_MODERATORS_GROUP:
|
if group == settings.SIGNAL_MODERATORS_GROUP:
|
||||||
if emoji == "👍" and target_author == settings.SIGNAL_ACCOUNT:
|
if emoji == "👍" and target_author == settings.SIGNAL_ACCOUNT:
|
||||||
if source in settings.SIGNAL_MODERATORS:
|
if source in settings.SIGNAL_MODERATORS:
|
||||||
from ..item import models
|
from ..item import models, tasks
|
||||||
now = timezone.now()
|
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)
|
models.Comment.objects.filter(data__moderator_ts=target_ts).update(published=now)
|
||||||
rpc.send_reaction(target_author, target_ts, "🎉", group=group)
|
rpc.send_reaction(target_author, target_ts, "🎉", group=group)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -22,7 +22,8 @@ def send(msg, to=None, channel=None, preview_url=None, preview_title=None, previ
|
||||||
asyncio.run(bot.send_message(
|
asyncio.run(bot.send_message(
|
||||||
chat_id=channel,
|
chat_id=channel,
|
||||||
text=msg,
|
text=msg,
|
||||||
parse_mode='html'
|
parse_mode='html',
|
||||||
|
disable_web_page_preview=True
|
||||||
))
|
))
|
||||||
except:
|
except:
|
||||||
logger.error("failed to send message to telegram: %s", msg, exc_info=True)
|
logger.error("failed to send message to telegram: %s", msg, exc_info=True)
|
||||||
|
|
Loading…
Reference in a new issue