Show More
@@ -380,18 +380,20 b' class Post(models.Model, Viewable):' | |||||
380 |
|
380 | |||
381 | client = Client() |
|
381 | client = Client() | |
382 |
|
382 | |||
383 | thread = self.get_thread() |
|
|||
384 | thread_id = thread.id |
|
|||
385 | channel_name = WS_CHANNEL_THREAD + str(thread.get_opening_post_id()) |
|
|||
386 | client.publish(channel_name, { |
|
|||
387 | WS_NOTIFICATION_TYPE: WS_NOTIFICATION_TYPE_NEW_POST, |
|
|||
388 | }) |
|
|||
389 | client.send() |
|
|||
390 |
|
||||
391 | logger = logging.getLogger('boards.post.websocket') |
|
383 | logger = logging.getLogger('boards.post.websocket') | |
392 |
|
384 | |||
393 | logger.info('Sent notification from post #{} to channel {}'.format( |
|
385 | thread_ids = list() | |
394 | self.id, channel_name)) |
|
386 | for thread in self.get_threads().all(): | |
|
387 | thread_ids.append(thread.id) | |||
|
388 | ||||
|
389 | channel_name = WS_CHANNEL_THREAD + str(thread.get_opening_post_id()) | |||
|
390 | client.publish(channel_name, { | |||
|
391 | WS_NOTIFICATION_TYPE: WS_NOTIFICATION_TYPE_NEW_POST, | |||
|
392 | }) | |||
|
393 | client.send() | |||
|
394 | ||||
|
395 | logger.info('Sent notification from post #{} to channel {}'.format( | |||
|
396 | self.id, channel_name)) | |||
395 |
|
397 | |||
396 | if recursive: |
|
398 | if recursive: | |
397 | for reply_number in re.finditer(REGEX_REPLY, self.get_raw_text()): |
|
399 | for reply_number in re.finditer(REGEX_REPLY, self.get_raw_text()): | |
@@ -400,9 +402,9 b' class Post(models.Model, Viewable):' | |||||
400 | try: |
|
402 | try: | |
401 | ref_post = Post.objects.get(id=post_id) |
|
403 | ref_post = Post.objects.get(id=post_id) | |
402 |
|
404 | |||
403 | # If post is in this thread, its thread was already notified. |
|
405 | if ref_post.get_threads().exclude(id__in=thread_ids).exists(): | |
404 |
|
|
406 | # If post is in this thread, its thread was already notified. | |
405 | if ref_post.get_thread().id != thread_id: |
|
407 | # Otherwise, notify its thread separately. | |
406 | ref_post.send_to_websocket(request, recursive=False) |
|
408 | ref_post.send_to_websocket(request, recursive=False) | |
407 | except ObjectDoesNotExist: |
|
409 | except ObjectDoesNotExist: | |
408 | pass |
|
410 | pass |
@@ -22,7 +22,8 b' class TagView(AllThreadsView, Dispatcher' | |||||
22 | def get_threads(self): |
|
22 | def get_threads(self): | |
23 | tag = get_object_or_404(Tag, name=self.tag_name) |
|
23 | tag = get_object_or_404(Tag, name=self.tag_name) | |
24 |
|
24 | |||
25 | return tag.get_threads() |
|
25 | return tag.get_threads().exclude( | |
|
26 | tags__in=self.settings_manager.get_hidden_tags()) | |||
26 |
|
27 | |||
27 | def get_context_data(self, **kwargs): |
|
28 | def get_context_data(self, **kwargs): | |
28 | params = super(TagView, self).get_context_data(**kwargs) |
|
29 | params = super(TagView, self).get_context_data(**kwargs) |
General Comments 0
You need to be logged in to leave comments.
Login now