From 8de6454c8cdbff0788fe6c860c69f30c3f6c437d Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 2 Oct 2021 16:48:55 -0400 Subject: [PATCH] [twitter] Add support for block and unblock hooks --- twitter/twitter.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/twitter/twitter.php b/twitter/twitter.php index 7ce988b5f..f65a63f3c 100644 --- a/twitter/twitter.php +++ b/twitter/twitter.php @@ -107,6 +107,8 @@ function twitter_install() Hook::register('support_follow' , __FILE__, 'twitter_support_follow'); Hook::register('follow' , __FILE__, 'twitter_follow'); Hook::register('unfollow' , __FILE__, 'twitter_unfollow'); + Hook::register('block' , __FILE__, 'twitter_block'); + Hook::register('unblock' , __FILE__, 'twitter_unblock'); Hook::register('expire' , __FILE__, 'twitter_expire'); Hook::register('prepare_body' , __FILE__, 'twitter_prepare_body'); Hook::register('check_item_notification', __FILE__, 'twitter_check_item_notification'); @@ -175,6 +177,16 @@ function twitter_unfollow(App $a, array &$hook_data) $hook_data['result'] = twitter_api_contact('friendship/destroy', $hook_data['contact'], $hook_data['uid']); } +function twitter_block(App $a, array &$hook_data) +{ + $hook_data['result'] = twitter_api_contact('blocks/create', $hook_data['contact'], $hook_data['uid']); +} + +function twitter_unblock(App $a, array &$hook_data) +{ + $hook_data['result'] = twitter_api_contact('blocks/destroy', $hook_data['contact'], $hook_data['uid']); +} + function twitter_api_contact(string $apiPath, array $contact, int $uid): ?bool { if ($contact['network'] !== Protocol::TWITTER) {