Support for Twitter threads added
This commit is contained in:
parent
86e24c747e
commit
6f971a0f63
|
@ -8,7 +8,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: \n"
|
"Project-Id-Version: \n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2021-11-27 10:25-0500\n"
|
"POT-Creation-Date: 2022-10-02 23:56+0000\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
@ -17,23 +17,23 @@ msgstr ""
|
||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
|
||||||
#: twitter.php:213
|
#: twitter.php:216
|
||||||
msgid "Post to Twitter"
|
msgid "Post to Twitter"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: twitter.php:258
|
#: twitter.php:262
|
||||||
msgid ""
|
msgid ""
|
||||||
"You submitted an empty PIN, please Sign In with Twitter again to get a new "
|
"You submitted an empty PIN, please Sign In with Twitter again to get a new "
|
||||||
"one."
|
"one."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: twitter.php:321
|
#: twitter.php:327
|
||||||
msgid ""
|
msgid ""
|
||||||
"No consumer key pair for Twitter found. Please contact your site "
|
"No consumer key pair for Twitter found. Please contact your site "
|
||||||
"administrator."
|
"administrator."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: twitter.php:334
|
#: twitter.php:340
|
||||||
msgid ""
|
msgid ""
|
||||||
"At this Friendica instance the Twitter addon was enabled but you have not "
|
"At this Friendica instance the Twitter addon was enabled but you have not "
|
||||||
"yet connected your account to your Twitter account. To do so click the "
|
"yet connected your account to your Twitter account. To do so click the "
|
||||||
|
@ -42,26 +42,26 @@ msgid ""
|
||||||
"be posted to Twitter."
|
"be posted to Twitter."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: twitter.php:335
|
#: twitter.php:341
|
||||||
msgid "Log in with Twitter"
|
msgid "Log in with Twitter"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: twitter.php:337
|
#: twitter.php:343
|
||||||
msgid "Copy the PIN from Twitter here"
|
msgid "Copy the PIN from Twitter here"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: twitter.php:345 twitter.php:388
|
#: twitter.php:351 twitter.php:395
|
||||||
msgid "An error occured: "
|
msgid "An error occured: "
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: twitter.php:359
|
#: twitter.php:365
|
||||||
#, php-format
|
#, php-format
|
||||||
msgid ""
|
msgid ""
|
||||||
"Currently connected to: <a href=\"https://twitter.com/%1$s\" target="
|
"Currently connected to: <a href=\"https://twitter.com/%1$s\" target="
|
||||||
"\"_twitter\">%1$s</a>"
|
"\"_twitter\">%1$s</a>"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: twitter.php:365
|
#: twitter.php:371
|
||||||
msgid ""
|
msgid ""
|
||||||
"<strong>Note</strong>: Due to your privacy settings (<em>Hide your profile "
|
"<strong>Note</strong>: Due to your privacy settings (<em>Hide your profile "
|
||||||
"details from unknown viewers?</em>) the link potentially included in public "
|
"details from unknown viewers?</em>) the link potentially included in public "
|
||||||
|
@ -69,42 +69,46 @@ msgid ""
|
||||||
"the visitor that the access to your profile has been restricted."
|
"the visitor that the access to your profile has been restricted."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: twitter.php:372
|
#: twitter.php:378
|
||||||
msgid "Invalid Twitter info"
|
msgid "Invalid Twitter info"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: twitter.php:373
|
#: twitter.php:379
|
||||||
msgid "Disconnect"
|
msgid "Disconnect"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: twitter.php:378
|
#: twitter.php:384
|
||||||
msgid "Allow posting to Twitter"
|
msgid "Allow posting to Twitter"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: twitter.php:378
|
#: twitter.php:384
|
||||||
msgid ""
|
msgid ""
|
||||||
"If enabled all your <strong>public</strong> postings can be posted to the "
|
"If enabled all your <strong>public</strong> postings can be posted to the "
|
||||||
"associated Twitter account. You can choose to do so by default (here) or for "
|
"associated Twitter account. You can choose to do so by default (here) or for "
|
||||||
"every posting separately in the posting options when writing the entry."
|
"every posting separately in the posting options when writing the entry."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: twitter.php:379
|
#: twitter.php:385
|
||||||
msgid "Send public postings to Twitter by default"
|
msgid "Send public postings to Twitter by default"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: twitter.php:380
|
#: twitter.php:386
|
||||||
|
msgid "Use threads instead of truncating the content"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: twitter.php:387
|
||||||
msgid "Mirror all posts from twitter that are no replies"
|
msgid "Mirror all posts from twitter that are no replies"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: twitter.php:381
|
#: twitter.php:388
|
||||||
msgid "Import the remote timeline"
|
msgid "Import the remote timeline"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: twitter.php:382
|
#: twitter.php:389
|
||||||
msgid "Automatically create contacts"
|
msgid "Automatically create contacts"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: twitter.php:382
|
#: twitter.php:389
|
||||||
msgid ""
|
msgid ""
|
||||||
"This will automatically create a contact in Friendica as soon as you receive "
|
"This will automatically create a contact in Friendica as soon as you receive "
|
||||||
"a message from an existing contact via the Twitter network. If you do not "
|
"a message from an existing contact via the Twitter network. If you do not "
|
||||||
|
@ -112,33 +116,33 @@ msgid ""
|
||||||
"from whom you would like to see posts here."
|
"from whom you would like to see posts here."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: twitter.php:395
|
#: twitter.php:402
|
||||||
msgid "Twitter Import/Export/Mirror"
|
msgid "Twitter Import/Export/Mirror"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: twitter.php:547
|
#: twitter.php:554
|
||||||
msgid ""
|
msgid ""
|
||||||
"Please connect a Twitter account in your Social Network settings to import "
|
"Please connect a Twitter account in your Social Network settings to import "
|
||||||
"Twitter posts."
|
"Twitter posts."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: twitter.php:554
|
#: twitter.php:561
|
||||||
msgid "Twitter post not found."
|
msgid "Twitter post not found."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: twitter.php:914
|
#: twitter.php:961
|
||||||
msgid "Save Settings"
|
msgid "Save Settings"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: twitter.php:916
|
#: twitter.php:963
|
||||||
msgid "Consumer key"
|
msgid "Consumer key"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: twitter.php:917
|
#: twitter.php:964
|
||||||
msgid "Consumer secret"
|
msgid "Consumer secret"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: twitter.php:1113
|
#: twitter.php:1163
|
||||||
#, php-format
|
#, php-format
|
||||||
msgid "%s on Twitter"
|
msgid "%s on Twitter"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
<p>{{$l10n.privacy_warning nofilter}}</p>
|
<p>{{$l10n.privacy_warning nofilter}}</p>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{include file="field_checkbox.tpl" field=$default}}
|
{{include file="field_checkbox.tpl" field=$default}}
|
||||||
|
{{include file="field_checkbox.tpl" field=$thread}}
|
||||||
{{include file="field_checkbox.tpl" field=$mirror}}
|
{{include file="field_checkbox.tpl" field=$mirror}}
|
||||||
{{include file="field_checkbox.tpl" field=$import}}
|
{{include file="field_checkbox.tpl" field=$import}}
|
||||||
{{include file="field_checkbox.tpl" field=$create_user}}
|
{{include file="field_checkbox.tpl" field=$create_user}}
|
||||||
|
|
|
@ -243,6 +243,7 @@ function twitter_settings_post(App $a)
|
||||||
DI::pConfig()->delete(local_user(), 'twitter', 'post');
|
DI::pConfig()->delete(local_user(), 'twitter', 'post');
|
||||||
DI::pConfig()->delete(local_user(), 'twitter', 'post_by_default');
|
DI::pConfig()->delete(local_user(), 'twitter', 'post_by_default');
|
||||||
DI::pConfig()->delete(local_user(), 'twitter', 'lastid');
|
DI::pConfig()->delete(local_user(), 'twitter', 'lastid');
|
||||||
|
DI::pConfig()->delete(local_user(), 'twitter', 'thread');
|
||||||
DI::pConfig()->delete(local_user(), 'twitter', 'mirror_posts');
|
DI::pConfig()->delete(local_user(), 'twitter', 'mirror_posts');
|
||||||
DI::pConfig()->delete(local_user(), 'twitter', 'import');
|
DI::pConfig()->delete(local_user(), 'twitter', 'import');
|
||||||
DI::pConfig()->delete(local_user(), 'twitter', 'create_user');
|
DI::pConfig()->delete(local_user(), 'twitter', 'create_user');
|
||||||
|
@ -277,6 +278,7 @@ function twitter_settings_post(App $a)
|
||||||
// to post a tweet for every new __public__ posting to the wall
|
// to post a tweet for every new __public__ posting to the wall
|
||||||
DI::pConfig()->set(local_user(), 'twitter', 'post', intval($_POST['twitter-enable']));
|
DI::pConfig()->set(local_user(), 'twitter', 'post', intval($_POST['twitter-enable']));
|
||||||
DI::pConfig()->set(local_user(), 'twitter', 'post_by_default', intval($_POST['twitter-default']));
|
DI::pConfig()->set(local_user(), 'twitter', 'post_by_default', intval($_POST['twitter-default']));
|
||||||
|
DI::pConfig()->set(local_user(), 'twitter', 'thread', intval($_POST['twitter-thread']));
|
||||||
DI::pConfig()->set(local_user(), 'twitter', 'mirror_posts', intval($_POST['twitter-mirror']));
|
DI::pConfig()->set(local_user(), 'twitter', 'mirror_posts', intval($_POST['twitter-mirror']));
|
||||||
DI::pConfig()->set(local_user(), 'twitter', 'import', intval($_POST['twitter-import']));
|
DI::pConfig()->set(local_user(), 'twitter', 'import', intval($_POST['twitter-import']));
|
||||||
DI::pConfig()->set(local_user(), 'twitter', 'create_user', intval($_POST['twitter-create_user']));
|
DI::pConfig()->set(local_user(), 'twitter', 'create_user', intval($_POST['twitter-create_user']));
|
||||||
|
@ -310,6 +312,7 @@ function twitter_settings(App $a, array &$data)
|
||||||
|
|
||||||
$enabled = intval(DI::pConfig()->get(local_user(), 'twitter', 'post'));
|
$enabled = intval(DI::pConfig()->get(local_user(), 'twitter', 'post'));
|
||||||
$defenabled = intval(DI::pConfig()->get(local_user(), 'twitter', 'post_by_default'));
|
$defenabled = intval(DI::pConfig()->get(local_user(), 'twitter', 'post_by_default'));
|
||||||
|
$threadenabled = intval(DI::pConfig()->get(local_user(), 'twitter', 'thread'));
|
||||||
$mirrorenabled = intval(DI::pConfig()->get(local_user(), 'twitter', 'mirror_posts'));
|
$mirrorenabled = intval(DI::pConfig()->get(local_user(), 'twitter', 'mirror_posts'));
|
||||||
$importenabled = intval(DI::pConfig()->get(local_user(), 'twitter', 'import'));
|
$importenabled = intval(DI::pConfig()->get(local_user(), 'twitter', 'import'));
|
||||||
$create_userenabled = intval(DI::pConfig()->get(local_user(), 'twitter', 'create_user'));
|
$create_userenabled = intval(DI::pConfig()->get(local_user(), 'twitter', 'create_user'));
|
||||||
|
@ -380,6 +383,7 @@ function twitter_settings(App $a, array &$data)
|
||||||
'$account' => $account,
|
'$account' => $account,
|
||||||
'$enable' => ['twitter-enable', DI::l10n()->t('Allow posting to Twitter'), $enabled, DI::l10n()->t('If enabled all your <strong>public</strong> postings can be posted to the associated Twitter account. You can choose to do so by default (here) or for every posting separately in the posting options when writing the entry.')],
|
'$enable' => ['twitter-enable', DI::l10n()->t('Allow posting to Twitter'), $enabled, DI::l10n()->t('If enabled all your <strong>public</strong> postings can be posted to the associated Twitter account. You can choose to do so by default (here) or for every posting separately in the posting options when writing the entry.')],
|
||||||
'$default' => ['twitter-default', DI::l10n()->t('Send public postings to Twitter by default'), $defenabled],
|
'$default' => ['twitter-default', DI::l10n()->t('Send public postings to Twitter by default'), $defenabled],
|
||||||
|
'$thread' => ['twitter-thread', DI::l10n()->t('Use threads instead of truncating the content'), $threadenabled],
|
||||||
'$mirror' => ['twitter-mirror', DI::l10n()->t('Mirror all posts from twitter that are no replies'), $mirrorenabled],
|
'$mirror' => ['twitter-mirror', DI::l10n()->t('Mirror all posts from twitter that are no replies'), $mirrorenabled],
|
||||||
'$import' => ['twitter-import', DI::l10n()->t('Import the remote timeline'), $importenabled],
|
'$import' => ['twitter-import', DI::l10n()->t('Import the remote timeline'), $importenabled],
|
||||||
'$create_user' => ['twitter-create_user', DI::l10n()->t('Automatically create contacts'), $create_userenabled, DI::l10n()->t('This will automatically create a contact in Friendica as soon as you receive a message from an existing contact via the Twitter network. If you do not enable this, you need to manually add those Twitter contacts in Friendica from whom you would like to see posts here.')],
|
'$create_user' => ['twitter-create_user', DI::l10n()->t('Automatically create contacts'), $create_userenabled, DI::l10n()->t('This will automatically create a contact in Friendica as soon as you receive a message from an existing contact via the Twitter network. If you do not enable this, you need to manually add those Twitter contacts in Friendica from whom you would like to see posts here.')],
|
||||||
|
@ -626,7 +630,7 @@ function twitter_get_id(string $uri)
|
||||||
|
|
||||||
function twitter_post_hook(App $a, array &$b)
|
function twitter_post_hook(App $a, array &$b)
|
||||||
{
|
{
|
||||||
DI::logger()->info('twitter_post_hook', $b);
|
DI::logger()->debug('Invoke post hook', $b);
|
||||||
|
|
||||||
if ($b['deleted']) {
|
if ($b['deleted']) {
|
||||||
twitter_delete_item($b);
|
twitter_delete_item($b);
|
||||||
|
@ -809,29 +813,71 @@ function twitter_post_hook(App $a, array &$b)
|
||||||
unset($post['media_ids']);
|
unset($post['media_ids']);
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
Logger::notice('Exception when trying to send to Twitter', ['id' => $b['id'], 'message' => $e->getMessage()]);
|
Logger::warning('Exception when trying to send to Twitter', ['id' => $b['id'], 'message' => $e->getMessage()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$post['status'] = $msg;
|
if (!DI::pConfig()->get($b['uid'], 'twitter', 'thread') || empty($msgarr['parts']) || (count($msgarr['parts']) == 1)) {
|
||||||
|
Logger::debug('Post single message', ['id' => $b['id']]);
|
||||||
|
|
||||||
if ($thr_parent) {
|
$post['status'] = $msg;
|
||||||
$post['in_reply_to_status_id'] = twitter_get_id($thr_parent['uri']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = $connection->post('statuses/update', $post);
|
if ($thr_parent) {
|
||||||
Logger::info('twitter_post send', ['id' => $b['id'], 'result' => $result]);
|
$post['in_reply_to_status_id'] = twitter_get_id($thr_parent['uri']);
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($result->source)) {
|
$result = $connection->post('statuses/update', $post);
|
||||||
DI::config()->set('twitter', 'application_name', strip_tags($result->source));
|
Logger::info('twitter_post send', ['id' => $b['id'], 'result' => $result]);
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($result->errors)) {
|
if (!empty($result->source)) {
|
||||||
Logger::error('Send to Twitter failed', ['id' => $b['id'], 'error' => $result->errors]);
|
DI::config()->set('twitter', 'application_name', strip_tags($result->source));
|
||||||
Worker::defer();
|
}
|
||||||
} elseif ($thr_parent) {
|
|
||||||
Logger::notice('Post send, updating extid', ['id' => $b['id'], 'extid' => $result->id_str]);
|
if (!empty($result->errors)) {
|
||||||
Item::update(['extid' => 'twitter::' . $result->id_str], ['id' => $b['id']]);
|
Logger::error('Send to Twitter failed', ['id' => $b['id'], 'error' => $result->errors]);
|
||||||
|
Worker::defer();
|
||||||
|
} elseif ($thr_parent) {
|
||||||
|
Logger::notice('Post send, updating extid', ['id' => $b['id'], 'extid' => $result->id_str]);
|
||||||
|
Item::update(['extid' => 'twitter::' . $result->id_str], ['id' => $b['id']]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ($thr_parent) {
|
||||||
|
$in_reply_to_status_id = twitter_get_id($thr_parent['uri']);
|
||||||
|
} else {
|
||||||
|
$in_reply_to_status_id = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger::debug('Post message thread', ['id' => $b['id'], 'parts' => count($msgarr['parts'])]);
|
||||||
|
foreach ($msgarr['parts'] as $key => $part) {
|
||||||
|
$post['status'] = $part;
|
||||||
|
|
||||||
|
if ($in_reply_to_status_id) {
|
||||||
|
$post['in_reply_to_status_id'] = $in_reply_to_status_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $connection->post('statuses/update', $post);
|
||||||
|
Logger::debug('twitter_post send', ['part' => $key, 'id' => $b['id'], 'result' => $result]);
|
||||||
|
|
||||||
|
if (!empty($result->errors)) {
|
||||||
|
Logger::warning('Send to Twitter failed', ['part' => $key, 'id' => $b['id'], 'error' => $result->errors]);
|
||||||
|
Worker::defer();
|
||||||
|
break;
|
||||||
|
} elseif ($key == 0) {
|
||||||
|
Logger::debug('Updating extid', ['part' => $key, 'id' => $b['id'], 'extid' => $result->id_str]);
|
||||||
|
Item::update(['extid' => 'twitter::' . $result->id_str], ['id' => $b['id']]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($result->source)) {
|
||||||
|
$application_name = strip_tags($result->source);
|
||||||
|
}
|
||||||
|
|
||||||
|
$in_reply_to_status_id = $result->id_str;
|
||||||
|
unset($post['media_ids']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($application_name)) {
|
||||||
|
DI::config()->set('twitter', 'application_name', strip_tags($result->source));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user