Merge pull request #774 from annando/fork-check
Added a hook to check if the hook needs to be forked at allpull/777/head
commit
1375847d54
|
@ -17,6 +17,7 @@ use Friendica\Util\XML;
|
||||||
|
|
||||||
function blogger_install()
|
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('post_local', 'addon/blogger/blogger.php', 'blogger_post_local');
|
||||||
Addon::registerHook('notifier_normal', 'addon/blogger/blogger.php', 'blogger_send');
|
Addon::registerHook('notifier_normal', 'addon/blogger/blogger.php', 'blogger_send');
|
||||||
Addon::registerHook('jot_networks', 'addon/blogger/blogger.php', 'blogger_jot_nets');
|
Addon::registerHook('jot_networks', 'addon/blogger/blogger.php', 'blogger_jot_nets');
|
||||||
|
@ -26,6 +27,7 @@ function blogger_install()
|
||||||
|
|
||||||
function blogger_uninstall()
|
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('post_local', 'addon/blogger/blogger.php', 'blogger_post_local');
|
||||||
Addon::unregisterHook('notifier_normal', 'addon/blogger/blogger.php', 'blogger_send');
|
Addon::unregisterHook('notifier_normal', 'addon/blogger/blogger.php', 'blogger_send');
|
||||||
Addon::unregisterHook('jot_networks', 'addon/blogger/blogger.php', 'blogger_jot_nets');
|
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)
|
function blogger_post_local(App $a, array &$b)
|
||||||
{
|
{
|
||||||
// This can probably be changed to allow editing by pointing to a different API endpoint
|
// This can probably be changed to allow editing by pointing to a different API endpoint
|
||||||
|
|
|
@ -23,6 +23,7 @@ use Friendica\Util\Strings;
|
||||||
|
|
||||||
function buffer_install()
|
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('post_local', 'addon/buffer/buffer.php', 'buffer_post_local');
|
||||||
Addon::registerHook('notifier_normal', 'addon/buffer/buffer.php', 'buffer_send');
|
Addon::registerHook('notifier_normal', 'addon/buffer/buffer.php', 'buffer_send');
|
||||||
Addon::registerHook('jot_networks', 'addon/buffer/buffer.php', 'buffer_jot_nets');
|
Addon::registerHook('jot_networks', 'addon/buffer/buffer.php', 'buffer_jot_nets');
|
||||||
|
@ -32,6 +33,7 @@ function buffer_install()
|
||||||
|
|
||||||
function buffer_uninstall()
|
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('post_local', 'addon/buffer/buffer.php', 'buffer_post_local');
|
||||||
Addon::unregisterHook('notifier_normal', 'addon/buffer/buffer.php', 'buffer_send');
|
Addon::unregisterHook('notifier_normal', 'addon/buffer/buffer.php', 'buffer_send');
|
||||||
Addon::unregisterHook('jot_networks', 'addon/buffer/buffer.php', 'buffer_jot_nets');
|
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';
|
$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)
|
function buffer_send(App $a, array &$b)
|
||||||
{
|
{
|
||||||
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
|
if ($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited'])) {
|
||||||
|
|
|
@ -21,6 +21,7 @@ use Friendica\Model\Queue;
|
||||||
|
|
||||||
function diaspora_install()
|
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('post_local', 'addon/diaspora/diaspora.php', 'diaspora_post_local');
|
||||||
Addon::registerHook('notifier_normal', 'addon/diaspora/diaspora.php', 'diaspora_send');
|
Addon::registerHook('notifier_normal', 'addon/diaspora/diaspora.php', 'diaspora_send');
|
||||||
Addon::registerHook('jot_networks', 'addon/diaspora/diaspora.php', 'diaspora_jot_nets');
|
Addon::registerHook('jot_networks', 'addon/diaspora/diaspora.php', 'diaspora_jot_nets');
|
||||||
|
@ -31,6 +32,7 @@ function diaspora_install()
|
||||||
|
|
||||||
function diaspora_uninstall()
|
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('post_local', 'addon/diaspora/diaspora.php', 'diaspora_post_local');
|
||||||
Addon::unregisterHook('notifier_normal', 'addon/diaspora/diaspora.php', 'diaspora_send');
|
Addon::unregisterHook('notifier_normal', 'addon/diaspora/diaspora.php', 'diaspora_send');
|
||||||
Addon::unregisterHook('jot_networks', 'addon/diaspora/diaspora.php', 'diaspora_jot_nets');
|
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)
|
function diaspora_post_local(App $a, array &$b)
|
||||||
{
|
{
|
||||||
if ($b['edit']) {
|
if ($b['edit']) {
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
* Author: Tony Baldwin <https://free-haven.org/u/tony>
|
* Author: Tony Baldwin <https://free-haven.org/u/tony>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
use Friendica\Content\Text\BBCode;
|
use Friendica\Content\Text\BBCode;
|
||||||
use Friendica\Core\Addon;
|
use Friendica\Core\Addon;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
|
@ -14,22 +15,25 @@ use Friendica\Core\PConfig;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\Util\Network;
|
use Friendica\Util\Network;
|
||||||
|
|
||||||
function libertree_install() {
|
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('hook_fork', 'addon/libertree/libertree.php', 'libertree_hook_fork');
|
||||||
Addon::registerHook('jot_networks', 'addon/libertree/libertree.php', 'libertree_jot_nets');
|
Addon::registerHook('post_local', 'addon/libertree/libertree.php', 'libertree_post_local');
|
||||||
Addon::registerHook('connector_settings', 'addon/libertree/libertree.php', 'libertree_settings');
|
Addon::registerHook('notifier_normal', 'addon/libertree/libertree.php', 'libertree_send');
|
||||||
Addon::registerHook('connector_settings_post', 'addon/libertree/libertree.php', 'libertree_settings_post');
|
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_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) {
|
function libertree_jot_nets(&$a,&$b) {
|
||||||
if(! local_user())
|
if(! local_user())
|
||||||
|
@ -118,6 +122,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) {
|
function libertree_post_local(&$a,&$b) {
|
||||||
|
|
||||||
// This can probably be changed to allow editing by pointing to a different API endpoint
|
// This can probably be changed to allow editing by pointing to a different API endpoint
|
||||||
|
|
|
@ -38,6 +38,7 @@ define('PUMPIO_DEFAULT_POLL_INTERVAL', 5); // given in minutes
|
||||||
function pumpio_install()
|
function pumpio_install()
|
||||||
{
|
{
|
||||||
Addon::registerHook('load_config', 'addon/pumpio/pumpio.php', 'pumpio_load_config');
|
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('post_local', 'addon/pumpio/pumpio.php', 'pumpio_post_local');
|
||||||
Addon::registerHook('notifier_normal', 'addon/pumpio/pumpio.php', 'pumpio_send');
|
Addon::registerHook('notifier_normal', 'addon/pumpio/pumpio.php', 'pumpio_send');
|
||||||
Addon::registerHook('jot_networks', 'addon/pumpio/pumpio.php', 'pumpio_jot_nets');
|
Addon::registerHook('jot_networks', 'addon/pumpio/pumpio.php', 'pumpio_jot_nets');
|
||||||
|
@ -51,6 +52,7 @@ function pumpio_install()
|
||||||
function pumpio_uninstall()
|
function pumpio_uninstall()
|
||||||
{
|
{
|
||||||
Addon::unregisterHook('load_config', 'addon/pumpio/pumpio.php', 'pumpio_load_config');
|
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('post_local', 'addon/pumpio/pumpio.php', 'pumpio_post_local');
|
||||||
Addon::unregisterHook('notifier_normal', 'addon/pumpio/pumpio.php', 'pumpio_send');
|
Addon::unregisterHook('notifier_normal', 'addon/pumpio/pumpio.php', 'pumpio_send');
|
||||||
Addon::unregisterHook('jot_networks', 'addon/pumpio/pumpio.php', 'pumpio_jot_nets');
|
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');
|
$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)
|
function pumpio_post_local(App $a, array &$b)
|
||||||
{
|
{
|
||||||
if (!local_user() || (local_user() != $b['uid'])) {
|
if (!local_user() || (local_user() != $b['uid'])) {
|
||||||
|
|
|
@ -68,6 +68,7 @@ function statusnet_install()
|
||||||
Addon::registerHook('connector_settings', 'addon/statusnet/statusnet.php', 'statusnet_settings');
|
Addon::registerHook('connector_settings', 'addon/statusnet/statusnet.php', 'statusnet_settings');
|
||||||
Addon::registerHook('connector_settings_post', 'addon/statusnet/statusnet.php', 'statusnet_settings_post');
|
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('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('post_local', 'addon/statusnet/statusnet.php', 'statusnet_post_local');
|
||||||
Addon::registerHook('jot_networks', 'addon/statusnet/statusnet.php', 'statusnet_jot_nets');
|
Addon::registerHook('jot_networks', 'addon/statusnet/statusnet.php', 'statusnet_jot_nets');
|
||||||
Addon::registerHook('cron', 'addon/statusnet/statusnet.php', 'statusnet_cron');
|
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', 'addon/statusnet/statusnet.php', 'statusnet_settings');
|
||||||
Addon::unregisterHook('connector_settings_post', 'addon/statusnet/statusnet.php', 'statusnet_settings_post');
|
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('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('post_local', 'addon/statusnet/statusnet.php', 'statusnet_post_local');
|
||||||
Addon::unregisterHook('jot_networks', 'addon/statusnet/statusnet.php', 'statusnet_jot_nets');
|
Addon::unregisterHook('jot_networks', 'addon/statusnet/statusnet.php', 'statusnet_jot_nets');
|
||||||
Addon::unregisterHook('cron', 'addon/statusnet/statusnet.php', 'statusnet_cron');
|
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>';
|
$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)
|
function statusnet_post_local(App $a, &$b)
|
||||||
{
|
{
|
||||||
if ($b['edit']) {
|
if ($b['edit']) {
|
||||||
|
|
|
@ -22,6 +22,7 @@ use Friendica\Util\Strings;
|
||||||
|
|
||||||
function tumblr_install()
|
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('post_local', 'addon/tumblr/tumblr.php', 'tumblr_post_local');
|
||||||
Addon::registerHook('notifier_normal', 'addon/tumblr/tumblr.php', 'tumblr_send');
|
Addon::registerHook('notifier_normal', 'addon/tumblr/tumblr.php', 'tumblr_send');
|
||||||
Addon::registerHook('jot_networks', 'addon/tumblr/tumblr.php', 'tumblr_jot_nets');
|
Addon::registerHook('jot_networks', 'addon/tumblr/tumblr.php', 'tumblr_jot_nets');
|
||||||
|
@ -31,6 +32,7 @@ function tumblr_install()
|
||||||
|
|
||||||
function tumblr_uninstall()
|
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('post_local', 'addon/tumblr/tumblr.php', 'tumblr_post_local');
|
||||||
Addon::unregisterHook('notifier_normal', 'addon/tumblr/tumblr.php', 'tumblr_send');
|
Addon::unregisterHook('notifier_normal', 'addon/tumblr/tumblr.php', 'tumblr_send');
|
||||||
Addon::unregisterHook('jot_networks', 'addon/tumblr/tumblr.php', 'tumblr_jot_nets');
|
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)
|
function tumblr_post_local(App $a, array &$b)
|
||||||
{
|
{
|
||||||
// This can probably be changed to allow editing by pointing to a different API endpoint
|
// This can probably be changed to allow editing by pointing to a different API endpoint
|
||||||
|
|
|
@ -104,6 +104,7 @@ function twitter_install()
|
||||||
Addon::registerHook('load_config' , __FILE__, 'twitter_load_config');
|
Addon::registerHook('load_config' , __FILE__, 'twitter_load_config');
|
||||||
Addon::registerHook('connector_settings' , __FILE__, 'twitter_settings');
|
Addon::registerHook('connector_settings' , __FILE__, 'twitter_settings');
|
||||||
Addon::registerHook('connector_settings_post', __FILE__, 'twitter_settings_post');
|
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('post_local' , __FILE__, 'twitter_post_local');
|
||||||
Addon::registerHook('notifier_normal' , __FILE__, 'twitter_post_hook');
|
Addon::registerHook('notifier_normal' , __FILE__, 'twitter_post_hook');
|
||||||
Addon::registerHook('jot_networks' , __FILE__, 'twitter_jot_nets');
|
Addon::registerHook('jot_networks' , __FILE__, 'twitter_jot_nets');
|
||||||
|
@ -121,6 +122,7 @@ function twitter_uninstall()
|
||||||
Addon::unregisterHook('load_config' , __FILE__, 'twitter_load_config');
|
Addon::unregisterHook('load_config' , __FILE__, 'twitter_load_config');
|
||||||
Addon::unregisterHook('connector_settings' , __FILE__, 'twitter_settings');
|
Addon::unregisterHook('connector_settings' , __FILE__, 'twitter_settings');
|
||||||
Addon::unregisterHook('connector_settings_post', __FILE__, 'twitter_settings_post');
|
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('post_local' , __FILE__, 'twitter_post_local');
|
||||||
Addon::unregisterHook('notifier_normal' , __FILE__, 'twitter_post_hook');
|
Addon::unregisterHook('notifier_normal' , __FILE__, 'twitter_post_hook');
|
||||||
Addon::unregisterHook('jot_networks' , __FILE__, 'twitter_jot_nets');
|
Addon::unregisterHook('jot_networks' , __FILE__, 'twitter_jot_nets');
|
||||||
|
@ -391,6 +393,47 @@ function twitter_settings(App $a, &$s)
|
||||||
$s .= '</div><div class="clear"></div>';
|
$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)
|
function twitter_post_local(App $a, array &$b)
|
||||||
{
|
{
|
||||||
if ($b['edit']) {
|
if ($b['edit']) {
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
|
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Friendica\App;
|
||||||
use Friendica\Content\Text\BBCode;
|
use Friendica\Content\Text\BBCode;
|
||||||
use Friendica\Content\Text\HTML;
|
use Friendica\Content\Text\HTML;
|
||||||
use Friendica\Core\Addon;
|
use Friendica\Core\Addon;
|
||||||
|
@ -17,40 +18,45 @@ use Friendica\Util\Network;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
use Friendica\Util\XML;
|
use Friendica\Util\XML;
|
||||||
|
|
||||||
function wppost_install() {
|
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('hook_fork', 'addon/wppost/wppost.php', 'wppost_hook_fork');
|
||||||
Addon::registerHook('jot_networks', 'addon/wppost/wppost.php', 'wppost_jot_nets');
|
Addon::registerHook('post_local', 'addon/wppost/wppost.php', 'wppost_post_local');
|
||||||
Addon::registerHook('connector_settings', 'addon/wppost/wppost.php', 'wppost_settings');
|
Addon::registerHook('notifier_normal', 'addon/wppost/wppost.php', 'wppost_send');
|
||||||
Addon::registerHook('connector_settings_post', 'addon/wppost/wppost.php', 'wppost_settings_post');
|
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');
|
function wppost_uninstall()
|
||||||
Addon::unregisterHook('notifier_normal', 'addon/wppost/wppost.php', 'wppost_send');
|
{
|
||||||
Addon::unregisterHook('jot_networks', 'addon/wppost/wppost.php', 'wppost_jot_nets');
|
Addon::unregisterHook('hook_fork', 'addon/wppost/wppost.php', 'wppost_hook_fork');
|
||||||
Addon::unregisterHook('connector_settings', 'addon/wppost/wppost.php', 'wppost_settings');
|
Addon::unregisterHook('post_local', 'addon/wppost/wppost.php', 'wppost_post_local');
|
||||||
Addon::unregisterHook('connector_settings_post', 'addon/wppost/wppost.php', 'wppost_settings_post');
|
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
|
// obsolete - remove
|
||||||
Addon::unregisterHook('post_local_end', 'addon/wppost/wppost.php', 'wppost_send');
|
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', 'addon/wppost/wppost.php', 'wppost_settings');
|
||||||
Addon::unregisterHook('addon_settings_post', 'addon/wppost/wppost.php', 'wppost_settings_post');
|
Addon::unregisterHook('addon_settings_post', 'addon/wppost/wppost.php', 'wppost_settings_post');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function wppost_jot_nets(&$a,&$b) {
|
function wppost_jot_nets(&$a, &$b)
|
||||||
if(! local_user())
|
{
|
||||||
return;
|
if (!local_user()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$wp_post = PConfig::get(local_user(),'wppost','post');
|
$wp_post = PConfig::get(local_user(), 'wppost', 'post');
|
||||||
if(intval($wp_post) == 1) {
|
if (intval($wp_post) == 1) {
|
||||||
$wp_defpost = PConfig::get(local_user(),'wppost','post_by_default');
|
$wp_defpost = PConfig::get(local_user(),'wppost','post_by_default');
|
||||||
$selected = ((intval($wp_defpost) == 1) ? ' checked="checked" ' : '');
|
$selected = ((intval($wp_defpost) == 1) ? ' checked="checked" ' : '');
|
||||||
$b .= '<div class="profile-jot-net"><input type="checkbox" name="wppost_enable" ' . $selected . ' value="1" /> '
|
$b .= '<div class="profile-jot-net"><input type="checkbox" name="wppost_enable" ' . $selected . ' value="1" /> '
|
||||||
. L10n::t('Post to Wordpress') . '</div>';
|
. L10n::t('Post to Wordpress') . '</div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -159,6 +165,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) {
|
function wppost_post_local(&$a, &$b) {
|
||||||
|
|
||||||
// This can probably be changed to allow editing by pointing to a different API endpoint
|
// This can probably be changed to allow editing by pointing to a different API endpoint
|
||||||
|
|
Loading…
Reference in New Issue