feat: add preview=1 to chat announcements
This commit is contained in:
parent
5bb6d3c575
commit
16199815c9
|
@ -10,13 +10,16 @@ from notifications.telegram.bot import bot
|
|||
@receiver(post_save, sender=Comment)
|
||||
def create_comment(sender, instance, created, **kwargs):
|
||||
if not created:
|
||||
return
|
||||
return # skip updates
|
||||
|
||||
comment = instance
|
||||
post = comment.post
|
||||
|
||||
link = f"https://{settings.APP_HOST}/{post.type}/{post.slug}/"
|
||||
|
||||
if not post.is_published():
|
||||
link += "?preview=1"
|
||||
|
||||
if comment.block:
|
||||
link += f"#block-{comment.block}-{comment.id}"
|
||||
else:
|
||||
|
|
|
@ -71,6 +71,9 @@ class Post(models.Model):
|
|||
self.updated_at = datetime.utcnow()
|
||||
return super().save(*args, **kwargs)
|
||||
|
||||
def is_published(self):
|
||||
return self.is_visible and self.published_at < datetime.utcnow()
|
||||
|
||||
def get_absolute_url(self):
|
||||
if self.url:
|
||||
return self.url
|
||||
|
|
Loading…
Reference in New Issue