# -*- coding: utf-8 -*-

from message.models import SystemMessageInfo
from utils.redis.rmessage import get_system_message_delete_info, get_system_message_read_info


def system_messages(user_id, src=SystemMessageInfo.PAIAI_USER):
    """ Not Deleted """
    deleted_message_ids = get_system_message_delete_info(user_id)
    return SystemMessageInfo.objects.filter(src=src, status=True).exclude(pk__in=deleted_message_ids)


def system_unread_messages(user_id, src):
    """ Not Deleted & Read """
    read_message_ids = get_system_message_read_info(user_id)
    deleted_message_ids = get_system_message_delete_info(user_id)
    return SystemMessageInfo.objects.filter(src=src, status=True).exclude(pk__in=list(set(read_message_ids + deleted_message_ids)))
