#NEWLINE# def do_send_to_twitter( post_id , app_config ) : #NEWLINE# #INDENT# with async_app_context ( app_config ) : #NEWLINE# #INDENT# current_app . logger . debug ( 'auto-posting to twitter for %s' , post_id ) #NEWLINE# post = Post . load_by_id ( post_id ) #NEWLINE# ( in_reply_to , repost_of , like_of ) = util . posse_post_discovery ( repost_of , PERMALINK_RE ) #NEWLINE# if ( post . in_reply_to and ( not in_reply_to ) ) : #NEWLINE# #INDENT# current_app . logger . warn ( 'could not find tweet to reply to for %s' , post . in_reply_to ) #NEWLINE# return None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( post . repost_of and ( not repost_of ) ) : #NEWLINE# #INDENT# current_app . logger . warn ( 'could not find tweet to repost for %s' , post . repost_of ) #NEWLINE# ( preview , img_url ) = guess_raw_share_tweet_content ( post ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( post . like_of and ( not like_of ) ) : #NEWLINE# #INDENT# current_app . logger . warn ( 'could not find tweet to like for %s' , post . like_of ) #NEWLINE# return None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( preview , img_url ) = guess_tweet_content ( post , in_reply_to ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# response = do_tweet ( post_id , preview , img_url , in_reply_to , repost_of , like_of ) #NEWLINE# return str ( response )