]> git.mxchange.org Git - friendica.git/commitdiff
Merge branch 'develop' of https://github.com/friendica/friendica into develop
authorRalf Thees <ralf@herrthees.de>
Tue, 23 Oct 2018 13:52:29 +0000 (15:52 +0200)
committerRalf Thees <ralf@herrthees.de>
Tue, 23 Oct 2018 13:52:29 +0000 (15:52 +0200)
14 files changed:
doc/Developers-Intro.md
mod/dfrn_poll.php
mod/toggle_mobile.php
src/App.php
src/Core/Install.php
src/Core/System.php
src/Core/Worker.php
src/Protocol/ActivityPub/Transmitter.php
src/Util/HTTPSignature.php
src/Worker/APDelivery.php
src/Worker/Delivery.php
tests/src/Core/Console/AutomaticInstallationConsoleTest.php
tests/src/Core/InstallTest.php
tests/src/Core/SystemTest.php

index 5deaf98ff0608edbb2a85b08716fd276ca6dd1c9..228d2fcf03836cccc35321c17b53257dd9919379 100644 (file)
@@ -149,7 +149,7 @@ As Friendica is using a [Twitter/GNU Social compatible API](help/api) any of the
 Furthermore there are several client projects, especially for use with Friendica.
 If you are interested in improving those clients, please contact the developers of the clients directly.
 
-* Android / LinageOS: **Friendiqa** [src](https://github.com/LubuWest/Friendiqa) developed by [Marco R](https://freunde.ma-nic.de/profile/marco)
+* Android / LinageOS: **Friendiqa** [src](https://git.friendi.ca/lubuwest/Friendiqa)/[Google Play](https://play.google.com/store/apps/details?id=org.qtproject.friendiqa) developed by [Marco R](https://freunde.ma-nic.de/profile/marco)
 * iOS: *currently no client*
 * SailfishOS: **Friendiy** [src](https://kirgroup.com/projects/fabrixxm/harbour-friendly) - developed by [Fabio](https://kirgroup.com/profile/fabrixxm/?tab=profile)
 * Windows: **Friendica Mobile** for Windows versions [before 8.1](http://windowsphone.com/s?appid=e3257730-c9cf-4935-9620-5261e3505c67) and [Windows 10](https://www.microsoft.com/store/apps/9nblggh0fhmn) - developed by [Gerhard Seeber](http://mozartweg.dyndns.org/friendica/profile/gerhard/?tab=profile)
index 4e7521b0edcc81651980bdb8cb03ad1e46a4cd63..354cf6b4caafcfb608a53eb7f4d31247c3a72b97 100644 (file)
@@ -549,14 +549,14 @@ function dfrn_poll_content(App $a)
 
                        switch ($destination_url) {
                                case 'profile':
-                                       $a->internalRedirect('profile/' . $profile . '?f=&tab=profile';
+                                       $a->internalRedirect('profile/' . $profile . '?f=&tab=profile');
                                        break;
                                case 'photos':
-                                       $a->internalRedirect('photos/' . $profile;
+                                       $a->internalRedirect('photos/' . $profile);
                                        break;
                                case 'status':
                                case '':
-                                       $a->internalRedirect('profile/' . $profile;
+                                       $a->internalRedirect('profile/' . $profile);
                                        break;
                                default:
                                        $appendix = (strstr($destination_url, '?') ? '&f=&redir=1' : '?f=&redir=1');
index ad77dd1ccd07c5dda7fc29dae321cd29b5b4416e..388c40891a80b2d64419e96daf6d775f1bd82361 100644 (file)
@@ -17,5 +17,5 @@ function toggle_mobile_init(App $a) {
                $address = '';
        }
 
-       $a->internalRedirect($address);
+       System::externalRedirect($address);
 }
index 081e7785e59e2579992ab4407de118322bd6987c..0ba82077985774e9728d03afc27d17758a7a0e67 100644 (file)
@@ -1772,7 +1772,7 @@ class App
                        }
 
                        $privateapps = Core\Config::get('config', 'private_addons', false);
-                       if (is_array($this->addons) && in_array($this->module, $this->addons) && file_exists("addon/{$this->module}/{$this->module}.php")) {
+                       if (Core\Addon::isEnabled($this->module) && file_exists("addon/{$this->module}/{$this->module}.php")) {
                                //Check if module is an app and if public access to apps is allowed or not
                                if ((!local_user()) && Core\Addon::isApp($this->module) && $privateapps) {
                                        info(Core\L10n::t("You must be logged in to use addons. "));
@@ -2000,7 +2000,7 @@ class App
        public function internalRedirect($toUrl = '', $ssl = false)
        {
                if (filter_var($toUrl, FILTER_VALIDATE_URL)) {
-                       throw new InternalServerErrorException('URL is not a relative path, please use System::externalRedirectTo');
+                       throw new InternalServerErrorException("'$toUrl is not a relative path, please use System::externalRedirectTo");
                }
 
                $redirectTo = $this->getBaseURL($ssl) . '/' . ltrim($toUrl, '/');
index daf90b9fff65de12b2620d9e2815a5c349e171dd..448f77c010b179c0f9bd5d379ef0913ab5e0082f 100644 (file)
@@ -97,6 +97,7 @@ class Install
         * - Creates `config/local.ini.php`
         * - Installs Database Structure
         *
+        * @param string        $phppath        Path to the PHP-Binary (optional, if not set e.g. 'php' or '/usr/bin/php')
         * @param string        $urlpath        Path based on the URL of Friendica (e.g. '/friendica')
         * @param string        $dbhost         Hostname/IP of the Friendica Database
         * @param string        $dbuser         Username of the Database connection credentials
@@ -106,7 +107,6 @@ class Install
         * @param string        $language       2-letter ISO 639-1 code (eg. 'en')
         * @param string        $adminmail      Mail-Adress of the administrator
         * @param string        $basepath   The basepath of Friendica
-        * @param string        $phpath         Path to the PHP-Binary (optional, if not set e.g. 'php' or '/usr/bin/php')
         *
         * @return bool|string true if the config was created, the text if something went wrong
         */
index e071866ee9bb54845ca0c1d2a2107cd11634777a..6079d9e22855d922a3072f9b06804725b5012872 100644 (file)
@@ -247,7 +247,7 @@ class System extends BaseObject
        public static function externalRedirect($url)
        {
                if (!filter_var($url, FILTER_VALIDATE_URL)) {
-                       throw new InternalServerErrorException('URL is not a fully qualified URL, please use App->internalRedirect() instead');
+                       throw new InternalServerErrorException("'$url' is not a fully qualified URL, please use App->internalRedirect() instead");
                }
 
                header("Location: $url");
index a06a11043daf16752701e5acff4a585cc2ea5208..76400d469848c4f218d3f19493f6137e94d473b7 100644 (file)
@@ -243,7 +243,9 @@ class Worker
                        self::execFunction($queue, $include, $argv, true);
 
                        $stamp = (float)microtime(true);
-                       if (DBA::update('workerqueue', ['done' => true], ['id' => $queue['id']])) {
+
+                       $condition = ["`id` = ? AND `next_try` < ?", $queue['id'], DateTimeFormat::utcNow()];
+                       if (DBA::update('workerqueue', ['done' => true], $condition)) {
                                Config::set('system', 'last_worker_execution', DateTimeFormat::utcNow());
                        }
                        self::$db_duration = (microtime(true) - $stamp);
@@ -1137,8 +1139,8 @@ class Worker
                $id = $queue['id'];
 
                if ($retrial > 14) {
-                       logger('Id ' . $id . ' had been tried 14 times, it will be deleted now.', LOGGER_DEBUG);
-                       DBA::delete('workerqueue', ['id' => $id]);
+                       logger('Id ' . $id . ' had been tried 14 times. We stop now.', LOGGER_DEBUG);
+                       return;
                }
 
                // Calculate the delay until the next trial
index a0d92a571d4dabe559a8fdd6b790b1991b42eb8c..a37d035377a5ce618aa751502010140f1f08a92e 100644 (file)
@@ -936,6 +936,8 @@ class Transmitter
         * @param integer $uid User ID
         * @param string $inbox Target inbox
         * @param integer $suggestion_id Suggestion ID
+        *
+        * @return boolean was the transmission successful?
         */
        public static function sendContactSuggestion($uid, $inbox, $suggestion_id)
        {
@@ -957,7 +959,7 @@ class Transmitter
                $signed = LDSignature::sign($data, $owner);
 
                logger('Deliver profile deletion for user ' . $uid . ' to ' . $inbox . ' via ActivityPub', LOGGER_DEBUG);
-               HTTPSignature::transmit($signed, $inbox, $uid);
+               return HTTPSignature::transmit($signed, $inbox, $uid);
        }
 
        /**
@@ -965,6 +967,8 @@ class Transmitter
         *
         * @param integer $uid User ID
         * @param string $inbox Target inbox
+        *
+        * @return boolean was the transmission successful?
         */
        public static function sendProfileDeletion($uid, $inbox)
        {
@@ -984,7 +988,7 @@ class Transmitter
                $signed = LDSignature::sign($data, $owner);
 
                logger('Deliver profile deletion for user ' . $uid . ' to ' . $inbox . ' via ActivityPub', LOGGER_DEBUG);
-               HTTPSignature::transmit($signed, $inbox, $uid);
+               return HTTPSignature::transmit($signed, $inbox, $uid);
        }
 
        /**
@@ -992,6 +996,8 @@ class Transmitter
         *
         * @param integer $uid User ID
         * @param string $inbox Target inbox
+        *
+        * @return boolean was the transmission successful?
         */
        public static function sendProfileUpdate($uid, $inbox)
        {
@@ -1011,7 +1017,7 @@ class Transmitter
                $signed = LDSignature::sign($data, $owner);
 
                logger('Deliver profile update for user ' . $uid . ' to ' . $inbox . ' via ActivityPub', LOGGER_DEBUG);
-               HTTPSignature::transmit($signed, $inbox, $uid);
+               return HTTPSignature::transmit($signed, $inbox, $uid);
        }
 
        /**
index 503cbff0ade45b0af04c35d039380f28ff267cbc..1d2e7d9f76b6a692e15c7453397c914e012c6593 100644 (file)
@@ -272,9 +272,11 @@ class HTTPSignature
        /**
         * @brief Transmit given data to a target for a user
         *
-        * @param $data
-        * @param $target
-        * @param $uid
+        * @param array $data Data that is about to be send
+        * @param string $target The URL of the inbox
+        * @param integer $uid User id of the sender
+        *
+        * @return boolean Was the transmission successful?
         */
        public static function transmit($data, $target, $uid)
        {
@@ -303,8 +305,11 @@ class HTTPSignature
                $headers[] = 'Content-Type: application/activity+json';
 
                $postResult = Network::post($target, $content, $headers);
+               $return_code = $postResult->getReturnCode();
+
+               logger('Transmit to ' . $target . ' returned ' . $return_code);
 
-               logger('Transmit to ' . $target . ' returned ' . $postResult->getReturnCode());
+               return ($return_code >= 200) && ($return_code <= 299);
        }
 
        /**
index 7b1ad760557022e3144c5d03382cabfe53ed6ada..b952249fed11a120066de84a8fd27e382520ded0 100644 (file)
@@ -7,6 +7,7 @@ namespace Friendica\Worker;
 use Friendica\BaseObject;
 use Friendica\Protocol\ActivityPub;
 use Friendica\Model\Item;
+use Friendica\Core\Worker;
 use Friendica\Util\HTTPSignature;
 
 class APDelivery extends BaseObject
@@ -23,19 +24,25 @@ class APDelivery extends BaseObject
        {
                logger('Invoked: ' . $cmd . ': ' . $item_id . ' to ' . $inbox, LOGGER_DEBUG);
 
+               $success = true;
+
                if ($cmd == Delivery::MAIL) {
                } elseif ($cmd == Delivery::SUGGESTION) {
-                       ActivityPub\Transmitter::sendContactSuggestion($uid, $inbox, $item_id);
+                       $success = ActivityPub\Transmitter::sendContactSuggestion($uid, $inbox, $item_id);
                } elseif ($cmd == Delivery::RELOCATION) {
                } elseif ($cmd == Delivery::REMOVAL) {
-                       ActivityPub\Transmitter::sendProfileDeletion($uid, $inbox);
+                       $success = ActivityPub\Transmitter::sendProfileDeletion($uid, $inbox);
                } elseif ($cmd == Delivery::PROFILEUPDATE) {
-                       ActivityPub\Transmitter::sendProfileUpdate($uid, $inbox);
+                       $success = ActivityPub\Transmitter::sendProfileUpdate($uid, $inbox);
                } else {
                        $data = ActivityPub\Transmitter::createCachedActivityFromItem($item_id);
                        if (!empty($data)) {
-                               HTTPSignature::transmit($data, $inbox, $uid);
+                               $success = HTTPSignature::transmit($data, $inbox, $uid);
                        }
                }
+
+               if (!$success) {
+                       Worker::defer();
+               }
        }
 }
index 1c353fb6327e8da4e3621e8344f7eaea51bb96d1..4feb341b372debd8f2c13ab81480cca763dbd792 100644 (file)
@@ -54,6 +54,7 @@ class Delivery extends BaseObject
                        $uid = $target_item['uid'];
                } elseif ($cmd == self::RELOCATION) {
                        $uid = $item_id;
+                       $target_item = [];
                } else {
                        $item = Item::selectFirst(['parent'], ['id' => $item_id]);
                        if (!DBA::isResult($item) || empty($item['parent'])) {
index da009a84c148878df34416d1ab359f55dab7ddeb..ce67cc9993c8540c4ea3bcbf93f8d613ac43a74a 100644 (file)
@@ -193,10 +193,10 @@ CONF;
                $this->assertConfig('database', 'database', $this->db_data);
                $this->assertConfig('config', 'admin_email', 'admin@friendica.local');
                $this->assertConfig('system', 'default_timezone', 'Europe/Berlin');
-               $this->assertConfig('system', 'language', 'de');
+               // TODO language changes back to en
+               //$this->assertConfig('system', 'language', 'de');
        }
 
-
        /**
         * @medium
         */
@@ -218,8 +218,9 @@ CONF;
                $this->assertConfig('database', 'database', '');
                $this->assertConfig('config', 'admin_email', 'admin@friendica.local');
                $this->assertConfig('system', 'default_timezone', 'Europe/Berlin');
-               $this->assertConfig('system', 'language', 'de');
                $this->assertConfig('system', 'urlpath', '/friendica');
+               // TODO language changes back to en
+               //$this->assertConfig('system', 'language', 'de');
        }
 
        /**
@@ -264,8 +265,9 @@ CONF;
                $this->assertConfig('database', 'database', $this->db_data);
                $this->assertConfig('config', 'admin_email', 'admin@friendica.local');
                $this->assertConfig('system', 'default_timezone', 'Europe/Berlin');
-               $this->assertConfig('system', 'language', 'de');
                $this->assertConfig('system', 'urlpath', '/friendica');
+               // TODO language changes back to en
+               //$this->assertConfig('system', 'language', 'de');
        }
 
        /**
index 645ac5a95750f0aaeb6d8a3a8ff2e823fe764c16..9d3672c54230c812a74c076ecabf5f78e33486ff 100644 (file)
@@ -50,6 +50,24 @@ class InstallTest extends TestCase
                };
        }
 
+       /**
+        * Replaces class_exist results with given mocks
+        *
+        * @param array $classes a list from class names and their results
+        */
+       private function setClasses($classes)
+       {
+               global $phpMock;
+               $phpMock['class_exists'] = function($class) use ($classes) {
+                       foreach ($classes as $name => $value) {
+                               if ($class == $name) {
+                                       return $value;
+                               }
+                       }
+                       return '__phpunit_continue__';
+               };
+       }
+
        /**
         * @small
         */
@@ -248,10 +266,13 @@ class InstallTest extends TestCase
                        ->shouldReceive('supportedTypes')
                        ->andReturn(['image/gif' => 'gif']);
 
+               $this->setClasses(['Imagick' => true]);
+
                $install = new Install();
 
                // even there is no supported type, Imagick should return true (because it is not required)
                $this->assertTrue($install->checkImagick());
+
                $this->assertCheckExist(1,
                        L10n::t('ImageMagick supports GIF'),
                        '',
@@ -270,6 +291,8 @@ class InstallTest extends TestCase
                        ->shouldReceive('supportedTypes')
                        ->andReturn([]);
 
+               $this->setClasses(['Imagick' => true]);
+
                $install = new Install();
 
                // even there is no supported type, Imagick should return true (because it is not required)
@@ -281,6 +304,22 @@ class InstallTest extends TestCase
                        false,
                        $install->getChecks());
        }
+
+       public function testImagickNotInstalled()
+       {
+               $this->setClasses(['Imagick' => false]);
+
+               $install = new Install();
+
+               // even there is no supported type, Imagick should return true (because it is not required)
+               $this->assertTrue($install->checkImagick());
+               $this->assertCheckExist(0,
+                       L10n::t('ImageMagick PHP extension is not installed'),
+                       '',
+                       false,
+                       false,
+                       $install->getChecks());
+       }
 }
 
 /**
@@ -301,3 +340,15 @@ function function_exists($function_name)
        }
        return call_user_func_array('\function_exists', func_get_args());
 }
+
+function class_exists($class_name)
+{
+       global $phpMock;
+       if (isset($phpMock['class_exists'])) {
+               $result = call_user_func_array($phpMock['class_exists'], func_get_args());
+               if ($result !== '__phpunit_continue__') {
+                       return $result;
+               }
+       }
+       return call_user_func_array('\class_exists', func_get_args());
+}
index b85bce44cb87df88d750c7ad386461230a47ab98..6b0781198a52ee828121771141c9f3cf4f4ac014 100644 (file)
@@ -34,4 +34,4 @@ class SystemTest extends TestCase
                $guid = System::createGUID(23, 'test');
                $this->assertGuid($guid, 23, 'test');
        }
-}
\ No newline at end of file
+}