]> git.mxchange.org Git - friendica.git/commitdiff
Add event for unfollow hook
authorArt4 <art4@wlabs.de>
Thu, 13 Mar 2025 13:42:54 +0000 (13:42 +0000)
committerArt4 <art4@wlabs.de>
Thu, 13 Mar 2025 13:42:54 +0000 (13:42 +0000)
src/Core/Hooks/HookEventBridge.php
src/Core/Protocol.php
src/Event/ArrayFilterEvent.php
tests/Unit/Core/Hooks/HookEventBridgeTest.php

index 2f1e51a297731e38b9ebd433b67a7ee33644aa18..6b652cf4f08d6e7a4af31fe944d6c6a6b0f6a124 100644 (file)
@@ -62,6 +62,7 @@ final class HookEventBridge
                ArrayFilterEvent::PROTOCOL_SUPPORTS_FOLLOW        => 'support_follow',
                ArrayFilterEvent::PROTOCOL_SUPPORTS_REVOKE_FOLLOW => 'support_revoke_follow',
                ArrayFilterEvent::PROTOCOL_SUPPORTS_PROBE         => 'support_probe',
+               ArrayFilterEvent::UNFOLLOW                        => 'unfollow',
                HtmlFilterEvent::HEAD                             => 'head',
                HtmlFilterEvent::FOOTER                           => 'footer',
                HtmlFilterEvent::PAGE_HEADER                      => 'page_header',
@@ -104,6 +105,7 @@ final class HookEventBridge
                        ArrayFilterEvent::PROTOCOL_SUPPORTS_FOLLOW        => 'onArrayFilterEvent',
                        ArrayFilterEvent::PROTOCOL_SUPPORTS_REVOKE_FOLLOW => 'onArrayFilterEvent',
                        ArrayFilterEvent::PROTOCOL_SUPPORTS_PROBE         => 'onArrayFilterEvent',
+                       ArrayFilterEvent::UNFOLLOW                        => 'onArrayFilterEvent',
                        HtmlFilterEvent::HEAD                             => 'onHtmlFilterEvent',
                        HtmlFilterEvent::FOOTER                           => 'onHtmlFilterEvent',
                        HtmlFilterEvent::PAGE_HEADER                      => 'onHtmlFilterEvent',
index 1e5b7e7f21acfe5524832028a3dca479202cad68..61427d10173a8cf7cb3c2d52ce082beb0a936edb 100644 (file)
@@ -183,7 +183,12 @@ class Protocol
                        'uid'     => $owner['uid'],
                        'result'  => null,
                ];
-               Hook::callAll('unfollow', $hook_data);
+
+               $eventDispatcher = DI::eventDispatcher();
+
+               $hook_data = $eventDispatcher->dispatch(
+                       new ArrayFilterEvent(ArrayFilterEvent::PROTOCOL_SUPPORTS_FOLLOW, $hook_data),
+               )->getArray();
 
                return $hook_data['result'];
        }
index d21c6f8d78ddbd5b7615e07da3bc70dfd54f557d..9664071714411faed301d0e5d260eb0090af25d1 100644 (file)
@@ -62,6 +62,8 @@ final class ArrayFilterEvent extends Event
 
        public const PROTOCOL_SUPPORTS_PROBE = 'friendica.data.protocol_supports_probe';
 
+       public const UNFOLLOW = 'friendica.data.unfollow';
+
        private array $array;
 
        public function __construct(string $name, array $array)
index cdd3e0d61b2c8a79f363283d659573a703e73cc1..93d62965c3c77c1a58dfb4b8dea31e0e4aadf48e 100644 (file)
@@ -51,6 +51,7 @@ class HookEventBridgeTest extends TestCase
                        ArrayFilterEvent::PROTOCOL_SUPPORTS_FOLLOW        => 'onArrayFilterEvent',
                        ArrayFilterEvent::PROTOCOL_SUPPORTS_REVOKE_FOLLOW => 'onArrayFilterEvent',
                        ArrayFilterEvent::PROTOCOL_SUPPORTS_PROBE         => 'onArrayFilterEvent',
+                       ArrayFilterEvent::UNFOLLOW                        => 'onArrayFilterEvent',
                        HtmlFilterEvent::HEAD                             => 'onHtmlFilterEvent',
                        HtmlFilterEvent::FOOTER                           => 'onHtmlFilterEvent',
                        HtmlFilterEvent::PAGE_HEADER                      => 'onHtmlFilterEvent',
@@ -278,6 +279,7 @@ class HookEventBridgeTest extends TestCase
                        [ArrayFilterEvent::PROTOCOL_SUPPORTS_FOLLOW, 'support_follow'],
                        [ArrayFilterEvent::PROTOCOL_SUPPORTS_REVOKE_FOLLOW, 'support_revoke_follow'],
                        [ArrayFilterEvent::PROTOCOL_SUPPORTS_PROBE, 'support_probe'],
+                       [ArrayFilterEvent::UNFOLLOW, 'unfollow'],
                ];
        }