#NEWLINE# @ cherrypy . expose #NEWLINE# def post_message( self , room , message ) : #NEWLINE# #INDENT# if ( cherrypy . request . method != 'POST' ) : #NEWLINE# #INDENT# raise cherrypy . HTTPError ( 400 ) #NEWLINE# #UNINDENT# user = self . get_user ( ) #NEWLINE# if ( not user ) : #NEWLINE# #INDENT# raise cherrypy . HTTPError ( 402 ) #NEWLINE# #UNINDENT# ( reply , highlight , prepend ) = ( None , [ ] , None ) #NEWLINE# if ( message . startswith ( '::' ) and ( ' ' in message ) ) : #NEWLINE# #INDENT# reply = message . split ( ) [ 0 ] [ 2 : ] #NEWLINE# r_msg = self . find_message ( room , reply ) #NEWLINE# if r_msg : #NEWLINE# #INDENT# message = message . replace ( ( '::' + reply ) , '' ) #NEWLINE# highlight = [ r_msg ] #NEWLINE# p = self . find_user ( r_msg ) #NEWLINE# if p : #NEWLINE# #INDENT# if p [ 'name' ] : #NEWLINE# #INDENT# p = ( '@' + p [ 'name' ] . split ( ) [ 0 ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# p = ( '@User' + p [ 'num_id' ] ) #NEWLINE# #UNINDENT# prepend = p #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# reply = None #NEWLINE# #UNINDENT# #UNINDENT# for i in [ j [ 1 : ] for j in message . lower ( ) . split ( ) if j . startswith ( '@' ) ] : #NEWLINE# #INDENT# u = list ( self . find_user_by_name ( '' . join ( ( j for j in i if ( j in 'abcdefghijklmnopqrstuvwxyz' ) ) ) ) ) #NEWLINE# if u : #NEWLINE# #INDENT# highlight . extend ( u ) #NEWLINE# #UNINDENT# #UNINDENT# self . update_user ( user [ '_id' ] , { #NEWLINE# #INDENT# 'last_seen_date' : time . time ( ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# message = { #NEWLINE# #INDENT# 'raw' : self . safe ( message ) , #NEWLINE# 'markdown' : self . onebox_html ( self . markdown ( self . onebox ( message ) ) ) , #NEWLINE# 'date' : time . time ( ) , #NEWLINE# 'user' : user [ 'num_id' ] , #NEWLINE# 'num_id' : self . get_num_id ( ) , #NEWLINE# 'stars' : [ ] , #NEWLINE# 'reply_to' : reply , #NEWLINE# 'highlight' : highlight , #NEWLINE# 'prepend' : prepend , #NEWLINE# #UNINDENT# } #NEWLINE# self . inc_message_count ( room ) #NEWLINE# self . do_get_messages . cache_clear ( ) #NEWLINE# self . db . request ( 'POST' , ( '/%s_room_%s_messages/' % ( self . couchdb_prefix , room ) ) , body = message )