]> git.mxchange.org Git - friendica-addons.git/commitdiff
Added a hook to check if the hook needs to be forked at all
authorMichael <heluecht@pirati.ca>
Sat, 10 Nov 2018 16:20:19 +0000 (16:20 +0000)
committerMichael <heluecht@pirati.ca>
Sat, 10 Nov 2018 16:20:19 +0000 (16:20 +0000)
blogger/blogger.php
buffer/buffer.php
diaspora/diaspora.php
libertree/libertree.php
pumpio/pumpio.php
statusnet/statusnet.php
tumblr/tumblr.php
twitter/twitter.php
wppost/wppost.php

index 496a47c85ea9e6a91bdcf18f93a6304bcb40fbac..84594f42d0bc79305b250f253df9fdef1ba40ccd 100644 (file)
@@ -17,6 +17,7 @@ use Friendica\Util\XML;
 
 function blogger_install()
 {
+       Addon::registerHook('hook_fork',               'addon/blogger/blogger.php', 'blogger_hook_fork');
        Addon::registerHook('post_local',              'addon/blogger/blogger.php', 'blogger_post_local');
        Addon::registerHook('notifier_normal',         'addon/blogger/blogger.php', 'blogger_send');
        Addon::registerHook('jot_networks',            'addon/blogger/blogger.php', 'blogger_jot_nets');
@@ -26,6 +27,7 @@ function blogger_install()
 
 function blogger_uninstall()
 {
+       Addon::unregisterHook('hook_fork',               'addon/blogger/blogger.php', 'blogger_hook_fork');
        Addon::unregisterHook('post_local',              'addon/blogger/blogger.php', 'blogger_post_local');
        Addon::unregisterHook('notifier_normal',         'addon/blogger/blogger.php', 'blogger_send');
        Addon::unregisterHook('jot_networks',            'addon/blogger/blogger.php', 'blogger_jot_nets');
@@ -130,6 +132,21 @@ function blogger_settings_post(App $a, array &$b)
        }
 }
 
+function blogger_hook_fork(App &$a, array &$b)
+{
+       if ($b['name'] != 'notifier_normal') {
+               return;
+       }
+
+       $post = $b['data'];
+
+       if ($post['deleted'] || $post['private'] || ($post['created'] !== $post['edited']) ||
+               !strstr($post['postopts'], 'blogger') || ($post['parent'] != $post['id'])) {
+               $b['execute'] = false;
+               return;
+       }
+}
+
 function blogger_post_local(App $a, array &$b)
 {
        // This can probably be changed to allow editing by pointing to a different API endpoint
index d9378cb12c73f80347832876dacf4e2b1b3a80ae..7a62756a24c2e327ab42714a7bc1f29aacfe16d5 100644 (file)
@@ -23,6 +23,7 @@ use Friendica\Util\Strings;
 
 function buffer_install()
 {
+       Addon::registerHook('hook_fork',            'addon/buffer/buffer.php', 'buffer_hook_fork');
        Addon::registerHook('post_local',           'addon/buffer/buffer.php', 'buffer_post_local');
        Addon::registerHook('notifier_normal',      'addon/buffer/buffer.php', 'buffer_send');
        Addon::registerHook('jot_networks',         'addon/buffer/buffer.php', 'buffer_jot_nets');
@@ -32,6 +33,7 @@ function buffer_install()
 
 function buffer_uninstall()
 {
+       Addon::unregisterHook('hook_fork',               'addon/buffer/buffer.php', 'buffer_hook_fork');
        Addon::unregisterHook('post_local',              'addon/buffer/buffer.php', 'buffer_post_local');
        Addon::unregisterHook('notifier_normal',         'addon/buffer/buffer.php', 'buffer_send');
        Addon::unregisterHook('jot_networks',            'addon/buffer/buffer.php', 'buffer_jot_nets');
@@ -266,6 +268,21 @@ function buffer_post_local(App $a, array &$b)
        $b['postopts'] .= 'buffer';
 }
 
+function buffer_hook_fork(&$a, &$b)
+{
+       if ($b['name'] != 'notifier_normal') {
+               return;
+       }
+
+       $post = $b['data'];
+
+       if ($post['deleted'] || $post['private'] || ($post['created'] !== $post['edited']) ||
+               !strstr($post['postopts'], 'buffer') || ($post['parent'] != $post['id'])) {
+               $b['execute'] = false;
+               return;
+       }
+}
+
 function buffer_send(App $a, array &$b)
 {
        if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
index 037933100d1c198ae5e6136f522ff2ee2e45ac3b..66fa1b72dd876bdbc876195da44f50330f1a4fbe 100644 (file)
@@ -21,6 +21,7 @@ use Friendica\Model\Queue;
 
 function diaspora_install()
 {
+       Addon::registerHook('hook_fork',               'addon/diaspora/diaspora.php', 'diaspora_hook_fork');
        Addon::registerHook('post_local',              'addon/diaspora/diaspora.php', 'diaspora_post_local');
        Addon::registerHook('notifier_normal',         'addon/diaspora/diaspora.php', 'diaspora_send');
        Addon::registerHook('jot_networks',            'addon/diaspora/diaspora.php', 'diaspora_jot_nets');
@@ -31,6 +32,7 @@ function diaspora_install()
 
 function diaspora_uninstall()
 {
+       Addon::unregisterHook('hook_fork',               'addon/diaspora/diaspora.php', 'diaspora_hook_fork');
        Addon::unregisterHook('post_local',              'addon/diaspora/diaspora.php', 'diaspora_post_local');
        Addon::unregisterHook('notifier_normal',         'addon/diaspora/diaspora.php', 'diaspora_send');
        Addon::unregisterHook('jot_networks',            'addon/diaspora/diaspora.php', 'diaspora_jot_nets');
@@ -253,6 +255,21 @@ function diaspora_settings_post(App $a, &$b)
        }
 }
 
+function diaspora_hook_fork(&$a, &$b)
+{
+       if ($b['name'] != 'notifier_normal') {
+               return;
+       }
+
+       $post = $b['data'];
+
+       if ($post['deleted'] || $post['private'] || ($post['created'] !== $post['edited']) ||
+               !strstr($post['postopts'], 'diaspora') || ($post['parent'] != $post['id'])) {
+               $b['execute'] = false;
+               return;
+       }
+}
+
 function diaspora_post_local(App $a, array &$b)
 {
        if ($b['edit']) {
index 0804476c31025bab78ce46981c5015fcc3e4976f..a7dcce586e8a5da1fe505adc6d6cce1d075ec9a9 100644 (file)
@@ -14,22 +14,25 @@ use Friendica\Core\PConfig;
 use Friendica\Database\DBA;
 use Friendica\Util\Network;
 
-function libertree_install() {
-    Addon::registerHook('post_local',           'addon/libertree/libertree.php', 'libertree_post_local');
-    Addon::registerHook('notifier_normal',      'addon/libertree/libertree.php', 'libertree_send');
-    Addon::registerHook('jot_networks',         'addon/libertree/libertree.php', 'libertree_jot_nets');
-    Addon::registerHook('connector_settings',      'addon/libertree/libertree.php', 'libertree_settings');
-    Addon::registerHook('connector_settings_post', 'addon/libertree/libertree.php', 'libertree_settings_post');
-
-}
-function libertree_uninstall() {
-    Addon::unregisterHook('post_local',       'addon/libertree/libertree.php', 'libertree_post_local');
-    Addon::unregisterHook('notifier_normal',  'addon/libertree/libertree.php', 'libertree_send');
-    Addon::unregisterHook('jot_networks',     'addon/libertree/libertree.php', 'libertree_jot_nets');
-    Addon::unregisterHook('connector_settings',      'addon/libertree/libertree.php', 'libertree_settings');
-    Addon::unregisterHook('connector_settings_post', 'addon/libertree/libertree.php', 'libertree_settings_post');
+function libertree_install()
+{
+       Addon::registerHook('hook_fork',            'addon/libertree/libertree.php', 'libertree_hook_fork');
+       Addon::registerHook('post_local',           'addon/libertree/libertree.php', 'libertree_post_local');
+       Addon::registerHook('notifier_normal',      'addon/libertree/libertree.php', 'libertree_send');
+       Addon::registerHook('jot_networks',         'addon/libertree/libertree.php', 'libertree_jot_nets');
+       Addon::registerHook('connector_settings',      'addon/libertree/libertree.php', 'libertree_settings');
+       Addon::registerHook('connector_settings_post', 'addon/libertree/libertree.php', 'libertree_settings_post');
 }
 
+function libertree_uninstall()
+{
+       Addon::unregisterHook('hook_fork',        'addon/libertree/libertree.php', 'libertree_hook_fork');
+       Addon::unregisterHook('post_local',       'addon/libertree/libertree.php', 'libertree_post_local');
+       Addon::unregisterHook('notifier_normal',  'addon/libertree/libertree.php', 'libertree_send');
+       Addon::unregisterHook('jot_networks',     'addon/libertree/libertree.php', 'libertree_jot_nets');
+       Addon::unregisterHook('connector_settings',      'addon/libertree/libertree.php', 'libertree_settings');
+       Addon::unregisterHook('connector_settings_post', 'addon/libertree/libertree.php', 'libertree_settings_post');
+}
 
 function libertree_jot_nets(&$a,&$b) {
     if(! local_user())
@@ -118,6 +121,21 @@ function libertree_settings_post(&$a,&$b) {
 
 }
 
+function libertree_hook_fork(App &$a, array &$b)
+{
+       if ($b['name'] != 'notifier_normal') {
+               return;
+       }
+
+       $post = $b['data'];
+
+       if ($post['deleted'] || $post['private'] || ($post['created'] !== $post['edited']) ||
+               !strstr($post['postopts'], 'libertree') || ($post['parent'] != $post['id'])) {
+               $b['execute'] = false;
+               return;
+       }
+}
+
 function libertree_post_local(&$a,&$b) {
 
        // This can probably be changed to allow editing by pointing to a different API endpoint
index 71b5cf159759e9851d4a3e281eeedfbf0fcae09d..ebef1a22268164e0e0b7798a18ee33b6e5ad4636 100644 (file)
@@ -38,6 +38,7 @@ define('PUMPIO_DEFAULT_POLL_INTERVAL', 5); // given in minutes
 function pumpio_install()
 {
        Addon::registerHook('load_config',          'addon/pumpio/pumpio.php', 'pumpio_load_config');
+       Addon::registerHook('hook_fork',            'addon/pumpio/pumpio.php', 'hook_fork');
        Addon::registerHook('post_local',           'addon/pumpio/pumpio.php', 'pumpio_post_local');
        Addon::registerHook('notifier_normal',      'addon/pumpio/pumpio.php', 'pumpio_send');
        Addon::registerHook('jot_networks',         'addon/pumpio/pumpio.php', 'pumpio_jot_nets');
@@ -51,6 +52,7 @@ function pumpio_install()
 function pumpio_uninstall()
 {
        Addon::unregisterHook('load_config',      'addon/pumpio/pumpio.php', 'pumpio_load_config');
+       Addon::unregisterHook('hook_fork',        'addon/pumpio/pumpio.php', 'pumpio_hook_fork');
        Addon::unregisterHook('post_local',       'addon/pumpio/pumpio.php', 'pumpio_post_local');
        Addon::unregisterHook('notifier_normal',  'addon/pumpio/pumpio.php', 'pumpio_send');
        Addon::unregisterHook('jot_networks',     'addon/pumpio/pumpio.php', 'pumpio_jot_nets');
@@ -381,6 +383,42 @@ function pumpio_load_config(App $a)
        $a->loadConfigFile(__DIR__. '/config/pumpio.ini.php');
 }
 
+function pumpio_hook_fork(App $a, array &$b)
+{
+        if ($b['name'] != 'notifier_normal') {
+                return;
+        }
+
+        $post = $b['data'];
+
+        // Deleting and editing is not supported by the addon (deleting could, but isn't by now)
+        if ($post['deleted'] || ($post['created'] !== $post['edited'])) {
+                $b['execute'] = false;
+                return;
+        }
+
+        // if post comes from pump.io don't send it back
+       if ($post['app'] == "pump.io") {
+                $b['execute'] = false;
+                return;
+        }
+
+        if (PConfig::get($post['uid'], 'pumpio', 'import')) {
+                // Don't fork if it isn't a reply to a pump.io post
+                if (($post['parent'] != $post['id']) && !Item::exists(['id' => $post['parent'], 'network' => Protocol::PUMPIO])) {
+                        Logger::log('No pump.io parent found for item ' . $post['id']);
+                        $b['execute'] = false;
+                        return;
+                }
+        } else {
+                // Comments are never exported when we don't import the pumpio timeline
+                if (!strstr($post['postopts'], 'pumpio') || ($post['parent'] != $post['id']) || $post['private']) {
+                        $b['execute'] = false;
+                        return;
+                }
+        }
+}
+
 function pumpio_post_local(App $a, array &$b)
 {
        if (!local_user() || (local_user() != $b['uid'])) {
index 473ec18c81c75705fbb65c6b8e34a9fffc51d557..7fc6d4d35078fa4d4dae2f2df76703c5a736ed14 100644 (file)
@@ -68,6 +68,7 @@ function statusnet_install()
        Addon::registerHook('connector_settings', 'addon/statusnet/statusnet.php', 'statusnet_settings');
        Addon::registerHook('connector_settings_post', 'addon/statusnet/statusnet.php', 'statusnet_settings_post');
        Addon::registerHook('notifier_normal', 'addon/statusnet/statusnet.php', 'statusnet_post_hook');
+       Addon::registerHook('hook_fork', 'addon/statusnet/statusnet.php', 'statusnet_hook_fork');
        Addon::registerHook('post_local', 'addon/statusnet/statusnet.php', 'statusnet_post_local');
        Addon::registerHook('jot_networks', 'addon/statusnet/statusnet.php', 'statusnet_jot_nets');
        Addon::registerHook('cron', 'addon/statusnet/statusnet.php', 'statusnet_cron');
@@ -81,6 +82,7 @@ function statusnet_uninstall()
        Addon::unregisterHook('connector_settings', 'addon/statusnet/statusnet.php', 'statusnet_settings');
        Addon::unregisterHook('connector_settings_post', 'addon/statusnet/statusnet.php', 'statusnet_settings_post');
        Addon::unregisterHook('notifier_normal', 'addon/statusnet/statusnet.php', 'statusnet_post_hook');
+       Addon::unregisterHook('hook_fork', 'addon/statusnet/statusnet.php', 'statusnet_hook_fork');
        Addon::unregisterHook('post_local', 'addon/statusnet/statusnet.php', 'statusnet_post_local');
        Addon::unregisterHook('jot_networks', 'addon/statusnet/statusnet.php', 'statusnet_jot_nets');
        Addon::unregisterHook('cron', 'addon/statusnet/statusnet.php', 'statusnet_cron');
@@ -393,6 +395,47 @@ function statusnet_settings(App $a, &$s)
        $s .= '</div><div class="clear"></div>';
 }
 
+function statusnet_hook_fork(App $a, array &$b)
+{
+       if ($b['name'] != 'notifier_normal') {
+               return;
+       }
+
+       $post = $b['data'];
+
+       // Deleting and editing is not supported by the addon
+       if ($post['deleted'] || ($post['created'] !== $post['edited'])) {
+               $b['execute'] = false;
+               return;
+       }
+
+       // if post comes from GNU Social don't send it back
+       if ($post['extid'] == Protocol::STATUSNET) {
+               $b['execute'] = false;
+               return;
+       }
+
+       if ($post['app'] == 'StatusNet') {
+               $b['execute'] = false;
+               return;
+       }
+
+       if (PConfig::get($post['uid'], 'statusnet', 'import')) {
+               // Don't fork if it isn't a reply to a GNU Social post
+               if (($post['parent'] != $post['id']) && !Item::exists(['id' => $post['parent'], 'network' => Protocol::STATUSNET])) {
+                       Logger::log('No GNU Social parent found for item ' . $post['id']);
+                       $b['execute'] = false;
+                       return;
+               }
+       } else {
+               // Comments are never exported when we don't import the GNU Social timeline
+               if (!strstr($post['postopts'], 'statusnet') || ($post['parent'] != $post['id']) || $post['private']) {
+                       $b['execute'] = false;
+                       return;
+               }
+       }
+}
+
 function statusnet_post_local(App $a, &$b)
 {
        if ($b['edit']) {
index 97ac8bf49291a87b317bc267d747511f28c39a14..83bdcf6ef30dee4a547ba6d809b13d86e1759e7f 100644 (file)
@@ -22,6 +22,7 @@ use Friendica\Util\Strings;
 
 function tumblr_install()
 {
+       Addon::registerHook('hook_fork',               'addon/tumblr/tumblr.php', 'tumblr_hook_fork');
        Addon::registerHook('post_local',              'addon/tumblr/tumblr.php', 'tumblr_post_local');
        Addon::registerHook('notifier_normal',         'addon/tumblr/tumblr.php', 'tumblr_send');
        Addon::registerHook('jot_networks',            'addon/tumblr/tumblr.php', 'tumblr_jot_nets');
@@ -31,6 +32,7 @@ function tumblr_install()
 
 function tumblr_uninstall()
 {
+       Addon::unregisterHook('hook_fork',               'addon/tumblr/tumblr.php', 'tumblr_hook_fork');
        Addon::unregisterHook('post_local',              'addon/tumblr/tumblr.php', 'tumblr_post_local');
        Addon::unregisterHook('notifier_normal',         'addon/tumblr/tumblr.php', 'tumblr_send');
        Addon::unregisterHook('jot_networks',            'addon/tumblr/tumblr.php', 'tumblr_jot_nets');
@@ -299,6 +301,21 @@ function tumblr_settings_post(App $a, array &$b)
        }
 }
 
+function tumblr_hook_fork(&$a, &$b)
+{
+       if ($b['name'] != 'notifier_normal') {
+               return;
+       }
+
+       $post = $b['data'];
+
+       if ($post['deleted'] || $post['private'] || ($post['created'] !== $post['edited']) ||
+               !strstr($post['postopts'], 'tumblr') || ($post['parent'] != $post['id'])) {
+               $b['execute'] = false;
+               return;
+       }
+}
+
 function tumblr_post_local(App $a, array &$b)
 {
        // This can probably be changed to allow editing by pointing to a different API endpoint
index 07c696abfa8517731b26bddcca211d9b1c00a5ed..3e5701658b13ee60b8965ff427887d02c9d18397 100644 (file)
@@ -103,6 +103,7 @@ function twitter_install()
        Addon::registerHook('load_config'            , __FILE__, 'twitter_load_config');
        Addon::registerHook('connector_settings'     , __FILE__, 'twitter_settings');
        Addon::registerHook('connector_settings_post', __FILE__, 'twitter_settings_post');
+       Addon::registerHook('hook_fork'              , __FILE__, 'twitter_hook_fork');
        Addon::registerHook('post_local'             , __FILE__, 'twitter_post_local');
        Addon::registerHook('notifier_normal'        , __FILE__, 'twitter_post_hook');
        Addon::registerHook('jot_networks'           , __FILE__, 'twitter_jot_nets');
@@ -120,6 +121,7 @@ function twitter_uninstall()
        Addon::unregisterHook('load_config'            , __FILE__, 'twitter_load_config');
        Addon::unregisterHook('connector_settings'     , __FILE__, 'twitter_settings');
        Addon::unregisterHook('connector_settings_post', __FILE__, 'twitter_settings_post');
+       Addon::unregisterHook('hook_fork'              , __FILE__, 'twitter_hook_fork');
        Addon::unregisterHook('post_local'             , __FILE__, 'twitter_post_local');
        Addon::unregisterHook('notifier_normal'        , __FILE__, 'twitter_post_hook');
        Addon::unregisterHook('jot_networks'           , __FILE__, 'twitter_jot_nets');
@@ -390,6 +392,47 @@ function twitter_settings(App $a, &$s)
        $s .= '</div><div class="clear"></div>';
 }
 
+function twitter_hook_fork(App $a, array &$b)
+{
+       if ($b['name'] != 'notifier_normal') {
+               return;
+       }
+
+       $post = $b['data'];
+
+       // Deleting and editing is not supported by the addon (deleting could, but isn't by now)
+       if ($post['deleted'] || ($post['created'] !== $post['edited'])) {
+               $b['execute'] = false;
+               return;
+       }
+
+       // if post comes from twitter don't send it back
+       if ($post['extid'] == Protocol::TWITTER) {
+               $b['execute'] = false;
+               return;
+       }
+
+       if ($post['app'] == 'Twitter') {
+               $b['execute'] = false;
+               return;
+       }
+
+       if (PConfig::get($post['uid'], 'twitter', 'import')) {
+               // Don't fork if it isn't a reply to a twitter post
+               if (($post['parent'] != $post['id']) && !Item::exists(['id' => $post['parent'], 'network' => Protocol::TWITTER])) {
+                       Logger::log('No twitter parent found for item ' . $post['id']);
+                       $b['execute'] = false;
+                       return;
+               }
+       } else {
+               // Comments are never exported when we don't import the twitter timeline
+               if (!strstr($post['postopts'], 'twitter') || ($post['parent'] != $post['id']) || $post['private']) {
+                       $b['execute'] = false;
+                       return;
+               }
+        }
+}
+
 function twitter_post_local(App $a, array &$b)
 {
        if ($b['edit']) {
index 9e226260849242936a3e206cc6eb081bbf17e51f..2f09a258c856a7efbe1d80641fbe273f6f80e0d4 100644 (file)
@@ -17,40 +17,45 @@ use Friendica\Util\Network;
 use Friendica\Util\Strings;
 use Friendica\Util\XML;
 
-function wppost_install() {
-    Addon::registerHook('post_local',           'addon/wppost/wppost.php', 'wppost_post_local');
-    Addon::registerHook('notifier_normal',      'addon/wppost/wppost.php', 'wppost_send');
-    Addon::registerHook('jot_networks',         'addon/wppost/wppost.php', 'wppost_jot_nets');
-    Addon::registerHook('connector_settings',      'addon/wppost/wppost.php', 'wppost_settings');
-    Addon::registerHook('connector_settings_post', 'addon/wppost/wppost.php', 'wppost_settings_post');
-
+function wppost_install()
+{
+       Addon::registerHook('hook_fork',            'addon/wppost/wppost.php', 'wppost_hook_fork');
+       Addon::registerHook('post_local',           'addon/wppost/wppost.php', 'wppost_post_local');
+       Addon::registerHook('notifier_normal',      'addon/wppost/wppost.php', 'wppost_send');
+       Addon::registerHook('jot_networks',         'addon/wppost/wppost.php', 'wppost_jot_nets');
+       Addon::registerHook('connector_settings',      'addon/wppost/wppost.php', 'wppost_settings');
+       Addon::registerHook('connector_settings_post', 'addon/wppost/wppost.php', 'wppost_settings_post');
 }
-function wppost_uninstall() {
-    Addon::unregisterHook('post_local',       'addon/wppost/wppost.php', 'wppost_post_local');
-    Addon::unregisterHook('notifier_normal',  'addon/wppost/wppost.php', 'wppost_send');
-    Addon::unregisterHook('jot_networks',     'addon/wppost/wppost.php', 'wppost_jot_nets');
-    Addon::unregisterHook('connector_settings',      'addon/wppost/wppost.php', 'wppost_settings');
-    Addon::unregisterHook('connector_settings_post', 'addon/wppost/wppost.php', 'wppost_settings_post');
 
-       // obsolete - remove
-    Addon::unregisterHook('post_local_end',   'addon/wppost/wppost.php', 'wppost_send');
-    Addon::unregisterHook('addon_settings',  'addon/wppost/wppost.php', 'wppost_settings');
-    Addon::unregisterHook('addon_settings_post',  'addon/wppost/wppost.php', 'wppost_settings_post');
+function wppost_uninstall()
+{
+       Addon::unregisterHook('hook_fork',        'addon/wppost/wppost.php', 'wppost_hook_fork');
+       Addon::unregisterHook('post_local',       'addon/wppost/wppost.php', 'wppost_post_local');
+       Addon::unregisterHook('notifier_normal',  'addon/wppost/wppost.php', 'wppost_send');
+       Addon::unregisterHook('jot_networks',     'addon/wppost/wppost.php', 'wppost_jot_nets');
+       Addon::unregisterHook('connector_settings',      'addon/wppost/wppost.php', 'wppost_settings');
+       Addon::unregisterHook('connector_settings_post', 'addon/wppost/wppost.php', 'wppost_settings_post');
 
+       // obsolete - remove
+       Addon::unregisterHook('post_local_end',   'addon/wppost/wppost.php', 'wppost_send');
+       Addon::unregisterHook('addon_settings',  'addon/wppost/wppost.php', 'wppost_settings');
+       Addon::unregisterHook('addon_settings_post',  'addon/wppost/wppost.php', 'wppost_settings_post');
 }
 
 
-function wppost_jot_nets(&$a,&$b) {
-    if(! local_user())
-        return;
+function wppost_jot_nets(&$a, &$b)
+{
+       if (!local_user()) {
+               return;
+       }
 
-    $wp_post = PConfig::get(local_user(),'wppost','post');
-    if(intval($wp_post) == 1) {
-        $wp_defpost = PConfig::get(local_user(),'wppost','post_by_default');
-        $selected = ((intval($wp_defpost) == 1) ? ' checked="checked" ' : '');
-        $b .= '<div class="profile-jot-net"><input type="checkbox" name="wppost_enable" ' . $selected . ' value="1" /> '
-            . L10n::t('Post to Wordpress') . '</div>';
-    }
+       $wp_post = PConfig::get(local_user(), 'wppost', 'post');
+       if (intval($wp_post) == 1) {
+               $wp_defpost = PConfig::get(local_user(),'wppost','post_by_default');
+               $selected = ((intval($wp_defpost) == 1) ? ' checked="checked" ' : '');
+               $b .= '<div class="profile-jot-net"><input type="checkbox" name="wppost_enable" ' . $selected . ' value="1" /> '
+                       . L10n::t('Post to Wordpress') . '</div>';
+       }
 }
 
 
@@ -159,6 +164,21 @@ function wppost_settings_post(&$a,&$b) {
 
 }
 
+function wppost_hook_fork(&$a, &$b)
+{
+       if ($b['name'] != 'notifier_normal') {
+               return;
+       }
+
+       $post = $b['data'];
+
+       if ($post['deleted'] || $post['private'] || ($post['created'] !== $post['edited']) ||
+               !strstr($post['postopts'], 'wppost') || ($post['parent'] != $post['id'])) {
+               $b['execute'] = false;
+               return;
+       }
+}
+
 function wppost_post_local(&$a, &$b) {
 
        // This can probably be changed to allow editing by pointing to a different API endpoint