|
@@ -6,7 +6,7 @@ from flask_restful import Resource, marshal_with, reqparse
|
|
|
from flask_restful.inputs import int_range
|
|
|
from sqlalchemy import func, or_
|
|
|
from sqlalchemy.orm import joinedload
|
|
|
-from werkzeug.exceptions import NotFound
|
|
|
+from werkzeug.exceptions import Forbidden, NotFound
|
|
|
|
|
|
from controllers.console import api
|
|
|
from controllers.console.app.wraps import get_app_model
|
|
@@ -33,6 +33,8 @@ class CompletionConversationApi(Resource):
|
|
|
@get_app_model(mode=AppMode.COMPLETION)
|
|
|
@marshal_with(conversation_pagination_fields)
|
|
|
def get(self, app_model):
|
|
|
+ if not current_user.is_admin_or_owner:
|
|
|
+ raise Forbidden()
|
|
|
parser = reqparse.RequestParser()
|
|
|
parser.add_argument('keyword', type=str, location='args')
|
|
|
parser.add_argument('start', type=datetime_string('%Y-%m-%d %H:%M'), location='args')
|
|
@@ -106,6 +108,8 @@ class CompletionConversationDetailApi(Resource):
|
|
|
@get_app_model(mode=AppMode.COMPLETION)
|
|
|
@marshal_with(conversation_message_detail_fields)
|
|
|
def get(self, app_model, conversation_id):
|
|
|
+ if not current_user.is_admin_or_owner:
|
|
|
+ raise Forbidden()
|
|
|
conversation_id = str(conversation_id)
|
|
|
|
|
|
return _get_conversation(app_model, conversation_id)
|
|
@@ -115,6 +119,8 @@ class CompletionConversationDetailApi(Resource):
|
|
|
@account_initialization_required
|
|
|
@get_app_model(mode=[AppMode.CHAT, AppMode.AGENT_CHAT, AppMode.ADVANCED_CHAT])
|
|
|
def delete(self, app_model, conversation_id):
|
|
|
+ if not current_user.is_admin_or_owner:
|
|
|
+ raise Forbidden()
|
|
|
conversation_id = str(conversation_id)
|
|
|
|
|
|
conversation = db.session.query(Conversation) \
|
|
@@ -137,6 +143,8 @@ class ChatConversationApi(Resource):
|
|
|
@get_app_model(mode=[AppMode.CHAT, AppMode.AGENT_CHAT, AppMode.ADVANCED_CHAT])
|
|
|
@marshal_with(conversation_with_summary_pagination_fields)
|
|
|
def get(self, app_model):
|
|
|
+ if not current_user.is_admin_or_owner:
|
|
|
+ raise Forbidden()
|
|
|
parser = reqparse.RequestParser()
|
|
|
parser.add_argument('keyword', type=str, location='args')
|
|
|
parser.add_argument('start', type=datetime_string('%Y-%m-%d %H:%M'), location='args')
|
|
@@ -225,6 +233,8 @@ class ChatConversationDetailApi(Resource):
|
|
|
@get_app_model(mode=[AppMode.CHAT, AppMode.AGENT_CHAT, AppMode.ADVANCED_CHAT])
|
|
|
@marshal_with(conversation_detail_fields)
|
|
|
def get(self, app_model, conversation_id):
|
|
|
+ if not current_user.is_admin_or_owner:
|
|
|
+ raise Forbidden()
|
|
|
conversation_id = str(conversation_id)
|
|
|
|
|
|
return _get_conversation(app_model, conversation_id)
|
|
@@ -234,6 +244,8 @@ class ChatConversationDetailApi(Resource):
|
|
|
@get_app_model(mode=[AppMode.CHAT, AppMode.AGENT_CHAT, AppMode.ADVANCED_CHAT])
|
|
|
@account_initialization_required
|
|
|
def delete(self, app_model, conversation_id):
|
|
|
+ if not current_user.is_admin_or_owner:
|
|
|
+ raise Forbidden()
|
|
|
conversation_id = str(conversation_id)
|
|
|
|
|
|
conversation = db.session.query(Conversation) \
|