#NEWLINE# def create( self , request , * args , **kwargs ) : #NEWLINE# #INDENT# recipients = request . data . get ( 'recipients' , False ) #NEWLINE# if recipients : #NEWLINE# #INDENT# conversations = self . queryset . filter ( deleted = False , recipients__in = recipients ) #NEWLINE# if ( len ( conversations ) > 0 ) : #NEWLINE# #INDENT# response_data = ConversationSerializer ( instance = conversations [ 0 ] , context = { #NEWLINE# #INDENT# 'request' : request , #NEWLINE# #UNINDENT# } ) . data #NEWLINE# return Response ( data = args ) #NEWLINE# #UNINDENT# #UNINDENT# serializer = ConversationSerializer ( data = request . data , context = { #NEWLINE# #INDENT# 'request' : request , #NEWLINE# #UNINDENT# } ) #NEWLINE# if serializer . is_valid ( ) : #NEWLINE# #INDENT# obj = serializer . create ( sender = request . user ) #NEWLINE# response_data = ConversationSerializer ( instance = obj , context = { #NEWLINE# #INDENT# 'request' : request , #NEWLINE# #UNINDENT# } ) . data #NEWLINE# return Response ( data = response_data ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return Response ( serializer . errors , status = status . HTTP_400_BAD_REQUEST )