Skip to content

Commit e48befa

Browse files
feat: Bluesky Integration (#1050)
* feat: Bluesky integration * feat: add refresh_token for Bluesky * chore: phpcs fix * chore: linting
1 parent 88aa257 commit e48befa

9 files changed

Lines changed: 896 additions & 16 deletions

File tree

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ module.exports = {
6767
allowedTextDomain: 'tweet-old-post',
6868
},
6969
],
70-
'@wordpress/no-unsafe-wp-apis': false,
70+
'@wordpress/no-unsafe-wp-apis': 0,
7171
},
7272
},
7373
],

assets/css/rop_core.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,12 @@ a.active {
847847
display: flex;
848848
align-items: center;
849849
}
850+
#rop_core .btn.btn-bluesky {
851+
background-color: #1A8CD8;
852+
color: #fff;
853+
display: flex;
854+
align-items: center;
855+
}
850856

851857
#rop_core
852858
.btn:is(

includes/admin/class-rop-global-settings.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,12 @@ class Rop_Global_Settings {
151151
'two_step_sign_in' => true,
152152
'allowed_comment' => false,
153153
),
154+
'bluesky' => array(
155+
'active' => false,
156+
'name' => 'Bluesky',
157+
'two_step_sign_in' => true,
158+
'allowed_comment' => false,
159+
),
154160
);
155161

156162
/**
@@ -415,6 +421,28 @@ class Rop_Global_Settings {
415421
'utm_campaign_medium' => 'social',
416422
'utm_campaign_name' => 'ReviveOldPost',
417423
),
424+
'bluesky' => array(
425+
'wpml_language' => '',
426+
'post_content' => 'post_title',
427+
'custom_meta_field' => '',
428+
'maximum_length' => '300',
429+
'custom_text' => '',
430+
'custom_text_pos' => 'beginning',
431+
'include_link' => true,
432+
'url_from_meta' => false,
433+
'url_meta_key' => '',
434+
'short_url' => false,
435+
'short_url_service' => 'rviv.ly',
436+
'hashtags' => 'no-hashtags',
437+
'hashtags_length' => '200',
438+
'hashtags_common' => '',
439+
'hashtags_custom' => '',
440+
'hashtags_randomize' => false,
441+
'shortner_credentials' => array(),
442+
'image' => false,
443+
'utm_campaign_medium' => 'social',
444+
'utm_campaign_name' => 'ReviveOldPost',
445+
),
418446
);
419447

420448
/**

includes/admin/class-rop-rest-api.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1597,6 +1597,51 @@ private function add_account_mastodon( $data ) {
15971597
return $this->response->to_array();
15981598
}
15991599

1600+
/**
1601+
* API method called to add Bluesky via app.
1602+
*
1603+
* @SuppressWarnings(PHPMD.UnusedPrivateMethod) As it is called dynamically.
1604+
*
1605+
* @since 9.3.0
1606+
* @access private
1607+
*
1608+
* @param array $data Bluesky accounts data.
1609+
*
1610+
* @return array
1611+
*/
1612+
private function add_account_bluesky( $data ) {
1613+
$services = array();
1614+
$active_accounts = array();
1615+
$bs_service = new Rop_Bluesky_Service();
1616+
$model = new Rop_Services_Model();
1617+
$db = new Rop_Db_Upgrade();
1618+
1619+
$bs_service->add_account_with_app( $data );
1620+
1621+
$services[ $bs_service->get_service_id() ] = $bs_service->get_service();
1622+
$active_accounts = array_merge( $active_accounts, $bs_service->get_service_active_accounts() );
1623+
1624+
if ( ! empty( $services ) ) {
1625+
$model->add_authenticated_service( $services );
1626+
}
1627+
1628+
if ( ! empty( $active_accounts ) ) {
1629+
$db->migrate_schedule( $active_accounts );
1630+
$db->migrate_post_formats( $active_accounts );
1631+
} else {
1632+
$this->response->set_code( '500' )
1633+
->set_data( array() );
1634+
1635+
return $this->response->to_array();
1636+
}
1637+
1638+
$this->response->set_code( '200' )
1639+
->set_message( 'OK' )
1640+
->set_data( array() );
1641+
1642+
return $this->response->to_array();
1643+
}
1644+
16001645
/**
16011646
* Share API method.
16021647
*

0 commit comments

Comments
 (0)