def create_message(exploration_id, thread_id, author_id, updated_status, updated_subject, text):
 from core.domain import event_services
 full_thread_id = feedback_models.FeedbackThreadModel.generate_full_thread_id(exploration_id, thread_id)
 thread = feedback_models.FeedbackThreadModel.get(full_thread_id)
 message_id = feedback_models.FeedbackMessageModel.get_message_count(exploration_id, thread_id)
 msg = feedback_models.FeedbackMessageModel.create(exploration_id, thread_id, message_id)
 msg.thread_id = full_thread_id
 msg.message_id = message_id
 msg.author_id = author_id
 if updated_status:
  if (message_id == 0):
   event_services.FeedbackThreadCreatedEventHandler.record(thread.exploration_id)
  else:
   event_services.FeedbackThreadStatusChangedEventHandler.record(thread.exploration_id, thread.status, updated_status)
  msg.updated_status = updated_status
 if updated_subject:
  msg.updated_subject = updated_subject
 msg.text = text
 msg.put()
 old_status = thread.status
 if ((message_id != 0) and (updated_status or updated_subject)):
  if (updated_status and (updated_status != thread.status)):
   thread.status = updated_status
  if (updated_subject and (updated_subject != thread.subject)):
   thread.subject = updated_subject
 new_status = thread.status
 thread.put()
 if (user_services.is_user_registered(author_id) and feconf.CAN_SEND_EMAILS and feconf.CAN_SEND_FEEDBACK_MESSAGE_EMAILS):
  _add_message_to_email_buffer(author_id, exploration_id, thread_id, message_id, len(text), old_status, new_status)
 if author_id:
  subscription_services.subscribe_to_thread(author_id, full_thread_id)

def create_message ( exploration_id , thread_id , author_id , updated_status , updated_subject , text ) : from core . domain import event_services full_thread_id = feedback_models . FeedbackThreadModel . generate_full_thread_id ( exploration_id , thread_id ) thread = feedback_models . FeedbackThreadModel . get ( full_thread_id ) message_id = feedback_models . FeedbackMessageModel . get_message_count ( exploration_id , thread_id ) msg = feedback_models . FeedbackMessageModel . create ( exploration_id , thread_id , message_id ) msg . thread_id = full_thread_id msg . message_id = message_id msg . author_id = author_id if updated_status : if ( message_id == 0 ) : event_services . FeedbackThreadCreatedEventHandler . record ( thread . exploration_id ) else : event_services . FeedbackThreadStatusChangedEventHandler . record ( thread . exploration_id , thread . status , updated_status ) msg . updated_status = updated_status if updated_subject : msg . updated_subject = updated_subject msg . text = text msg . put ( ) old_status = thread . status if ( ( message_id != 0 ) and ( updated_status or updated_subject ) ) : if ( updated_status and ( updated_status != thread . status ) ) : thread . status = updated_status if ( updated_subject and ( updated_subject != thread . subject ) ) : thread . subject = updated_subject new_status = thread . status thread . put ( ) if ( user_services . is_user_registered ( author_id ) and feconf . CAN_SEND_EMAILS and feconf . CAN_SEND_FEEDBACK_MESSAGE_EMAILS ) : _add_message_to_email_buffer ( author_id , exploration_id , thread_id , message_id , len ( text ) , old_status , new_status ) if author_id : subscription_services . subscribe_to_thread ( author_id , full_thread_id )
create a message in the db .