コード例 #1
0
ファイル: consumers.py プロジェクト: katkoffff/web
def append_unread_msg_if_not_connected(room, user, connected_users, message):
    if not user in connected_users:
        try:
            unread_msgs = UnreadChatRoomMessages.objects.get(room=room,
                                                             user=user)
            unread_msgs.most_recent_message = message
            unread_msgs.count += 1
            unread_msgs.save()
        except UnreadChatRoomMessages.DoesNotExist:
            UnreadChatRoomMessages(room=room, user=user, count=1).save()
            pass
    return
コード例 #2
0
ファイル: consumers.py プロジェクト: lostdawg3/CodingWithChat
def on_user_connected(room, user):
    connected_users = room.connected_users.all()

    if user in connected_users:
        try:
            unread_msgs = UnreadChatRoomMessages.objects.get(room=room,
                                                             user=user)
            unread_msgs.count = 0
            unread_msgs.save()
        except UnreadChatRoomMessages.DoesNotExist:
            UnreadChatRoomMessages(room=room, user=user, count=0).save()
            pass
    return
コード例 #3
0
ファイル: consumers.py プロジェクト: katkoffff/web
def on_user_connected(room, user):
    # confirm they are in the connected users list
    connected_users = room.connected_users.all()
    if user in connected_users:
        try:
            # reset count
            unread_msgs = UnreadChatRoomMessages.objects.get(room=room,
                                                             user=user)
            unread_msgs.count = 0
            unread_msgs.save()
        except UnreadChatRoomMessages.DoesNotExist:
            UnreadChatRoomMessages(room=room, user=user).save()
            pass
    return