Merge pull request #1282 from annando/thread
Support for Twitter threads added
This commit is contained in:
commit
046b1418f2
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: \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"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -17,23 +17,23 @@ msgstr ""
|
|||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: twitter.php:213
|
||||
#: twitter.php:216
|
||||
msgid "Post to Twitter"
|
||||
msgstr ""
|
||||
|
||||
#: twitter.php:258
|
||||
#: twitter.php:262
|
||||
msgid ""
|
||||
"You submitted an empty PIN, please Sign In with Twitter again to get a new "
|
||||
"one."
|
||||
msgstr ""
|
||||
|
||||
#: twitter.php:321
|
||||
#: twitter.php:327
|
||||
msgid ""
|
||||
"No consumer key pair for Twitter found. Please contact your site "
|
||||
"administrator."
|
||||
msgstr ""
|
||||
|
||||
#: twitter.php:334
|
||||
#: twitter.php:340
|
||||
msgid ""
|
||||
"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 "
|
||||
|
@ -42,26 +42,26 @@ msgid ""
|
|||
"be posted to Twitter."
|
||||
msgstr ""
|
||||
|
||||
#: twitter.php:335
|
||||
#: twitter.php:341
|
||||
msgid "Log in with Twitter"
|
||||
msgstr ""
|
||||
|
||||
#: twitter.php:337
|
||||
#: twitter.php:343
|
||||
msgid "Copy the PIN from Twitter here"
|
||||
msgstr ""
|
||||
|
||||
#: twitter.php:345 twitter.php:388
|
||||
#: twitter.php:351 twitter.php:395
|
||||
msgid "An error occured: "
|
||||
msgstr ""
|
||||
|
||||
#: twitter.php:359
|
||||
#: twitter.php:365
|
||||
#, php-format
|
||||
msgid ""
|
||||
"Currently connected to: <a href=\"https://twitter.com/%1$s\" target="
|
||||
"\"_twitter\">%1$s</a>"
|
||||
msgstr ""
|
||||
|
||||
#: twitter.php:365
|
||||
#: twitter.php:371
|
||||
msgid ""
|
||||
"<strong>Note</strong>: Due to your privacy settings (<em>Hide your profile "
|
||||
"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."
|
||||
msgstr ""
|
||||
|
||||
#: twitter.php:372
|
||||
#: twitter.php:378
|
||||
msgid "Invalid Twitter info"
|
||||
msgstr ""
|
||||
|
||||
#: twitter.php:373
|
||||
#: twitter.php:379
|
||||
msgid "Disconnect"
|
||||
msgstr ""
|
||||
|
||||
#: twitter.php:378
|
||||
#: twitter.php:384
|
||||
msgid "Allow posting to Twitter"
|
||||
msgstr ""
|
||||
|
||||
#: twitter.php:378
|
||||
#: twitter.php:384
|
||||
msgid ""
|
||||
"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."
|
||||
msgstr ""
|
||||
|
||||
#: twitter.php:379
|
||||
#: twitter.php:385
|
||||
msgid "Send public postings to Twitter by default"
|
||||
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"
|
||||
msgstr ""
|
||||
|
||||
#: twitter.php:381
|
||||
#: twitter.php:388
|
||||
msgid "Import the remote timeline"
|
||||
msgstr ""
|
||||
|
||||
#: twitter.php:382
|
||||
#: twitter.php:389
|
||||
msgid "Automatically create contacts"
|
||||
msgstr ""
|
||||
|
||||
#: twitter.php:382
|
||||
#: twitter.php:389
|
||||
msgid ""
|
||||
"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 "
|
||||
|
@ -112,33 +116,33 @@ msgid ""
|
|||
"from whom you would like to see posts here."
|
||||
msgstr ""
|
||||
|
||||
#: twitter.php:395
|
||||
#: twitter.php:402
|
||||
msgid "Twitter Import/Export/Mirror"
|
||||
msgstr ""
|
||||
|
||||
#: twitter.php:547
|
||||
#: twitter.php:554
|
||||
msgid ""
|
||||
"Please connect a Twitter account in your Social Network settings to import "
|
||||
"Twitter posts."
|
||||
msgstr ""
|
||||
|
||||
#: twitter.php:554
|
||||
#: twitter.php:561
|
||||
msgid "Twitter post not found."
|
||||
msgstr ""
|
||||
|
||||
#: twitter.php:914
|
||||
#: twitter.php:961
|
||||
msgid "Save Settings"
|
||||
msgstr ""
|
||||
|
||||
#: twitter.php:916
|
||||
#: twitter.php:963
|
||||
msgid "Consumer key"
|
||||
msgstr ""
|
||||
|
||||
#: twitter.php:917
|
||||
#: twitter.php:964
|
||||
msgid "Consumer secret"
|
||||
msgstr ""
|
||||
|
||||
#: twitter.php:1113
|
||||
#: twitter.php:1163
|
||||
#, php-format
|
||||
msgid "%s on Twitter"
|
||||
msgstr ""
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
<p>{{$l10n.privacy_warning nofilter}}</p>
|
||||
{{/if}}
|
||||
{{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=$import}}
|
||||
{{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_by_default');
|
||||
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', 'import');
|
||||
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
|
||||
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', 'thread', intval($_POST['twitter-thread']));
|
||||
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', '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'));
|
||||
$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'));
|
||||
$importenabled = intval(DI::pConfig()->get(local_user(), 'twitter', 'import'));
|
||||
$create_userenabled = intval(DI::pConfig()->get(local_user(), 'twitter', 'create_user'));
|
||||
|
@ -380,6 +383,7 @@ function twitter_settings(App $a, array &$data)
|
|||
'$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.')],
|
||||
'$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],
|
||||
'$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.')],
|
||||
|
@ -626,7 +630,7 @@ function twitter_get_id(string $uri)
|
|||
|
||||
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']) {
|
||||
twitter_delete_item($b);
|
||||
|
@ -809,29 +813,71 @@ function twitter_post_hook(App $a, array &$b)
|
|||
unset($post['media_ids']);
|
||||
}
|
||||
} 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['in_reply_to_status_id'] = twitter_get_id($thr_parent['uri']);
|
||||
}
|
||||
$post['status'] = $msg;
|
||||
|
||||
$result = $connection->post('statuses/update', $post);
|
||||
Logger::info('twitter_post send', ['id' => $b['id'], 'result' => $result]);
|
||||
if ($thr_parent) {
|
||||
$post['in_reply_to_status_id'] = twitter_get_id($thr_parent['uri']);
|
||||
}
|
||||
|
||||
if (!empty($result->source)) {
|
||||
DI::config()->set('twitter', 'application_name', strip_tags($result->source));
|
||||
}
|
||||
$result = $connection->post('statuses/update', $post);
|
||||
Logger::info('twitter_post send', ['id' => $b['id'], 'result' => $result]);
|
||||
|
||||
if (!empty($result->errors)) {
|
||||
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']]);
|
||||
if (!empty($result->source)) {
|
||||
DI::config()->set('twitter', 'application_name', strip_tags($result->source));
|
||||
}
|
||||
|
||||
if (!empty($result->errors)) {
|
||||
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