From 1aef7ab22256f676d7991ddceffe07f85b5774e6 Mon Sep 17 00:00:00 2001 From: rowasc Date: Thu, 9 Apr 2020 23:48:01 +0000 Subject: [PATCH 01/11] fix(Twitter): urls are now formatted with the std https://twitter.com/{userid}/status/{tweetId} - This change was necessary because the old /statuses path stopped working at some point, which means all the twitter urls we grabbed from that point onwards were broken. Not super great - There doesn't seem to be any way to get the correct URL from the API response we get from /search API, which is very dissapointing because if the format changes again this will stop working. The only thing that saves us here is that because this is a more user facing url, its likely that it will be redirected even if it changes, rather than just stop working --- .../20200409232153_rewrite_twitter_urls.php | 38 +++++++++++++++++++ src/App/DataSource/Twitter/Twitter.php | 11 +++++- 2 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 migrations/20200409232153_rewrite_twitter_urls.php diff --git a/migrations/20200409232153_rewrite_twitter_urls.php b/migrations/20200409232153_rewrite_twitter_urls.php new file mode 100644 index 0000000000..2623f6bfb4 --- /dev/null +++ b/migrations/20200409232153_rewrite_twitter_urls.php @@ -0,0 +1,38 @@ +getAdapter()->getConnection(); + $update = $pdo->prepare($sql); + $update->execute(); + } +} diff --git a/src/App/DataSource/Twitter/Twitter.php b/src/App/DataSource/Twitter/Twitter.php index a75315d7db..f518d391cc 100644 --- a/src/App/DataSource/Twitter/Twitter.php +++ b/src/App/DataSource/Twitter/Twitter.php @@ -187,13 +187,20 @@ public function fetch($limit = false) ) { continue; } + $user_id = $user['id_str']; // @todo Check for similar messages in the database before saving $messages[] = [ 'type' => MessageType::TWITTER, 'contact_type' => Contact::TWITTER, - 'from' => $user['id_str'], + 'from' => $user_id, 'to' => null, - 'message' => 'https://twitter.com/statuses/' . $id, + /** + * Best compromise I could find was just make the proper urls with user_id rather than only + * tweet id (for which there is an unofficial formula)... since there doesn't seem to be a way to grab the URL from the + * API itself in the v1.1 search endpoint. + * Fun fact: if the user id is wrong, twitter still takes you to the correct Tweet... they just use the tweet id + **/ + 'message' => "https://twitter.com/$user_id/status/$id", 'title' => 'From twitter on ' . $date, 'datetime' => $date, 'data_source_message_id' => $id, From 9d56472f9e4e1c95722816d8e5e8a03131eda94b Mon Sep 17 00:00:00 2001 From: rowasc Date: Thu, 9 Apr 2020 23:52:27 +0000 Subject: [PATCH 02/11] fix(Twitter): urls are now formatted with the std https://twitter.com/{userid}/status/{tweetId} - use execute --- migrations/20200409232153_rewrite_twitter_urls.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/migrations/20200409232153_rewrite_twitter_urls.php b/migrations/20200409232153_rewrite_twitter_urls.php index 2623f6bfb4..c829dad8ee 100644 --- a/migrations/20200409232153_rewrite_twitter_urls.php +++ b/migrations/20200409232153_rewrite_twitter_urls.php @@ -31,8 +31,6 @@ public function change() INNER JOIN contacts on contacts.id = messages.contact_id SET messages.message = REPLACE(messages.message, concat('https://twitter.com/statuses/', messages.data_source_message_id), concat('https://twitter.com/', contacts.contact, '/status/', messages.data_source_message_id)) WHERE `messages`.`type` = 'twitter'"; - $pdo = $this->getAdapter()->getConnection(); - $update = $pdo->prepare($sql); - $update->execute(); + $this->execute($sql); } } From bd2280c2bd739f4758bb799ee93899d549b06b31 Mon Sep 17 00:00:00 2001 From: rowasc Date: Thu, 9 Apr 2020 23:55:17 +0000 Subject: [PATCH 03/11] fix(Twitter): urls are now formatted with the std https://twitter.com/{userid}/status/{tweetId} - use execute --- migrations/20200409232153_rewrite_twitter_urls.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/migrations/20200409232153_rewrite_twitter_urls.php b/migrations/20200409232153_rewrite_twitter_urls.php index c829dad8ee..31d699ad56 100644 --- a/migrations/20200409232153_rewrite_twitter_urls.php +++ b/migrations/20200409232153_rewrite_twitter_urls.php @@ -25,7 +25,7 @@ class RewriteTwitterUrls extends AbstractMigration * Remember to call "create()" or "update()" and NOT "save()" when working * with the Table class. */ - public function change() + public function up() { $sql = "UPDATE messages INNER JOIN contacts on contacts.id = messages.contact_id @@ -33,4 +33,12 @@ public function change() WHERE `messages`.`type` = 'twitter'"; $this->execute($sql); } + + public function down() { + $sql = "UPDATE messages + INNER JOIN contacts on contacts.id = messages.contact_id + SET messages.message = REPLACE(messages.message, concat('https://twitter.com/', contacts.contact, '/status/', messages.data_source_message_id), concat('https://twitter.com/statuses/', messages.data_source_message_id)) + WHERE `messages`.`type` = 'twitter'"; + $this->execute($sql); + } } From 12e2cedb34932ecc3a0eb643e2a055bf3c920bdc Mon Sep 17 00:00:00 2001 From: rowasc Date: Fri, 10 Apr 2020 02:23:05 +0000 Subject: [PATCH 04/11] Fix twitter test with new tweet url --- tests/unit/App/DataSource/TwitterDataSourceTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/unit/App/DataSource/TwitterDataSourceTest.php b/tests/unit/App/DataSource/TwitterDataSourceTest.php index 31cb2d908f..6c7d73121d 100644 --- a/tests/unit/App/DataSource/TwitterDataSourceTest.php +++ b/tests/unit/App/DataSource/TwitterDataSourceTest.php @@ -271,7 +271,7 @@ function ($a, $b, $c, $d) use ($mockTwitterOAuth) { 'type' => 'twitter', 'contact_type' => 'twitter', 'from' => '1112222223', // twitter user id - 'message' => 'https://twitter.com/statuses/abc123', + 'message' => 'https://twitter.com/1112222223/status/abc123', 'to' => null, 'title' => 'From twitter on Thu Apr 06 15:24:15 +0000 2017', 'data_source_message_id' => 'abc123', @@ -282,7 +282,7 @@ function ($a, $b, $c, $d) use ($mockTwitterOAuth) { 'type' => 'twitter', 'contact_type' => 'twitter', 'from' => '1112222225', // twitter user id - 'message' => 'https://twitter.com/statuses/abc125', + 'message' => 'https://twitter.com/1112222225/status/abc125', 'to' => null, 'title' => 'From twitter on Thu Apr 06 15:24:15 +0000 2017', 'data_source_message_id' => 'abc125', @@ -293,7 +293,7 @@ function ($a, $b, $c, $d) use ($mockTwitterOAuth) { 'type' => 'twitter', 'contact_type' => 'twitter', 'from' => '12344494949', //twitter user id - 'message' => 'https://twitter.com/statuses/abc126', + 'message' => 'https://twitter.com/12344494949/status/abc126', 'to' => null, 'title' => 'From twitter on Thu Apr 06 15:24:15 +0000 2017', 'data_source_message_id' => 'abc126', From de2adf21d2b12ecb1c3869852de888b92df7093c Mon Sep 17 00:00:00 2001 From: Romina Date: Thu, 16 Apr 2020 08:40:54 -0300 Subject: [PATCH 05/11] Fix style issues --- src/App/DataSource/Twitter/Twitter.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/App/DataSource/Twitter/Twitter.php b/src/App/DataSource/Twitter/Twitter.php index f518d391cc..bd44c99a88 100644 --- a/src/App/DataSource/Twitter/Twitter.php +++ b/src/App/DataSource/Twitter/Twitter.php @@ -195,10 +195,12 @@ public function fetch($limit = false) 'from' => $user_id, 'to' => null, /** - * Best compromise I could find was just make the proper urls with user_id rather than only - * tweet id (for which there is an unofficial formula)... since there doesn't seem to be a way to grab the URL from the - * API itself in the v1.1 search endpoint. - * Fun fact: if the user id is wrong, twitter still takes you to the correct Tweet... they just use the tweet id + * Best compromise I could find was just make the proper urls with user_id rather than only + * tweet id (for which there is an unofficial formula)... + * since there doesn't seem to be a way to grab the URL from the + * API itself in the v1.1 search endpoint. + * Fun fact: if the user id is wrong, twitter + * still takes you to the correct Tweet... they just use the tweet id **/ 'message' => "https://twitter.com/$user_id/status/$id", 'title' => 'From twitter on ' . $date, From 97a8399dbd51cd115fb8748607b62b9897c55086 Mon Sep 17 00:00:00 2001 From: Romina Date: Thu, 16 Apr 2020 09:00:07 -0300 Subject: [PATCH 06/11] Fix style issues --- src/App/DataSource/Twitter/Twitter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/App/DataSource/Twitter/Twitter.php b/src/App/DataSource/Twitter/Twitter.php index bd44c99a88..111ec2fe09 100644 --- a/src/App/DataSource/Twitter/Twitter.php +++ b/src/App/DataSource/Twitter/Twitter.php @@ -194,7 +194,7 @@ public function fetch($limit = false) 'contact_type' => Contact::TWITTER, 'from' => $user_id, 'to' => null, - /** + /** * Best compromise I could find was just make the proper urls with user_id rather than only * tweet id (for which there is an unofficial formula)... * since there doesn't seem to be a way to grab the URL from the From 3769936744eac4e69320ba954a43070af0a0a6b1 Mon Sep 17 00:00:00 2001 From: Romina Suarez Date: Fri, 17 Apr 2020 06:54:39 -0300 Subject: [PATCH 07/11] Fix lint --- .../20200409232153_rewrite_twitter_urls.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/migrations/20200409232153_rewrite_twitter_urls.php b/migrations/20200409232153_rewrite_twitter_urls.php index 31d699ad56..2428f32d37 100644 --- a/migrations/20200409232153_rewrite_twitter_urls.php +++ b/migrations/20200409232153_rewrite_twitter_urls.php @@ -27,18 +27,21 @@ class RewriteTwitterUrls extends AbstractMigration */ public function up() { - $sql = "UPDATE messages - INNER JOIN contacts on contacts.id = messages.contact_id - SET messages.message = REPLACE(messages.message, concat('https://twitter.com/statuses/', messages.data_source_message_id), concat('https://twitter.com/', contacts.contact, '/status/', messages.data_source_message_id)) - WHERE `messages`.`type` = 'twitter'"; + $sql = "UPDATE messages INNER JOIN contacts on contacts.id = messages.contact_id " . + "SET messages.message = " . + "REPLACE(messages.message, concat('https://twitter.com/statuses/', messages.data_source_message_id), " . + "concat('https://twitter.com/', contacts.contact, '/status/', messages.data_source_message_id)) " . + "WHERE `messages`.`type` = 'twitter'"; $this->execute($sql); } public function down() { - $sql = "UPDATE messages - INNER JOIN contacts on contacts.id = messages.contact_id - SET messages.message = REPLACE(messages.message, concat('https://twitter.com/', contacts.contact, '/status/', messages.data_source_message_id), concat('https://twitter.com/statuses/', messages.data_source_message_id)) - WHERE `messages`.`type` = 'twitter'"; + // phpcs:ignore + $sql = "UPDATE messages INNER JOIN contacts on contacts.id = messages.contact_id " . + "SET messages.message = REPLACE(messages.message, " . + "concat('https://twitter.com/', contacts.contact, '/status/', messages.data_source_message_id), " . + "concat('https://twitter.com/statuses/', messages.data_source_message_id)) " . + "WHERE `messages`.`type` = 'twitter'"; $this->execute($sql); } } From bf7598e5a10f229c1b60ee238f322de918352732 Mon Sep 17 00:00:00 2001 From: Romina Suarez Date: Fri, 17 Apr 2020 11:11:45 -0300 Subject: [PATCH 08/11] Fix lint --- migrations/20200409232153_rewrite_twitter_urls.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/migrations/20200409232153_rewrite_twitter_urls.php b/migrations/20200409232153_rewrite_twitter_urls.php index 2428f32d37..2b25731fed 100644 --- a/migrations/20200409232153_rewrite_twitter_urls.php +++ b/migrations/20200409232153_rewrite_twitter_urls.php @@ -35,7 +35,8 @@ public function up() $this->execute($sql); } - public function down() { + public function down() + { // phpcs:ignore $sql = "UPDATE messages INNER JOIN contacts on contacts.id = messages.contact_id " . "SET messages.message = REPLACE(messages.message, " . From d86a0c2afc336f3869cdc3bb0ce9ba253e0c86ff Mon Sep 17 00:00:00 2001 From: noone0212 Date: Tue, 21 Apr 2020 19:42:02 +0530 Subject: [PATCH 09/11] fix: URL replaced --- docs/api/dataproviders.apib | 2 +- resources/lang/es/data-sources.php | 4 ++-- src/App/DataSource/Twitter/Twitter.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/api/dataproviders.apib b/docs/api/dataproviders.apib index 4b686833d2..a3a1913d95 100644 --- a/docs/api/dataproviders.apib +++ b/docs/api/dataproviders.apib @@ -342,7 +342,7 @@ "intro_step1": { "label": "Step 1: Create a new Twitter application", "input": "read-only-text", - "description": "Create a new twitter application" + "description": "Create a new twitter application" }, "intro_step2": { "label": "Step 2: Generate a consumer key and secret", diff --git a/resources/lang/es/data-sources.php b/resources/lang/es/data-sources.php index 861d414b4f..258a23244d 100644 --- a/resources/lang/es/data-sources.php +++ b/resources/lang/es/data-sources.php @@ -58,8 +58,8 @@ 'Auth Token' => 'Token de Autenticación', 'SMS Auto response' => 'Respuesta automática de SMS', 'Step 1: Create a new Twitter application' => 'Paso 1: Cree una nueva aplicación de Twitter', - 'Create a new twitter application' - => 'Cree una nueva aplicación de twitter', + 'Create a new twitter application' + => 'Cree una nueva aplicación de twitter', 'Step 2: Generate a consumer key and secret' => 'Paso 2: Genere una clave de consumidor y código secreto', 'Once you\'ve created the application click on "Keys and Access Tokens".
Then click "Generate Consumer Key and Secret".
Copy keys, tokens and secrets into the fields below.' => 'Una vez que haya creado la aplicación, haga clic en "Tokens Clave y de Acceso".
Luego haga clic en "Generar clave de consumidor y código secreto".
Copie las claves, los tokens y los códigos secretos en los campos de abajo.', diff --git a/src/App/DataSource/Twitter/Twitter.php b/src/App/DataSource/Twitter/Twitter.php index 111ec2fe09..5c821e9b12 100644 --- a/src/App/DataSource/Twitter/Twitter.php +++ b/src/App/DataSource/Twitter/Twitter.php @@ -76,7 +76,7 @@ public function getOptions() 'description' => function () { return 'Twitter applications may take some time to be approved by Twitter. Please be aware of this if you need this data quickly. -

Create your +

Create your
Twitter application here.'; } ], From 40dcbec0812c5eb57ffdb5839e0f6397f2222181 Mon Sep 17 00:00:00 2001 From: Romina Date: Wed, 22 Apr 2020 02:30:20 -0300 Subject: [PATCH 10/11] Release last transifex updates --- resources/lang/cs/hxl_metadata.php | 7 +++++++ resources/lang/cs/media.php | 7 +++++++ resources/lang/cs/notifications.php | 4 ++-- resources/lang/en_GB/contacts.php | 6 ++++++ 4 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 resources/lang/cs/hxl_metadata.php create mode 100644 resources/lang/cs/media.php create mode 100644 resources/lang/en_GB/contacts.php diff --git a/resources/lang/cs/hxl_metadata.php b/resources/lang/cs/hxl_metadata.php new file mode 100644 index 0000000000..15cc16b73b --- /dev/null +++ b/resources/lang/cs/hxl_metadata.php @@ -0,0 +1,7 @@ + 'Nelze vytvořit entitu metadat pro úlohu, která ji již má', + 'privateShouldNotBeEmpty' => 'Private should be a boolean. Received: NULL' + +); diff --git a/resources/lang/cs/media.php b/resources/lang/cs/media.php new file mode 100644 index 0000000000..4ebe1121af --- /dev/null +++ b/resources/lang/cs/media.php @@ -0,0 +1,7 @@ + 'Velikost souboru by měla být menší než: param1 MB', + 'mime_type_not_allowed' => 'Typ souboru není podporován. Nahrajte prosím soubor obrázku.', + 'mime_not_empty' => 'Typ MIME nebyl nalezen. Pro soubor musí být nastaven typ MIME.' +); diff --git a/resources/lang/cs/notifications.php b/resources/lang/cs/notifications.php index f62a7cab9e..6bc9539e93 100644 --- a/resources/lang/cs/notifications.php +++ b/resources/lang/cs/notifications.php @@ -3,10 +3,10 @@ return array( 'email' => array( 'title' => '[:sitename] Nový příspěvek: :title', - 'message' => "New post on :sitename\n\n:title\n\n:content\n\nView post: :url" + 'message' => "Nový příspěvek na :sitename\n\n:title\n\n:content\n\nView post: :url" ), 'sms' => array( 'title' => '', - 'message' => 'New post on :sitename\n\n:title\n\n:content\n\nView post: :url', + 'message' => 'Nový příspěvek na :sitename\n\n:title\n\n:content\n\nView post: :url', ) ); diff --git a/resources/lang/en_GB/contacts.php b/resources/lang/en_GB/contacts.php new file mode 100644 index 0000000000..f6c6c2e412 --- /dev/null +++ b/resources/lang/en_GB/contacts.php @@ -0,0 +1,6 @@ + 'Could not create contacts. Result: %s', +); \ No newline at end of file From 6cffd7e604fe79f51576fcddb99db528bfbc39a6 Mon Sep 17 00:00:00 2001 From: Obadha2 <38259840+Obadha2@users.noreply.github.com> Date: Wed, 22 Apr 2020 12:41:43 +0300 Subject: [PATCH 11/11] =?UTF-8?q?Revert=20"fix(Twitter):=20urls=20are=20no?= =?UTF-8?q?w=20formatted=20with=20the=20std=20https://twitter.com=E2=80=A6?= =?UTF-8?q?"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20200409232153_rewrite_twitter_urls.php | 48 ------------------- src/App/DataSource/Twitter/Twitter.php | 13 +---- .../App/DataSource/TwitterDataSourceTest.php | 6 +-- 3 files changed, 5 insertions(+), 62 deletions(-) delete mode 100644 migrations/20200409232153_rewrite_twitter_urls.php diff --git a/migrations/20200409232153_rewrite_twitter_urls.php b/migrations/20200409232153_rewrite_twitter_urls.php deleted file mode 100644 index 2b25731fed..0000000000 --- a/migrations/20200409232153_rewrite_twitter_urls.php +++ /dev/null @@ -1,48 +0,0 @@ -execute($sql); - } - - public function down() - { - // phpcs:ignore - $sql = "UPDATE messages INNER JOIN contacts on contacts.id = messages.contact_id " . - "SET messages.message = REPLACE(messages.message, " . - "concat('https://twitter.com/', contacts.contact, '/status/', messages.data_source_message_id), " . - "concat('https://twitter.com/statuses/', messages.data_source_message_id)) " . - "WHERE `messages`.`type` = 'twitter'"; - $this->execute($sql); - } -} diff --git a/src/App/DataSource/Twitter/Twitter.php b/src/App/DataSource/Twitter/Twitter.php index 111ec2fe09..a75315d7db 100644 --- a/src/App/DataSource/Twitter/Twitter.php +++ b/src/App/DataSource/Twitter/Twitter.php @@ -187,22 +187,13 @@ public function fetch($limit = false) ) { continue; } - $user_id = $user['id_str']; // @todo Check for similar messages in the database before saving $messages[] = [ 'type' => MessageType::TWITTER, 'contact_type' => Contact::TWITTER, - 'from' => $user_id, + 'from' => $user['id_str'], 'to' => null, - /** - * Best compromise I could find was just make the proper urls with user_id rather than only - * tweet id (for which there is an unofficial formula)... - * since there doesn't seem to be a way to grab the URL from the - * API itself in the v1.1 search endpoint. - * Fun fact: if the user id is wrong, twitter - * still takes you to the correct Tweet... they just use the tweet id - **/ - 'message' => "https://twitter.com/$user_id/status/$id", + 'message' => 'https://twitter.com/statuses/' . $id, 'title' => 'From twitter on ' . $date, 'datetime' => $date, 'data_source_message_id' => $id, diff --git a/tests/unit/App/DataSource/TwitterDataSourceTest.php b/tests/unit/App/DataSource/TwitterDataSourceTest.php index 6c7d73121d..31cb2d908f 100644 --- a/tests/unit/App/DataSource/TwitterDataSourceTest.php +++ b/tests/unit/App/DataSource/TwitterDataSourceTest.php @@ -271,7 +271,7 @@ function ($a, $b, $c, $d) use ($mockTwitterOAuth) { 'type' => 'twitter', 'contact_type' => 'twitter', 'from' => '1112222223', // twitter user id - 'message' => 'https://twitter.com/1112222223/status/abc123', + 'message' => 'https://twitter.com/statuses/abc123', 'to' => null, 'title' => 'From twitter on Thu Apr 06 15:24:15 +0000 2017', 'data_source_message_id' => 'abc123', @@ -282,7 +282,7 @@ function ($a, $b, $c, $d) use ($mockTwitterOAuth) { 'type' => 'twitter', 'contact_type' => 'twitter', 'from' => '1112222225', // twitter user id - 'message' => 'https://twitter.com/1112222225/status/abc125', + 'message' => 'https://twitter.com/statuses/abc125', 'to' => null, 'title' => 'From twitter on Thu Apr 06 15:24:15 +0000 2017', 'data_source_message_id' => 'abc125', @@ -293,7 +293,7 @@ function ($a, $b, $c, $d) use ($mockTwitterOAuth) { 'type' => 'twitter', 'contact_type' => 'twitter', 'from' => '12344494949', //twitter user id - 'message' => 'https://twitter.com/12344494949/status/abc126', + 'message' => 'https://twitter.com/statuses/abc126', 'to' => null, 'title' => 'From twitter on Thu Apr 06 15:24:15 +0000 2017', 'data_source_message_id' => 'abc126',