mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2025-07-12 03:18:48 +00:00
Added a hook to check if the hook needs to be forked at all
This commit is contained in:
parent
d2460a43e5
commit
d1919f0497
9 changed files with 271 additions and 41 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue