Commit e107801a authored by zhanglu's avatar zhanglu

创建帖子时,用户检测

parent 600da6e3
...@@ -3,6 +3,8 @@ import json ...@@ -3,6 +3,8 @@ import json
from api.views.base_view import BaseView from api.views.base_view import BaseView
from api.utils.sensitive import Sensitive from api.utils.sensitive import Sensitive
from libs.user import get_user_by_ids
from alpha_types.venus import ERROR as CODES
class CreateTopicForBatch(BaseView): class CreateTopicForBatch(BaseView):
""" """
...@@ -16,6 +18,10 @@ class CreateTopicForBatch(BaseView): ...@@ -16,6 +18,10 @@ class CreateTopicForBatch(BaseView):
if not user_id: if not user_id:
return self.parameter_invalid_response() return self.parameter_invalid_response()
user_info = get_user_by_ids([user_id])
if not user_info:
return self.error(self.get_ErrorInfo(CODES.USER_NOT_FOUND))
if not topic_list: if not topic_list:
return self.ok() return self.ok()
......
...@@ -7,6 +7,7 @@ from helios.rpc import RPCFaultException ...@@ -7,6 +7,7 @@ from helios.rpc import RPCFaultException
from libs.utils import DictWrapperUseDot from libs.utils import DictWrapperUseDot
from engine.logger import auth_logger from engine.logger import auth_logger
from engine.rpc import get_current_rpc_invoker
def get_user_by_request(request): def get_user_by_request(request):
...@@ -33,6 +34,18 @@ def get_user_by_request(request): ...@@ -33,6 +34,18 @@ def get_user_by_request(request):
return DictWrapperUseDot(info) return DictWrapperUseDot(info)
def get_user_by_ids(user_ids):
"""获取用户信息"""
try:
rpc = get_current_rpc_invoker()
users_info = rpc["venus/account/user/userinfo_list"](user_ids=user_ids).unwrap()
except:
return None
return users_info
def auth(request): def auth(request):
user_info = get_user_by_request(request) user_info = get_user_by_request(request)
if not user_info: if not user_info:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment