]> git.mxchange.org Git - friendica-addons.git/blobdiff - dwpost/dwpost.php
Merge pull request #1150 from tobiasd/20210728-zhcn
[friendica-addons.git] / dwpost / dwpost.php
index bb45dd14e46cf5ebfc1cc356c4ed0fbce94071da..56e04f783c2be41e7925a903e093d0cddf58f1b6 100644 (file)
@@ -14,8 +14,8 @@ use Friendica\Core\Hook;
 use Friendica\Core\Logger;
 use Friendica\Database\DBA;
 use Friendica\DI;
+use Friendica\Model\Post;
 use Friendica\Model\Tag;
-use Friendica\Network\HTTPRequest;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\XML;
 
@@ -28,15 +28,6 @@ function dwpost_install()
        Hook::register('connector_settings_post', 'addon/dwpost/dwpost.php', 'dwpost_settings_post');
 }
 
-function dwpost_uninstall()
-{
-       Hook::unregister('post_local',              'addon/dwpost/dwpost.php', 'dwpost_post_local');
-       Hook::unregister('notifier_normal',         'addon/dwpost/dwpost.php', 'dwpost_send');
-       Hook::unregister('jot_networks',            'addon/dwpost/dwpost.php', 'dwpost_jot_nets');
-       Hook::unregister('connector_settings',      'addon/dwpost/dwpost.php', 'dwpost_settings');
-       Hook::unregister('connector_settings_post', 'addon/dwpost/dwpost.php', 'dwpost_settings_post');
-}
-
 function dwpost_jot_nets(App $a, array &$jotnets_fields)
 {
        if (!local_user()) {
@@ -169,6 +160,8 @@ function dwpost_send(App $a, array &$b)
                return;
        }
 
+       $b['body'] = Post\Media::addAttachmentsToBody($b['uri-id'], $b['body']);
+
        /*
         * dreamwidth post in the LJ user's timezone.
         * Hopefully the person's Friendica account
@@ -190,7 +183,7 @@ function dwpost_send(App $a, array &$b)
 
        if ($dw_username && $dw_password && $dw_blog) {
                $title = $b['title'];
-               $post = BBCode::convert($b['body']);
+               $post = BBCode::convertForUriId($b['uri-id'], $b['body'], BBCode::CONNECTORS);
                $post = XML::escape($post);
                $tags = Tag::getCSVByURIId($b['uri-id'], [Tag::HASHTAG]);
 
@@ -231,7 +224,7 @@ EOT;
                Logger::log('dwpost: data: ' . $xml, Logger::DATA);
 
                if ($dw_blog !== 'test') {
-                       $x = HTTPRequest::post($dw_blog, $xml, ["Content-Type: text/xml"])->getBody();
+                       $x = DI::httpRequest()->post($dw_blog, $xml, ["Content-Type: text/xml"])->getBody();
                }
 
                Logger::log('posted to dreamwidth: ' . ($x) ? $x : '', Logger::DEBUG);