From d5b29b1c61951cd3a805c4edd8d589d6954c8280 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sat, 5 Nov 2022 18:15:25 -0400 Subject: [PATCH] Add follow/unfollow link to the contact actions menu --- src/Module/Contact/Profile.php | 18 ++++++++++++++++++ view/templates/contact_edit.tpl | 2 ++ view/theme/frio/templates/contact_edit.tpl | 4 +++- view/theme/vier/templates/contact_edit.tpl | 2 ++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/Module/Contact/Profile.php b/src/Module/Contact/Profile.php index ec1c6b55b..eaf9993fc 100644 --- a/src/Module/Contact/Profile.php +++ b/src/Module/Contact/Profile.php @@ -415,6 +415,24 @@ class Profile extends BaseModule $formSecurityToken = self::getFormSecurityToken('contact_action'); + if ($localRelationship->rel & Contact::SHARING) { + $contact_actions['unfollow'] = [ + 'label' => $this->t('Unfollow'), + 'url' => 'contact/unfollow?url=' . urlencode($contact['url']) . '&auto=1', + 'title' => '', + 'sel' => '', + 'id' => 'unfollow', + ]; + } else { + $contact_actions['follow'] = [ + 'label' => $this->t('Follow'), + 'url' => 'contact/follow?url=' . urlencode($contact['url']) . '&auto=1', + 'title' => '', + 'sel' => '', + 'id' => 'follow', + ]; + } + // Provide friend suggestion only for Friendica contacts if ($contact['network'] === Protocol::DFRN) { $contact_actions['suggest'] = [ diff --git a/view/templates/contact_edit.tpl b/view/templates/contact_edit.tpl index 90b163cb0..2b84657c8 100644 --- a/view/templates/contact_edit.tpl +++ b/view/templates/contact_edit.tpl @@ -15,6 +15,8 @@ {{$contact_action_button}} diff --git a/view/theme/vier/templates/contact_edit.tpl b/view/theme/vier/templates/contact_edit.tpl index 59f8b8f86..82ed71abe 100644 --- a/view/theme/vier/templates/contact_edit.tpl +++ b/view/theme/vier/templates/contact_edit.tpl @@ -16,6 +16,8 @@ {{$contact_action_button}}