fix(communications): Исправить вызов метода get_participants()
- signals.py: chat.get_participants → chat.get_participants() - notifications/handlers.py: chat.get_participants → chat.get_participants() Ошибка: AttributeError: 'function' object has no attribute 'exclude' Причина: Метод не вызывался, пытались вызвать метод на самом объекте функции Исправлено: Добавлены () для вызова метода и получения QuerySet
This commit is contained in:
parent
45b35b0f36
commit
0c00652c8e
@ -3,12 +3,12 @@ Serializers for Communications API
|
||||
"""
|
||||
from rest_framework import serializers
|
||||
from django.contrib.auth import get_user_model
|
||||
from communications.models import (
|
||||
from ..models import (
|
||||
Chat, Message, MessageAttachment,
|
||||
MessageReaction, Poll, PollOption, PollVote,
|
||||
ChatMembership, ChatUserSettings
|
||||
)
|
||||
from communications.serialization import serialize_message
|
||||
from ..serialization import serialize_message
|
||||
|
||||
Employee = get_user_model()
|
||||
|
||||
|
||||
@ -19,12 +19,12 @@ from datetime import timezone as dt_tz
|
||||
|
||||
from asgiref.sync import async_to_sync
|
||||
from channels.layers import get_channel_layer
|
||||
from communications.models import (Chat, ChatMembership, ChatReadState,
|
||||
from ..models import (Chat, ChatMembership, ChatReadState,
|
||||
ChatUserSettings, Message,
|
||||
MessageAttachment, MessageReaction, Poll,
|
||||
PollOption, PollVote)
|
||||
from communications.serialization import serialize_message
|
||||
from communications.utils import _coerce_ts, user_can_access_chat
|
||||
from ..utils import _coerce_ts, user_can_access_chat
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.db import transaction
|
||||
from django.db.models import Count, Exists, OuterRef, Prefetch, Q, Subquery
|
||||
|
||||
@ -71,7 +71,7 @@ def notify_new_message(message):
|
||||
|
||||
# Получаем всех участников чата кроме автора
|
||||
if chat.type in ['announcement', 'channel', 'department', 'global']:
|
||||
participants = chat.get_participants.exclude(id=author.id)
|
||||
participants = chat.get_participants().exclude(id=author.id)
|
||||
else:
|
||||
participants = chat.participants.exclude(id=author.id)
|
||||
|
||||
|
||||
@ -123,7 +123,7 @@ def increment_unread_count_on_new_message(sender, instance, created, **kwargs):
|
||||
try:
|
||||
# Получаем всех участников чата
|
||||
chat = instance.chat
|
||||
participants = chat.get_participants.exclude(id=instance.author_id)
|
||||
participants = chat.get_participants().exclude(id=instance.author_id)
|
||||
|
||||
# Инкрементируем счетчик для существующих ChatReadState
|
||||
# Только для тех, кто еще не прочитал это сообщение
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user