def post_save(self, serializer): queryset = self.thread.subscription_set.filter( send_email=True, last_read_on__gte=self.previous_last_post_on).exclude( user=self.user).select_related('user') notifications = [] for subscription in queryset.iterator(): if self.notify_user_of_post(subscription.user): notifications.append(self.build_mail(subscription.user)) if notifications: send_messages(notifications)
def add_participants(request, thread, users): """ Add multiple participants to thread, set "recound private threads" flag on them notify them about being added to thread """ ThreadParticipant.objects.add_participants(thread, users) try: thread_participants = thread.participants_list except AttributeError: thread_participants = [] set_users_unread_private_threads_sync(users=users, participants=thread_participants, exclude_user=request.user) emails = [] for user in users: if user != request.user: emails.append(build_noticiation_email(request, thread, user)) if emails: send_messages(emails)
def add_participants(request, thread, users): """ Add multiple participants to thread, set "recound private threads" flag on them notify them about being added to thread """ ThreadParticipant.objects.add_participants(thread, users) try: thread_participants = thread.participants_list except AttributeError: thread_participants = [] set_users_unread_private_threads_sync( users=users, participants=thread_participants, exclude_user=request.user ) emails = [] for user in users: if user != request.user: emails.append(build_noticiation_email(request, thread, user)) if emails: send_messages(emails)