Example #1
0
    def _body(self):
        _message = {}
        _message["id"] = self._task.get("uuid")
        _message["fi"] = self._task.get("from_uuid")
        _message["ti"] = self._task.get("to_uuid")
        _message["ft"] = self._task.get("from_type")
        _message["tt"] = self._task.get("to_type")
        _message["mt"] = self._task.get("message_type")
        _message["ms"] = self._task.get("message_subtype")
        _message["ci"] = self._task.get("conversation_uuid")
        _message["ct"] = self._task.get("conversation_type")
        _message["tl"] = self._task.get("title")
        _message["bo"] = self._task.get("body")

        if _message["ct"] == CONVERSATION_TYPE.S2P:
            _message["ti"] = self._task["app_uuid"]
            _message["tt"] = YVOBJECT.AP
            if self._name == APP_POLICY.GROUP:
                #_message["ti"] == self._task["to_uuid"]
                _message["tt"] == YVOBJECT.OG
                
        if isinstance(self._task.get("title"), unicode):
            _message["tl"] = self._task.get("title").encode("utf-8")
        if isinstance(self._task.get("body"), unicode):
            _message["bo"] = self._task.get("body").encode("utf-8")

        _message["ts"] = datetime_to_microsecond_timestamp(self._task["createtime"])
        
        self._task["message_body"] = _message

        _message_body = json.dumps(self._task["message_body"])
        if isinstance(_message_body, unicode):
            _message_body = _message_body.encode("utf-8")
            
        _values = {
            "uuid": self._task["uuid"],
            "task_status": TASK_STATUS.PROCESSED,
            "message_body": _message_body,
        }
        _row = MessagePushTask(**_values)
        _row.async_update(self._redis)
        _row.update_redis_keys(self._redis)
        return
    def _result_data(self, _conversation, _member_list):
        _now = datetime.datetime.now()
        _now_timestamp = datetime_to_microsecond_timestamp(_now)

        _rdata = {}
        _rdata["user_list"] = _member_list        
        _rdata["uuid"] = _conversation["uuid"]
        _rdata["user_uuid"] = self._user_uuid
        _rdata["assigned_uuid"] = _conversation.get("assigned_uuid")
        _rdata["group_uuid"] = self._group_uuid
        _rdata["status"] = CONVERSATION_STATUS.NEW
        _rdata["conversation_name"] = self._return_name
        _rdata["conversation_icon"] = self._return_icon
        _rdata["conversation_type"] = self._conv_type
        _rdata["updatetime"] = _now
        _rdata["createtime"] = _now
        _rdata["updatetimestamp"] = _now_timestamp
        _rdata["createtimestamp"] = _now_timestamp
        return _rdata