@@ -53,7 +53,8 @@ import { BASE_URL,
5353 BULK_DOWNLOADS_PATH ,
5454 BIOPAX_DOWNLOADS_PATH ,
5555 BIOPAX_IDMAP_DOWNLOADS_PATH ,
56- ORCID_PUBLIC_API_BASE_URL
56+ ORCID_PUBLIC_API_BASE_URL ,
57+ DOI_LINK_BASE_URL
5758 } from '../../../../config' ;
5859
5960import { ENTITY_TYPE } from '../../../../model/element/entity-type' ;
@@ -1462,6 +1463,19 @@ const tweetDoc = ( doc, text ) => {
14621463 . then ( tweet => doc . setTweetMetadata ( tweet ) ) ;
14631464} ;
14641465
1466+ // reply to document tweet with article link
1467+ const tweetArticleReply = async doc => {
1468+ const { doi } = doc . citation ( ) ;
1469+ if ( ! doi || ! doc . hasTweet ( ) ) return ;
1470+
1471+ const { id_str : in_reply_to_status_id } = doc . tweetMetadata ( ) ;
1472+ const url = `${ DOI_LINK_BASE_URL } ${ doi } ` ;
1473+ const status = `Read the paper: ${ url } ` ;
1474+
1475+ await twitterClient . post ( 'statuses/update' , { status, in_reply_to_status_id } ) ;
1476+ return doc ;
1477+ } ;
1478+
14651479const tryTweetingDoc = async ( doc , text ) => {
14661480
14671481 const shouldTweet = doc => {
@@ -1475,6 +1489,7 @@ const tryTweetingDoc = async ( doc, text ) => {
14751489 try {
14761490 if ( ! text ) text = truncateString ( doc . toText ( ) , MAX_TWEET_LENGTH ) ;
14771491 await tweetDoc ( doc , text ) ;
1492+ await tweetArticleReply ( doc ) ;
14781493 } catch ( e ) {
14791494 logger . error ( `Error attempting to Tweet: ${ JSON . stringify ( e ) } ` ) ; //swallow
14801495 }
0 commit comments