Beispiel #1
0
 def post(self, **kwargs):
     """  接口: 1. 标记消息为已读-read
               2. 设置系统消息-sys
     """
     type = kwargs.get('type')
     msg_id = kwargs.get('msg_id')
    # self.write({'read msg_id':msg_id})
    # return
     if type == 'read' and msg_id:
         result = Message.mark_read(user_id=kwargs['uid'], msg_id=msg_id)
     elif type == 'sys' and (kwargs['uid'] == 'admin' or configs['test_mode']):  # todo 系统用户才能设置系统消息
         data = json_decode(self.request.body)
         content = data.get('content')
         if content:
             result = Message.set_message(type=Message._type_sys, content=content)
     else:
         raise HTTPError(404, 'not support post method or user not support')
     self.write(result.dictify())
     self.set_status(201)