feat: boolean flag to send comments to rooms
This commit is contained in:
parent
98ee63688a
commit
d51f92e4c2
|
@ -71,13 +71,21 @@ def async_create_or_update_comment(comment):
|
|||
)
|
||||
notified_user_ids.add(thread_author.id)
|
||||
|
||||
# post top level comments to online channel
|
||||
# post top level comments to "online" channel
|
||||
if not comment.reply_to and comment.post.is_visible and comment.post.is_visible_in_feeds:
|
||||
send_telegram_message(
|
||||
chat=CLUB_ONLINE,
|
||||
text=render_html_message("channel_comment_announce.html", comment=comment),
|
||||
)
|
||||
|
||||
# post top level comments to "rooms" (if necessary)
|
||||
if not comment.reply_to and comment.post.is_visible:
|
||||
if comment.post.room_id and comment.post.room.chat_id and comment.post.room.send_new_comments_to_chat:
|
||||
send_telegram_message(
|
||||
chat=Chat(id=comment.post.room.chat_id),
|
||||
text=render_html_message("channel_comment_announce.html", comment=comment),
|
||||
)
|
||||
|
||||
# notify friends about your comments (not replies)
|
||||
if not comment.reply_to:
|
||||
friends = Friend.friends_for_user(comment.author)
|
||||
|
|
|
@ -49,7 +49,7 @@ def announce_in_club_chats(post):
|
|||
reply_markup=post_reply_markup,
|
||||
)
|
||||
|
||||
if post.room and post.room.chat_id:
|
||||
if post.room and post.room.chat_id and post.room.send_new_posts_to_chat:
|
||||
# announce to the room chat
|
||||
send_telegram_message(
|
||||
chat=Chat(id=post.room.chat_id),
|
||||
|
|
|
@ -12,11 +12,12 @@ class RoomsAdmin(admin.ModelAdmin):
|
|||
"icon",
|
||||
"color",
|
||||
"chat_name",
|
||||
"send_new_posts_to_chat",
|
||||
"send_new_comments_to_chat",
|
||||
"network_group",
|
||||
"last_activity_at",
|
||||
"is_visible",
|
||||
"is_open_for_posting",
|
||||
"is_bot_active",
|
||||
"index",
|
||||
)
|
||||
ordering = ("title",)
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
# Generated by Django 3.2.13 on 2023-09-25 12:39
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('rooms', '0002_auto_20230731_1419'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='room',
|
||||
old_name='is_bot_active',
|
||||
new_name='send_new_posts_to_chat',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='room',
|
||||
name='send_new_comments_to_chat',
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
]
|
|
@ -20,6 +20,8 @@ class Room(models.Model):
|
|||
chat_name = models.CharField(max_length=128, null=True, blank=True)
|
||||
chat_url = models.URLField(null=True, blank=True)
|
||||
chat_id = models.CharField(max_length=32, null=True, blank=True)
|
||||
send_new_posts_to_chat = models.BooleanField(default=True)
|
||||
send_new_comments_to_chat = models.BooleanField(default=False)
|
||||
|
||||
network_group = models.ForeignKey(
|
||||
"misc.NetworkGroup",
|
||||
|
@ -31,7 +33,6 @@ class Room(models.Model):
|
|||
|
||||
is_visible = models.BooleanField(default=True)
|
||||
is_open_for_posting = models.BooleanField(default=True)
|
||||
is_bot_active = models.BooleanField(default=True)
|
||||
|
||||
index = models.PositiveIntegerField(default=0)
|
||||
|
||||
|
|
Loading…
Reference in New Issue