//#import $owl_message_read:services/modelService.jsx

var MessageUtil = (function () {
    var f = {
        getReadState: function (messageId, toObjId){
            var key = "owl_message_read_" + messageId + "_" + toObjId;
            var jMessageRead = owl_message_readService.get(key);
            if (jMessageRead && jMessageRead.state == "1") {
                return "1";
            }
            return "0";
        },
        updateToRead: function (messageId, toObjId) {
            var key = "owl_message_read_" + messageId + "_" + toObjId;
            var jMessageRead = owl_message_readService.get(key);
            if (jMessageRead) {
                return;
            }

            jMessageRead = {
                "_t": "message_read",
                "message_id": messageId,
                "toObjId": toObjId,
                "state": "1",
                "_orgId": "0",
                "_orgIds": ["0"],
                "createTime": new Date().getTime()
            };

            owl_message_readService.add(jMessageRead);
        }
    };
    return f;
})();