From 8ed6469fb96fcd68fb3e7008a6d42dc6ee4337dc Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 27 Sep 2021 20:29:11 +0000 Subject: [PATCH 1/9] Issue 10772: Avoid duplicated links to Twitter --- twitter/twitter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/twitter/twitter.php b/twitter/twitter.php index 45f8fe13..66eb315a 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -680,7 +680,7 @@ function twitter_post_hook(App $a, array &$b) } // Add the link to the body if the type isn't a photo or there are more than 4 images in the post - if (!empty($msgarr['url']) && (($msgarr['type'] != 'photo') || empty($msgarr['images']) || (count($msgarr['images']) > 4))) { + if ((strpos($msg, $msgarr['url']) === false) && !empty($msgarr['url']) && (($msgarr['type'] != 'photo') || empty($msgarr['images']) || (count($msgarr['images']) > 4))) { $msg .= "\n" . $msgarr['url']; } -- 2.43.0 From eed987f9e15eaa82f19e426b8d9a7b1f41573622 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Tue, 28 Sep 2021 05:22:01 +0200 Subject: [PATCH 2/9] Update twitter/twitter.php Co-authored-by: Hypolite Petovan --- twitter/twitter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/twitter/twitter.php b/twitter/twitter.php index 66eb315a..912903e4 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -680,7 +680,7 @@ function twitter_post_hook(App $a, array &$b) } // Add the link to the body if the type isn't a photo or there are more than 4 images in the post - if ((strpos($msg, $msgarr['url']) === false) && !empty($msgarr['url']) && (($msgarr['type'] != 'photo') || empty($msgarr['images']) || (count($msgarr['images']) > 4))) { + if (!empty($msgarr['url']) && (strpos($msg, $msgarr['url']) === false) && (($msgarr['type'] != 'photo') || empty($msgarr['images']) || (count($msgarr['images']) > 4))) { $msg .= "\n" . $msgarr['url']; } -- 2.43.0 From 5199a887080221c0b0d4945eb8eb0b82f35a3637 Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Fri, 1 Oct 2021 15:53:09 +0200 Subject: [PATCH 3/9] [nitter] add note about privacy protection to the replacement message --- nitter/nitter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nitter/nitter.php b/nitter/nitter.php index 28bd9857..538de2c3 100644 --- a/nitter/nitter.php +++ b/nitter/nitter.php @@ -72,6 +72,6 @@ function nitter_render(&$a, &$o) $replaced = true; } if ($replaced) { - $o['html'] .= '

' . DI::l10n()->t('Links to Twitter in this posting were replaced by links to the Nitter instance at %s', $nitter) . '

'; + $o['html'] .= '

' . DI::l10n()->t('In an attempt to protect your privacy, links to Twitter in this posting were replaced by links to the Nitter instance at %s', $nitter) . '

'; } } -- 2.43.0 From d893ea016dad08b57f2559223aa4dc919d14687f Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Fri, 1 Oct 2021 16:10:51 +0200 Subject: [PATCH 4/9] [nitter] renew the messages.po file --- nitter/lang/C/messages.po | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/nitter/lang/C/messages.po b/nitter/lang/C/messages.po index a9e2428a..984707cc 100644 --- a/nitter/lang/C/messages.po +++ b/nitter/lang/C/messages.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-03-08 07:44+0100\n" +"POT-Creation-Date: 2021-10-01 16:10+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,7 +17,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: nitter.php:51 +#: nitter.php:52 #, php-format msgid "" "Which nitter server shall be used for the replacements in the post bodies? " @@ -25,17 +25,17 @@ msgid "" "public Nitter servers." msgstr "" -#: nitter.php:52 +#: nitter.php:53 msgid "Nitter server" msgstr "" -#: nitter.php:53 +#: nitter.php:54 msgid "Save Settings" msgstr "" -#: nitter.php:65 +#: nitter.php:99 #, php-format msgid "" -"Links to Twitter in this posting were replaced by links to the Nitter " -"instance at %s" +"In an attempt to protect your privacy, links to Twitter in this posting were " +"replaced by links to the Nitter instance at %s" msgstr "" -- 2.43.0 From 1ec669ce9a2840197122bac5a9cbdde6805eac53 Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Fri, 1 Oct 2021 17:04:33 +0200 Subject: [PATCH 5/9] [nitter] use other hook for the addon This enables the addon to also replace links in the attached preview with the Nitter server. **BUT** it requires the addon to be reloaded manually by the nodes admin. --- nitter/nitter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nitter/nitter.php b/nitter/nitter.php index 538de2c3..687ea78c 100644 --- a/nitter/nitter.php +++ b/nitter/nitter.php @@ -30,7 +30,7 @@ use Friendica\DI; function nitter_install() { - Addon::registerHook ('prepare_body', 'addon/nitter/nitter.php', 'nitter_render'); + Addon::registerHook ('prepare_body_final', 'addon/nitter/nitter.php', 'nitter_render'); } /* Handle the send data from the admin settings -- 2.43.0 From 8c5125c3f1819779687d154929fc245647f89c0d Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Fri, 1 Oct 2021 17:08:38 +0200 Subject: [PATCH 6/9] [nitter] update README, bump version number As the changed hook is a breaking change, the version of the addon is raised to 2.0. --- nitter/nitter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nitter/nitter.php b/nitter/nitter.php index 687ea78c..49808a12 100644 --- a/nitter/nitter.php +++ b/nitter/nitter.php @@ -2,7 +2,7 @@ /* * Name: nitter * Description: Replaces links to twitter.com to a nitter server in all displays of postings on a node. - * Version: 1.1 + * Version: 2.0 * Author: Tobias Diekershoff * * Copyright (c) 2020 Tobias Diekershoff -- 2.43.0 From 9e219efd46752297df4324dce80c60f27dac4863 Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Fri, 1 Oct 2021 20:07:18 +0200 Subject: [PATCH 7/9] forget to commit the updated README --- nitter/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nitter/README.md b/nitter/README.md index 8fab6304..24b10798 100644 --- a/nitter/README.md +++ b/nitter/README.md @@ -21,6 +21,9 @@ Excerp from nitters about page. Changelog --------- +* **Version 2.0** + * Changes the used hook by the addon, so that attached previews of postings get replaced as well. + This means the admins need to reload the addon * **Version 1.1** * Initial localization support with DE translation * Configurable nitter instance address from the admin panel -- 2.43.0 From 58a1cd4395cfb17704b63d1c07879aaf9b96a325 Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Fri, 1 Oct 2021 20:09:29 +0200 Subject: [PATCH 8/9] updated the DE translation of the nitter addon --- nitter/lang/de/messages.po | 39 +++++++++++++++++++++++--------------- nitter/lang/de/strings.php | 7 +++++-- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/nitter/lang/de/messages.po b/nitter/lang/de/messages.po index fb3825f5..ba95c1a2 100644 --- a/nitter/lang/de/messages.po +++ b/nitter/lang/de/messages.po @@ -1,41 +1,50 @@ # ADDON nitter -# Copyright (C) +# Copyright (C) # This file is distributed under the same license as the Friendica nitter addon package. # -# +# +# Translators: +# Tobias Diekershoff , 2021 +# #, fuzzy msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-03-08 07:44+0100\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: \n" +"POT-Creation-Date: 2021-10-01 16:10+0200\n" +"PO-Revision-Date: 2021-05-21 12:58+0000\n" +"Last-Translator: Tobias Diekershoff , 2021\n" +"Language-Team: German (https://www.transifex.com/Friendica/teams/12172/de/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +"Language: de\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" -#: nitter.php:51 +#: nitter.php:52 #, php-format msgid "" "Which nitter server shall be used for the replacements in the post bodies? " "Use the URL with servername and protocol. See %s for a list of available " "public Nitter servers." -msgstr "Welcher Nitter server soll für die Ersetzungen verwendet werden? Gib die URL mit Servername und Protokoll an. Eine Liste von öffentlichen Nitter servern findest du unter %s." +msgstr "" +"Welcher Nitter server soll für die Ersetzungen verwendet werden? Gib die URL" +" mit Servername und Protokoll an. Eine Liste von öffentlichen Nitter servern" +" findest du unter %s." -#: nitter.php:52 +#: nitter.php:53 msgid "Nitter server" msgstr "Nitter Server" -#: nitter.php:53 +#: nitter.php:54 msgid "Save Settings" msgstr "Einstellungen Speichern" -#: nitter.php:65 +#: nitter.php:99 #, php-format msgid "" -"Links to Twitter in this posting were replaced by links to the Nitter " -"instance at %s" -msgstr "In diesem Beitrag wurden Links nach twitter.com durch die Nitter Instanz auf %s ersetzt." +"In an attempt to protect your privacy, links to Twitter in this posting were" +" replaced by links to the Nitter instance at %s" +msgstr "" +"Um deine Privatsphäre zu schützen, wurden in diesem Beitrag Links nach " +"twitter.com durch die Nitter Instanz auf %s ersetzt." diff --git a/nitter/lang/de/strings.php b/nitter/lang/de/strings.php index 33a0ed2e..75ba72f9 100644 --- a/nitter/lang/de/strings.php +++ b/nitter/lang/de/strings.php @@ -1,7 +1,10 @@ strings["Which nitter server shall be used for the replacements in the post bodies? Use the URL with servername and protocol. See %s for a list of available public Nitter servers."] = "Welcher Nitter server soll für die Ersetzungen verwendet werden? Gib die URL mit Servername und Protokoll an. Eine Liste von öffentlichen Nitter servern findest du unter %s."; $a->strings["Nitter server"] = "Nitter Server"; $a->strings["Save Settings"] = "Einstellungen Speichern"; -$a->strings["Links to Twitter in this posting were replaced by links to the Nitter instance at %s"] = "In diesem Beitrag wurden Links nach twitter.com durch die Nitter Instanz auf %s ersetzt."; -- 2.43.0 From 7a1d3302d0ab87b3757dfaf56f5700960b1cdcfa Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 2 Oct 2021 11:52:24 -0400 Subject: [PATCH 9/9] [twitter] Add support for the new support_follow hook --- twitter/twitter.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/twitter/twitter.php b/twitter/twitter.php index 02470f98..f753ee97 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -104,6 +104,7 @@ function twitter_install() Hook::register('notifier_normal' , __FILE__, 'twitter_post_hook'); Hook::register('jot_networks' , __FILE__, 'twitter_jot_nets'); Hook::register('cron' , __FILE__, 'twitter_cron'); + Hook::register('support_follow' , __FILE__, 'twitter_support_follow'); Hook::register('follow' , __FILE__, 'twitter_follow'); Hook::register('unfollow' , __FILE__, 'twitter_unfollow'); Hook::register('expire' , __FILE__, 'twitter_expire'); @@ -135,6 +136,13 @@ function twitter_check_item_notification(App $a, array &$notification_data) } } +function twitter_support_follow(App $a, array &$data) +{ + if ($data['protocol'] == Protocol::TWITTER) { + $data['result'] = true; + } +} + function twitter_follow(App $a, array &$contact) { Logger::info('Check if contact is twitter contact', ['url' => $contact["url"]]); -- 2.43.0