def is_unique_msg(msg, previous_msg_ids, previous_run_time):
    """
    Determines if message is unique given previous message ids, and that it's greater than previous run time
    :param msg: raw Message object
    :param previous_msg_ids: set of previously fetched message ids
    :param previous_run_time: previous run time string
    :return: True if message is unique
    """
    message_dict = msg.get("message", {})
    if message_dict:
        msg_id = message_dict.get("messageId")
        msg_pub_time = message_dict.get("publishTime", "")
        return msg_id not in previous_msg_ids and msg_pub_time > previous_run_time
    return False