@@ -56,6 +56,7 @@ const PARAMS__HIDE = 'hide';
5656const PARAMS__LINK_ATTACHMENT = 'link_attachment' ;
5757const PARAMS__METRIC = 'metric' ;
5858const PARAMS__QUOTA_USAGE = 'quota_usage' ;
59+ const PARAMS__QUOTE_POST_ID = 'quote_post_id' ;
5960const PARAMS__REDIRECT_URI = 'redirect_uri' ;
6061const PARAMS__REPLY_CONFIG = 'reply_config' ;
6162const PARAMS__REPLY_CONTROL = 'reply_control' ;
@@ -293,23 +294,46 @@ app.get('/publishingLimit', loggedInUserChecker, async (req, res) => {
293294} ) ;
294295
295296app . get ( '/upload' , loggedInUserChecker , ( req , res ) => {
296- const { replyToId } = req . query ;
297+ const { replyToId, quotePostId } = req . query ;
297298 const title = replyToId === undefined ? 'Upload' : 'Upload (Reply)' ;
298299 res . render ( 'upload' , {
299300 title,
300- replyToId
301+ replyToId,
302+ quotePostId,
301303 } ) ;
302304} ) ;
303305
306+ app . post ( '/repost' , upload . array ( ) , async ( req , res ) => {
307+ const { repostId } = req . body ;
308+
309+ const repostThreadsUrl = buildGraphAPIURL ( `${ repostId } /repost` , { } , req . session . access_token ) ;
310+ try {
311+ const repostResponse = await axios . post ( repostThreadsUrl , { } ) ;
312+ const containerId = repostResponse . data . id ;
313+ return res . redirect ( `threads/${ containerId } ` ) ;
314+ }
315+ catch ( e ) {
316+ console . error ( e . message ) ;
317+ return res . json ( {
318+ error : true ,
319+ message : `Error during repost: ${ e } ` ,
320+ } ) ;
321+ }
322+ } ) ;
323+
304324app . post ( '/upload' , upload . array ( ) , async ( req , res ) => {
305- const { text, attachmentType, attachmentUrl, attachmentAltText, replyControl, replyToId, linkAttachment } = req . body ;
325+ const { text, attachmentType, attachmentUrl, attachmentAltText, replyControl, replyToId, linkAttachment, quotePostId } = req . body ;
306326 const params = {
307327 [ PARAMS__TEXT ] : text ,
308328 [ PARAMS__REPLY_CONTROL ] : replyControl ,
309329 [ PARAMS__REPLY_TO_ID ] : replyToId ,
310- [ PARAMS__LINK_ATTACHMENT ] : linkAttachment
330+ [ PARAMS__LINK_ATTACHMENT ] : linkAttachment ,
311331 } ;
312332
333+ if ( quotePostId ) {
334+ params [ PARAMS__QUOTE_POST_ID ] = quotePostId ;
335+ }
336+
313337 // No attachments
314338 if ( ! attachmentType ?. length ) {
315339 params . media_type = MEDIA_TYPE__TEXT ;
0 commit comments