1
0
Fork 0

Merge pull request #10845 from MrPetovan/bug/10844-unfollow-errors

Fix overly strict return value for terminateFriendship methods
This commit is contained in:
Michael Vogel 2021-10-07 21:06:17 +02:00 committed by GitHub
commit fcb018ebdd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 49 additions and 60 deletions

View file

@ -137,21 +137,14 @@ function unfollow_process(string $url)
// NOTREACHED // NOTREACHED
} }
$notice_message = '';
$return_path = $base_return_path . '/' . $contact['id']; $return_path = $base_return_path . '/' . $contact['id'];
try { try {
$result = Contact::terminateFriendship($owner, $contact); $result = Contact::terminateFriendship($owner, $contact);
if ($result === null) {
$notice_message = DI::l10n()->t('Unfollowing is currently not supported by this contact\'s network.');
}
if ($result === false) { if ($result === false) {
$notice_message = DI::l10n()->t('Unable to unfollow this contact, please retry in a few minutes or contact your administrator.'); $notice_message = DI::l10n()->t('Unable to unfollow this contact, please retry in a few minutes or contact your administrator.');
} } else {
if ($result === true) {
$notice_message = DI::l10n()->t('Contact was successfully unfollowed'); $notice_message = DI::l10n()->t('Contact was successfully unfollowed');
} }
} catch (Exception $e) { } catch (Exception $e) {

View file

@ -213,11 +213,11 @@ class Protocol
* *
* @param array $user User unfriending * @param array $user User unfriending
* @param array $contact Contact unfriended * @param array $contact Contact unfriended
* @return bool|null true if successful, false if not, null if no action was performed * @return bool|null true if successful, false if not, null if no remote action was performed
* @throws HTTPException\InternalServerErrorException * @throws HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function terminateFriendship(array $user, array $contact): bool public static function terminateFriendship(array $user, array $contact): ?bool
{ {
if (empty($contact['network'])) { if (empty($contact['network'])) {
throw new \InvalidArgumentException('Missing network key in contact array'); throw new \InvalidArgumentException('Missing network key in contact array');

View file

@ -832,11 +832,11 @@ class Contact
* @param array $user User unfriending * @param array $user User unfriending
* @param array $contact Contact (uid != 0) unfriended * @param array $contact Contact (uid != 0) unfriended
* @param boolean $two_way Revoke eventual inbound follow as well * @param boolean $two_way Revoke eventual inbound follow as well
* @return bool|null true if successful, false if not, null if no action was performed * @return bool|null true if successful, false if not, null if no remote action was performed
* @throws HTTPException\InternalServerErrorException * @throws HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function terminateFriendship(array $user, array $contact): bool public static function terminateFriendship(array $user, array $contact): ?bool
{ {
$result = Protocol::terminateFriendship($user, $contact); $result = Protocol::terminateFriendship($user, $contact);

View file

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: 2021.12-dev\n" "Project-Id-Version: 2021.12-dev\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-10-04 06:26+0000\n" "POT-Creation-Date: 2021-10-07 11:32-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -442,7 +442,7 @@ msgid "Edit post"
msgstr "" msgstr ""
#: mod/editpost.php:91 mod/notes.php:56 src/Content/Text/HTML.php:885 #: mod/editpost.php:91 mod/notes.php:56 src/Content/Text/HTML.php:885
#: src/Module/Admin/Storage.php:135 src/Module/Filer/SaveTag.php:69 #: src/Module/Admin/Storage.php:143 src/Module/Filer/SaveTag.php:69
msgid "Save" msgid "Save"
msgstr "" msgstr ""
@ -2284,21 +2284,17 @@ msgstr ""
msgid "Disconnect/Unfollow" msgid "Disconnect/Unfollow"
msgstr "" msgstr ""
#: mod/unfollow.php:147 #: mod/unfollow.php:146
msgid "Unfollowing is currently not supported by this contact's network."
msgstr ""
#: mod/unfollow.php:151
msgid "" msgid ""
"Unable to unfollow this contact, please retry in a few minutes or contact " "Unable to unfollow this contact, please retry in a few minutes or contact "
"your administrator." "your administrator."
msgstr "" msgstr ""
#: mod/unfollow.php:155 #: mod/unfollow.php:148
msgid "Contact was successfully unfollowed" msgid "Contact was successfully unfollowed"
msgstr "" msgstr ""
#: mod/unfollow.php:159 #: mod/unfollow.php:152
msgid "Unable to unfollow this contact, please contact your administrator" msgid "Unable to unfollow this contact, please contact your administrator"
msgstr "" msgstr ""
@ -4324,63 +4320,63 @@ msgstr ""
msgid "Forum" msgid "Forum"
msgstr "" msgstr ""
#: src/Model/Contact.php:2370 #: src/Model/Contact.php:2366
msgid "Disallowed profile URL." msgid "Disallowed profile URL."
msgstr "" msgstr ""
#: src/Model/Contact.php:2375 src/Module/Friendica.php:81 #: src/Model/Contact.php:2371 src/Module/Friendica.php:81
msgid "Blocked domain" msgid "Blocked domain"
msgstr "" msgstr ""
#: src/Model/Contact.php:2380 #: src/Model/Contact.php:2376
msgid "Connect URL missing." msgid "Connect URL missing."
msgstr "" msgstr ""
#: src/Model/Contact.php:2389 #: src/Model/Contact.php:2385
msgid "" msgid ""
"The contact could not be added. Please check the relevant network " "The contact could not be added. Please check the relevant network "
"credentials in your Settings -> Social Networks page." "credentials in your Settings -> Social Networks page."
msgstr "" msgstr ""
#: src/Model/Contact.php:2426 #: src/Model/Contact.php:2422
msgid "The profile address specified does not provide adequate information." msgid "The profile address specified does not provide adequate information."
msgstr "" msgstr ""
#: src/Model/Contact.php:2428 #: src/Model/Contact.php:2424
msgid "No compatible communication protocols or feeds were discovered." msgid "No compatible communication protocols or feeds were discovered."
msgstr "" msgstr ""
#: src/Model/Contact.php:2431 #: src/Model/Contact.php:2427
msgid "An author or name was not found." msgid "An author or name was not found."
msgstr "" msgstr ""
#: src/Model/Contact.php:2434 #: src/Model/Contact.php:2430
msgid "No browser URL could be matched to this address." msgid "No browser URL could be matched to this address."
msgstr "" msgstr ""
#: src/Model/Contact.php:2437 #: src/Model/Contact.php:2433
msgid "" msgid ""
"Unable to match @-style Identity Address with a known protocol or email " "Unable to match @-style Identity Address with a known protocol or email "
"contact." "contact."
msgstr "" msgstr ""
#: src/Model/Contact.php:2438 #: src/Model/Contact.php:2434
msgid "Use mailto: in front of address to force email check." msgid "Use mailto: in front of address to force email check."
msgstr "" msgstr ""
#: src/Model/Contact.php:2444 #: src/Model/Contact.php:2440
msgid "" msgid ""
"The profile address specified belongs to a network which has been disabled " "The profile address specified belongs to a network which has been disabled "
"on this site." "on this site."
msgstr "" msgstr ""
#: src/Model/Contact.php:2449 #: src/Model/Contact.php:2445
msgid "" msgid ""
"Limited profile. This person will be unable to receive direct/personal " "Limited profile. This person will be unable to receive direct/personal "
"notifications from you." "notifications from you."
msgstr "" msgstr ""
#: src/Model/Contact.php:2508 #: src/Model/Contact.php:2504
msgid "Unable to retrieve contact information." msgid "Unable to retrieve contact information."
msgstr "" msgstr ""
@ -4591,17 +4587,17 @@ msgstr ""
msgid "OpenWebAuth: %1$s welcomes %2$s" msgid "OpenWebAuth: %1$s welcomes %2$s"
msgstr "" msgstr ""
#: src/Model/Storage/Filesystem.php:187 #: src/Model/Storage/FilesystemConfig.php:77
msgid "Storage base path" msgid "Storage base path"
msgstr "" msgstr ""
#: src/Model/Storage/Filesystem.php:189 #: src/Model/Storage/FilesystemConfig.php:79
msgid "" msgid ""
"Folder where uploaded files are saved. For maximum security, This should be " "Folder where uploaded files are saved. For maximum security, This should be "
"a path outside web server folder tree" "a path outside web server folder tree"
msgstr "" msgstr ""
#: src/Model/Storage/Filesystem.php:202 #: src/Model/Storage/FilesystemConfig.php:92
msgid "Enter a valid existing folder" msgid "Enter a valid existing folder"
msgstr "" msgstr ""
@ -4884,7 +4880,7 @@ msgstr ""
#: src/Module/Admin/Blocklist/Server.php:88 src/Module/Admin/Federation.php:159 #: src/Module/Admin/Blocklist/Server.php:88 src/Module/Admin/Federation.php:159
#: src/Module/Admin/Item/Delete.php:65 src/Module/Admin/Logs/Settings.php:80 #: src/Module/Admin/Item/Delete.php:65 src/Module/Admin/Logs/Settings.php:80
#: src/Module/Admin/Logs/View.php:83 src/Module/Admin/Queue.php:72 #: src/Module/Admin/Logs/View.php:83 src/Module/Admin/Queue.php:72
#: src/Module/Admin/Site.php:497 src/Module/Admin/Storage.php:131 #: src/Module/Admin/Site.php:497 src/Module/Admin/Storage.php:139
#: src/Module/Admin/Summary.php:233 src/Module/Admin/Themes/Details.php:90 #: src/Module/Admin/Summary.php:233 src/Module/Admin/Themes/Details.php:90
#: src/Module/Admin/Themes/Index.php:111 src/Module/Admin/Tos.php:58 #: src/Module/Admin/Themes/Index.php:111 src/Module/Admin/Tos.php:58
#: src/Module/Admin/Users/Active.php:136 src/Module/Admin/Users/Blocked.php:137 #: src/Module/Admin/Users/Active.php:136 src/Module/Admin/Users/Blocked.php:137
@ -6403,49 +6399,49 @@ msgstr ""
msgid "Start Relocation" msgid "Start Relocation"
msgstr "" msgstr ""
#: src/Module/Admin/Storage.php:45 #: src/Module/Admin/Storage.php:46
#, php-format #, php-format
msgid "Storage backend, %s is invalid." msgid "Storage backend, %s is invalid."
msgstr "" msgstr ""
#: src/Module/Admin/Storage.php:71 #: src/Module/Admin/Storage.php:73
#, php-format #, php-format
msgid "Storage backend %s error: %s" msgid "Storage backend %s error: %s"
msgstr "" msgstr ""
#: src/Module/Admin/Storage.php:82 src/Module/Admin/Storage.php:85 #: src/Module/Admin/Storage.php:85 src/Module/Admin/Storage.php:88
msgid "Invalid storage backend setting value." msgid "Invalid storage backend setting value."
msgstr "" msgstr ""
#: src/Module/Admin/Storage.php:132 #: src/Module/Admin/Storage.php:140
msgid "Current Storage Backend" msgid "Current Storage Backend"
msgstr "" msgstr ""
#: src/Module/Admin/Storage.php:133 #: src/Module/Admin/Storage.php:141
msgid "Storage Configuration" msgid "Storage Configuration"
msgstr "" msgstr ""
#: src/Module/Admin/Storage.php:134 src/Module/BaseAdmin.php:91 #: src/Module/Admin/Storage.php:142 src/Module/BaseAdmin.php:91
msgid "Storage" msgid "Storage"
msgstr "" msgstr ""
#: src/Module/Admin/Storage.php:136 #: src/Module/Admin/Storage.php:144
msgid "Save & Use storage backend" msgid "Save & Use storage backend"
msgstr "" msgstr ""
#: src/Module/Admin/Storage.php:137 #: src/Module/Admin/Storage.php:145
msgid "Use storage backend" msgid "Use storage backend"
msgstr "" msgstr ""
#: src/Module/Admin/Storage.php:138 #: src/Module/Admin/Storage.php:146
msgid "Save & Reload" msgid "Save & Reload"
msgstr "" msgstr ""
#: src/Module/Admin/Storage.php:139 #: src/Module/Admin/Storage.php:147
msgid "This backend doesn't have custom settings" msgid "This backend doesn't have custom settings"
msgstr "" msgstr ""
#: src/Module/Admin/Storage.php:142 #: src/Module/Admin/Storage.php:150
msgid "Database (legacy)" msgid "Database (legacy)"
msgstr "" msgstr ""
@ -8666,21 +8662,21 @@ msgstr ""
msgid "Visible to:" msgid "Visible to:"
msgstr "" msgstr ""
#: src/Module/Photo.php:117 #: src/Module/Photo.php:122
msgid "The Photo is not available." msgid "The Photo is not available."
msgstr "" msgstr ""
#: src/Module/Photo.php:130 #: src/Module/Photo.php:135
#, php-format #, php-format
msgid "The Photo with id %s is not available." msgid "The Photo with id %s is not available."
msgstr "" msgstr ""
#: src/Module/Photo.php:163 #: src/Module/Photo.php:168
#, php-format #, php-format
msgid "Invalid external resource with url %s." msgid "Invalid external resource with url %s."
msgstr "" msgstr ""
#: src/Module/Photo.php:165 #: src/Module/Photo.php:170
#, php-format #, php-format
msgid "Invalid photo with id %s." msgid "Invalid photo with id %s."
msgstr "" msgstr ""
@ -8743,19 +8739,19 @@ msgstr ""
#: src/Module/Profile/Profile.php:326 src/Module/Profile/Profile.php:329 #: src/Module/Profile/Profile.php:326 src/Module/Profile/Profile.php:329
#: src/Module/Profile/Status.php:65 src/Module/Profile/Status.php:68 #: src/Module/Profile/Status.php:65 src/Module/Profile/Status.php:68
#: src/Protocol/Feed.php:953 src/Protocol/OStatus.php:1259 #: src/Protocol/Feed.php:953 src/Protocol/OStatus.php:1242
#, php-format #, php-format
msgid "%s's timeline" msgid "%s's timeline"
msgstr "" msgstr ""
#: src/Module/Profile/Profile.php:327 src/Module/Profile/Status.php:66 #: src/Module/Profile/Profile.php:327 src/Module/Profile/Status.php:66
#: src/Protocol/Feed.php:957 src/Protocol/OStatus.php:1263 #: src/Protocol/Feed.php:957 src/Protocol/OStatus.php:1246
#, php-format #, php-format
msgid "%s's posts" msgid "%s's posts"
msgstr "" msgstr ""
#: src/Module/Profile/Profile.php:328 src/Module/Profile/Status.php:67 #: src/Module/Profile/Profile.php:328 src/Module/Profile/Status.php:67
#: src/Protocol/Feed.php:960 src/Protocol/OStatus.php:1266 #: src/Protocol/Feed.php:960 src/Protocol/OStatus.php:1249
#, php-format #, php-format
msgid "%s's comments" msgid "%s's comments"
msgstr "" msgstr ""
@ -10459,21 +10455,21 @@ msgstr ""
msgid "Attachments:" msgid "Attachments:"
msgstr "" msgstr ""
#: src/Protocol/OStatus.php:1761 #: src/Protocol/OStatus.php:1645
#, php-format #, php-format
msgid "%s is now following %s." msgid "%s is now following %s."
msgstr "" msgstr ""
#: src/Protocol/OStatus.php:1762 #: src/Protocol/OStatus.php:1646
msgid "following" msgid "following"
msgstr "" msgstr ""
#: src/Protocol/OStatus.php:1765 #: src/Protocol/OStatus.php:1649
#, php-format #, php-format
msgid "%s stopped following %s." msgid "%s stopped following %s."
msgstr "" msgstr ""
#: src/Protocol/OStatus.php:1766 #: src/Protocol/OStatus.php:1650
msgid "stopped following" msgid "stopped following"
msgstr "" msgstr ""