diff --git a/mod/repair_ostatus.php b/mod/repair_ostatus.php deleted file mode 100644 index b0ee0bf575..0000000000 --- a/mod/repair_ostatus.php +++ /dev/null @@ -1,64 +0,0 @@ -. - * - */ - -use Friendica\App; -use Friendica\Core\Protocol; -use Friendica\Database\DBA; -use Friendica\DI; -use Friendica\Model\Contact; - -function repair_ostatus_content(App $a) { - - if (!DI::userSession()->getLocalUserId()) { - DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); - DI::baseUrl()->redirect('ostatus_repair'); - // NOTREACHED - } - - $o = '

' . DI::l10n()->t('Resubscribing to OStatus contacts') . '

'; - - $uid = DI::userSession()->getLocalUserId(); - - $counter = intval($_REQUEST['counter'] ?? 0); - - $condition = ['uid' => $uid, 'network' => Protocol::OSTATUS, 'rel' => [Contact::FRIEND, Contact::SHARING]]; - $total = DBA::count('contact', $condition); - - if (!$total) { - return ($o . DI::l10n()->tt('Error', 'Errors', 1)); - } - - $contact = Contact::selectToArray(['url'], $condition, ['order' => ['url'], 'limit' => [$counter++, 1]]); - if (!DBA::isResult($contact)) { - $o .= DI::l10n()->t('Done'); - return $o; - } - - $o .= '

' . $counter . '/' . $total . ': ' . $contact[0]['url'] . '

'; - - $o .= '

' . DI::l10n()->t('Keep this window open until done.') . '

'; - - Contact::createFromProbeForUser($a->getLoggedInUserId(), $contact[0]['url']); - - DI::page()['htmlhead'] = ''; - - return $o; -} diff --git a/mod/settings.php b/mod/settings.php index 45f5f96c54..259981541b 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -331,7 +331,7 @@ function settings_content(App $a) '$attach_link_title' => ['attach_link_title', DI::l10n()->t('Attach the link title'), $attach_link_title, DI::l10n()->t('When activated, the title of the attached link will be added as a title on posts to Diaspora. This is mostly helpful with "remote-self" contacts that share feed content.')], '$legacy_contact' => ['legacy_contact', DI::l10n()->t('Your legacy ActivityPub/GNU Social account'), $legacy_contact, DI::l10n()->t("If you enter your old account name from an ActivityPub based system or your GNU Social/Statusnet account name here (in the format user@domain.tld), your contacts will be added automatically. The field will be emptied when done.")], - '$repair_ostatus_url' => DI::baseUrl() . '/repair_ostatus', + '$repair_ostatus_url' => 'ostatus/repair', '$repair_ostatus_text' => DI::l10n()->t('Repair OStatus subscriptions'), '$connector_settings_forms' => $connector_settings_forms, diff --git a/src/Module/OStatus/Repair.php b/src/Module/OStatus/Repair.php new file mode 100644 index 0000000000..b7920c2abc --- /dev/null +++ b/src/Module/OStatus/Repair.php @@ -0,0 +1,93 @@ +. + * + */ + +namespace Friendica\Module\OStatus; + +use Friendica\App; +use Friendica\Core\L10n; +use Friendica\Core\Protocol; +use Friendica\Core\Renderer; +use Friendica\Core\Session\Capability\IHandleUserSessions; +use Friendica\Database\Database; +use Friendica\Model\Contact; +use Friendica\Module\Response; +use Friendica\Navigation\SystemMessages; +use Friendica\Util\Profiler; +use Psr\Log\LoggerInterface; + +class Repair extends \Friendica\BaseModule +{ + /** @var IHandleUserSessions */ + private $session; + /** @var SystemMessages */ + private $systemMessages; + /** @var Database */ + private $database; + /** @var App\Page */ + private $page; + + public function __construct(App\Page $page, Database $database, SystemMessages $systemMessages, IHandleUserSessions $session, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = []) + { + parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); + + $this->session = $session; + $this->systemMessages = $systemMessages; + $this->database = $database; + $this->page = $page; + } + + protected function content(array $request = []): string + { + if (!$this->session->getLocalUserId()) { + $this->systemMessages->addNotice($this->t('Permission denied.')); + $this->baseUrl->redirect('login'); + } + + $uid = $this->session->getLocalUserId(); + + $counter = intval($request['counter'] ?? 0); + + $condition = ['uid' => $uid, 'network' => Protocol::OSTATUS, 'rel' => [Contact::FRIEND, Contact::SHARING]]; + $total = $this->database->count('contact', $condition); + if ($total) { + $contacts = Contact::selectToArray(['url'], $condition, ['order' => ['url'], 'limit' => [$counter++, 1]]); + if ($contacts) { + Contact::createFromProbeForUser($this->session->getLocalUserId(), $contacts[0]['url']); + + $this->page['htmlhead'] .= ''; + } + } + + $tpl = Renderer::getMarkupTemplate('ostatus/repair.tpl'); + + return Renderer::replaceMacros($tpl, [ + '$l10n' => [ + 'title' => $this->t('Resubscribing to OStatus contacts'), + 'keep' => $this->t('Keep this window open until done.'), + 'done' => $this->t('✔ Done'), + 'nocontacts' => $this->t('No OStatus contacts to resubscribe to.'), + ], + '$total' => $total, + '$counter' => $counter, + '$contact' => $contacts[0] ?? null, + ]); + } +} diff --git a/static/routes.config.php b/static/routes.config.php index 773b8d2531..e64b138307 100644 --- a/static/routes.config.php +++ b/static/routes.config.php @@ -522,6 +522,8 @@ return [ '/openid' => [Module\Security\OpenID::class, [R::GET]], '/opensearch' => [Module\OpenSearch::class, [R::GET]], + '/ostatus/repair' => [Module\OStatus\Repair::class, [R::GET]], + '/parseurl' => [Module\ParseUrl::class, [R::GET]], '/permission/tooltip/{type}/{id:\d+}' => [Module\PermissionTooltip::class, [R::GET]], diff --git a/view/lang/C/messages.po b/view/lang/C/messages.po index 359fbebd0c..0aaf5d0176 100644 --- a/view/lang/C/messages.po +++ b/view/lang/C/messages.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 2022.12-dev\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-11-07 19:28+0000\n" +"POT-Creation-Date: 2022-11-07 21:47-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -41,8 +41,8 @@ msgstr "" #: mod/editpost.php:38 mod/item.php:181 mod/item.php:186 mod/item.php:870 #: mod/message.php:69 mod/message.php:114 mod/notes.php:44 #: mod/ostatus_subscribe.php:33 mod/photos.php:159 mod/photos.php:886 -#: mod/repair_ostatus.php:31 mod/settings.php:40 mod/settings.php:50 -#: mod/settings.php:156 src/Module/Attach.php:56 src/Module/BaseApi.php:94 +#: mod/settings.php:40 mod/settings.php:50 mod/settings.php:156 +#: src/Module/Attach.php:56 src/Module/BaseApi.php:94 #: src/Module/BaseNotifications.php:98 src/Module/Calendar/Event/API.php:88 #: src/Module/Calendar/Event/Form.php:84 src/Module/Calendar/Event/Show.php:54 #: src/Module/Calendar/Export.php:62 src/Module/Calendar/Show.php:64 @@ -54,16 +54,17 @@ msgstr "" #: src/Module/Group.php:40 src/Module/Group.php:83 src/Module/Invite.php:42 #: src/Module/Invite.php:131 src/Module/Notifications/Notification.php:76 #: src/Module/Notifications/Notification.php:107 -#: src/Module/Profile/Attachment/Upload.php:97 src/Module/Profile/Common.php:55 -#: src/Module/Profile/Contacts.php:55 src/Module/Profile/Photos/Upload.php:108 -#: src/Module/Profile/Schedule.php:39 src/Module/Profile/Schedule.php:56 -#: src/Module/Profile/UnkMail.php:69 src/Module/Profile/UnkMail.php:121 -#: src/Module/Profile/UnkMail.php:132 src/Module/Register.php:77 -#: src/Module/Register.php:90 src/Module/Register.php:206 -#: src/Module/Register.php:245 src/Module/Search/Directory.php:37 -#: src/Module/Settings/Account.php:50 src/Module/Settings/Account.php:410 -#: src/Module/Settings/Delegation.php:41 src/Module/Settings/Delegation.php:69 -#: src/Module/Settings/Display.php:41 src/Module/Settings/Display.php:119 +#: src/Module/OStatus/Repair.php:60 src/Module/Profile/Attachment/Upload.php:97 +#: src/Module/Profile/Common.php:55 src/Module/Profile/Contacts.php:55 +#: src/Module/Profile/Photos/Upload.php:108 src/Module/Profile/Schedule.php:39 +#: src/Module/Profile/Schedule.php:56 src/Module/Profile/UnkMail.php:69 +#: src/Module/Profile/UnkMail.php:121 src/Module/Profile/UnkMail.php:132 +#: src/Module/Register.php:77 src/Module/Register.php:90 +#: src/Module/Register.php:206 src/Module/Register.php:245 +#: src/Module/Search/Directory.php:37 src/Module/Settings/Account.php:50 +#: src/Module/Settings/Account.php:410 src/Module/Settings/Delegation.php:41 +#: src/Module/Settings/Delegation.php:69 src/Module/Settings/Display.php:41 +#: src/Module/Settings/Display.php:119 #: src/Module/Settings/Profile/Photo/Crop.php:165 #: src/Module/Settings/Profile/Photo/Index.php:111 #: src/Module/Settings/UserExport.php:84 src/Module/Settings/UserExport.php:118 @@ -186,7 +187,7 @@ msgstr "" #: mod/editpost.php:128 mod/photos.php:1334 mod/photos.php:1390 #: mod/photos.php:1464 src/Content/Conversation.php:386 -#: src/Module/Calendar/Event/Form.php:247 src/Module/Item/Compose.php:199 +#: src/Module/Calendar/Event/Form.php:248 src/Module/Item/Compose.php:199 #: src/Object/Post.php:997 msgid "Preview" msgstr "" @@ -247,7 +248,7 @@ msgid "Browser" msgstr "" #: mod/editpost.php:145 mod/photos.php:934 mod/photos.php:1288 -#: src/Content/Conversation.php:373 src/Module/Calendar/Event/Form.php:252 +#: src/Content/Conversation.php:373 src/Module/Calendar/Event/Form.php:253 msgid "Permissions" msgstr "" @@ -510,7 +511,7 @@ msgstr "" #: mod/message.php:204 mod/message.php:359 mod/photos.php:916 #: mod/photos.php:1020 mod/photos.php:1292 mod/photos.php:1333 #: mod/photos.php:1389 mod/photos.php:1463 src/Module/Admin/Item/Source.php:60 -#: src/Module/Calendar/Event/Form.php:249 src/Module/Contact/Advanced.php:132 +#: src/Module/Calendar/Event/Form.php:250 src/Module/Contact/Advanced.php:132 #: src/Module/Contact/Profile.php:328 #: src/Module/Debug/ActivityPubConversion.php:140 #: src/Module/Debug/Babel.php:313 src/Module/Debug/Localtime.php:64 @@ -614,7 +615,7 @@ msgstr "" msgid "Unsupported network" msgstr "" -#: mod/ostatus_subscribe.php:102 mod/repair_ostatus.php:51 +#: mod/ostatus_subscribe.php:102 msgid "Done" msgstr "" @@ -630,7 +631,7 @@ msgstr "" msgid "ignored" msgstr "" -#: mod/ostatus_subscribe.php:126 mod/repair_ostatus.php:57 +#: mod/ostatus_subscribe.php:126 src/Module/OStatus/Repair.php:84 msgid "Keep this window open until done." msgstr "" @@ -959,17 +960,6 @@ msgstr "" msgid "Please enter your password for verification:" msgstr "" -#: mod/repair_ostatus.php:36 -msgid "Resubscribing to OStatus contacts" -msgstr "" - -#: mod/repair_ostatus.php:46 src/Module/Debug/ActivityPubConversion.php:129 -#: src/Module/Debug/Babel.php:293 src/Module/Security/TwoFactor/Verify.php:98 -msgid "Error" -msgid_plural "Errors" -msgstr[0] "" -msgstr[1] "" - #: mod/settings.php:122 msgid "Failed to connect with email account using the settings provided." msgstr "" @@ -1946,65 +1936,65 @@ msgstr "" msgid "show more" msgstr "" -#: src/Content/Item.php:295 src/Model/Item.php:2870 +#: src/Content/Item.php:294 src/Model/Item.php:2870 msgid "event" msgstr "" -#: src/Content/Item.php:298 src/Content/Item.php:308 +#: src/Content/Item.php:297 src/Content/Item.php:307 #: src/Module/Post/Tag/Add.php:123 msgid "status" msgstr "" -#: src/Content/Item.php:304 src/Model/Item.php:2872 +#: src/Content/Item.php:303 src/Model/Item.php:2872 #: src/Module/Post/Tag/Add.php:123 msgid "photo" msgstr "" -#: src/Content/Item.php:318 src/Module/Post/Tag/Add.php:141 +#: src/Content/Item.php:317 src/Module/Post/Tag/Add.php:141 #, php-format msgid "%1$s tagged %2$s's %3$s with %4$s" msgstr "" -#: src/Content/Item.php:387 view/theme/frio/theme.php:267 +#: src/Content/Item.php:386 view/theme/frio/theme.php:267 msgid "Follow Thread" msgstr "" -#: src/Content/Item.php:388 src/Model/Contact.php:1199 +#: src/Content/Item.php:387 src/Model/Contact.php:1199 msgid "View Status" msgstr "" -#: src/Content/Item.php:389 src/Content/Item.php:407 src/Model/Contact.php:1137 +#: src/Content/Item.php:388 src/Content/Item.php:406 src/Model/Contact.php:1137 #: src/Model/Contact.php:1191 src/Model/Contact.php:1200 #: src/Module/Directory.php:157 src/Module/Settings/Profile/Index.php:234 msgid "View Profile" msgstr "" -#: src/Content/Item.php:390 src/Model/Contact.php:1201 +#: src/Content/Item.php:389 src/Model/Contact.php:1201 msgid "View Photos" msgstr "" -#: src/Content/Item.php:391 src/Model/Contact.php:1192 +#: src/Content/Item.php:390 src/Model/Contact.php:1192 #: src/Model/Contact.php:1202 msgid "Network Posts" msgstr "" -#: src/Content/Item.php:392 src/Model/Contact.php:1193 +#: src/Content/Item.php:391 src/Model/Contact.php:1193 #: src/Model/Contact.php:1203 msgid "View Contact" msgstr "" -#: src/Content/Item.php:393 src/Model/Contact.php:1204 +#: src/Content/Item.php:392 src/Model/Contact.php:1204 msgid "Send PM" msgstr "" -#: src/Content/Item.php:394 src/Module/Admin/Blocklist/Contact.php:100 +#: src/Content/Item.php:393 src/Module/Admin/Blocklist/Contact.php:100 #: src/Module/Admin/Users/Active.php:140 src/Module/Admin/Users/Index.php:154 #: src/Module/Contact.php:401 src/Module/Contact/Profile.php:349 #: src/Module/Contact/Profile.php:468 msgid "Block" msgstr "" -#: src/Content/Item.php:395 src/Module/Contact.php:402 +#: src/Content/Item.php:394 src/Module/Contact.php:402 #: src/Module/Contact/Profile.php:350 src/Module/Contact/Profile.php:476 #: src/Module/Notifications/Introductions.php:134 #: src/Module/Notifications/Introductions.php:206 @@ -2012,11 +2002,11 @@ msgstr "" msgid "Ignore" msgstr "" -#: src/Content/Item.php:399 src/Object/Post.php:454 +#: src/Content/Item.php:398 src/Object/Post.php:454 msgid "Languages" msgstr "" -#: src/Content/Item.php:404 src/Content/Widget.php:80 +#: src/Content/Item.php:403 src/Content/Widget.php:80 #: src/Model/Contact.php:1194 src/Model/Contact.php:1205 #: src/Module/Contact/Follow.php:165 view/theme/vier/theme.php:198 msgid "Connect/Follow" @@ -2548,7 +2538,7 @@ msgstr "" #: src/Content/Widget/VCard.php:104 src/Model/Event.php:82 #: src/Model/Event.php:109 src/Model/Event.php:471 src/Model/Event.php:992 -#: src/Model/Profile.php:373 src/Module/Calendar/Event/Form.php:238 +#: src/Model/Profile.php:373 src/Module/Calendar/Event/Form.php:239 #: src/Module/Contact/Profile.php:370 src/Module/Directory.php:147 #: src/Module/Notifications/Introductions.php:187 #: src/Module/Profile/Profile.php:193 @@ -3346,21 +3336,21 @@ msgstr "" msgid "Sept" msgstr "" -#: src/Model/Event.php:462 src/Module/Calendar/Show.php:124 +#: src/Model/Event.php:462 src/Module/Calendar/Show.php:125 msgid "today" msgstr "" -#: src/Model/Event.php:463 src/Module/Calendar/Show.php:125 +#: src/Model/Event.php:463 src/Module/Calendar/Show.php:126 #: src/Util/Temporal.php:341 msgid "month" msgstr "" -#: src/Model/Event.php:464 src/Module/Calendar/Show.php:126 +#: src/Model/Event.php:464 src/Module/Calendar/Show.php:127 #: src/Util/Temporal.php:342 msgid "week" msgstr "" -#: src/Model/Event.php:465 src/Module/Calendar/Show.php:127 +#: src/Model/Event.php:465 src/Module/Calendar/Show.php:128 #: src/Util/Temporal.php:343 msgid "day" msgstr "" @@ -3369,7 +3359,7 @@ msgstr "" msgid "No events to display" msgstr "" -#: src/Model/Event.php:567 src/Module/Calendar/Event/Show.php:64 +#: src/Model/Event.php:567 src/Module/Calendar/Event/Show.php:60 msgid "Event not found." msgstr "" @@ -4269,8 +4259,8 @@ msgstr "" #: src/Module/Admin/Blocklist/Server/Index.php:83 #: src/Module/Admin/Blocklist/Server/Index.php:111 #: src/Module/Admin/Blocklist/Server/Index.php:112 -#: src/Module/Admin/Item/Delete.php:69 src/Module/Calendar/Event/Form.php:208 -#: src/Module/Calendar/Event/Form.php:240 src/Module/Debug/Probe.php:59 +#: src/Module/Admin/Item/Delete.php:69 src/Module/Calendar/Event/Form.php:209 +#: src/Module/Calendar/Event/Form.php:241 src/Module/Debug/Probe.php:59 #: src/Module/Install.php:207 src/Module/Install.php:240 #: src/Module/Install.php:245 src/Module/Install.php:264 #: src/Module/Install.php:275 src/Module/Install.php:280 @@ -4781,7 +4771,7 @@ msgstr "" msgid "Click to view details" msgstr "" -#: src/Module/Admin/Logs/View.php:97 src/Module/Calendar/Event/Form.php:206 +#: src/Module/Admin/Logs/View.php:97 src/Module/Calendar/Event/Form.php:207 msgid "Event details" msgstr "" @@ -4959,7 +4949,7 @@ msgstr "" msgid "Policies" msgstr "" -#: src/Module/Admin/Site.php:439 src/Module/Calendar/Event/Form.php:251 +#: src/Module/Admin/Site.php:439 src/Module/Calendar/Event/Form.php:252 #: src/Module/Contact.php:477 src/Module/Profile/Profile.php:248 msgid "Advanced" msgstr "" @@ -6522,7 +6512,7 @@ msgid "The post was created" msgstr "" #: src/Module/Calendar/Event/API.php:100 src/Module/Calendar/Event/API.php:135 -#: src/Module/Calendar/Event/Form.php:80 src/Module/Calendar/Event/Show.php:58 +#: src/Module/Calendar/Event/Form.php:80 msgid "Invalid Request" msgstr "" @@ -6542,41 +6532,41 @@ msgstr "" msgid "Event title and start time are required." msgstr "" -#: src/Module/Calendar/Event/Form.php:207 +#: src/Module/Calendar/Event/Form.php:208 msgid "Starting date and Title are required." msgstr "" -#: src/Module/Calendar/Event/Form.php:208 -#: src/Module/Calendar/Event/Form.php:213 +#: src/Module/Calendar/Event/Form.php:209 +#: src/Module/Calendar/Event/Form.php:214 msgid "Event Starts:" msgstr "" -#: src/Module/Calendar/Event/Form.php:222 -#: src/Module/Calendar/Event/Form.php:246 +#: src/Module/Calendar/Event/Form.php:223 +#: src/Module/Calendar/Event/Form.php:247 msgid "Finish date/time is not known or not relevant" msgstr "" -#: src/Module/Calendar/Event/Form.php:224 -#: src/Module/Calendar/Event/Form.php:229 +#: src/Module/Calendar/Event/Form.php:225 +#: src/Module/Calendar/Event/Form.php:230 msgid "Event Finishes:" msgstr "" -#: src/Module/Calendar/Event/Form.php:236 src/Module/Profile/Profile.php:171 +#: src/Module/Calendar/Event/Form.php:237 src/Module/Profile/Profile.php:171 #: src/Module/Settings/Profile/Index.php:247 msgid "Description:" msgstr "" -#: src/Module/Calendar/Event/Form.php:240 -#: src/Module/Calendar/Event/Form.php:242 +#: src/Module/Calendar/Event/Form.php:241 +#: src/Module/Calendar/Event/Form.php:243 msgid "Title:" msgstr "" -#: src/Module/Calendar/Event/Form.php:243 #: src/Module/Calendar/Event/Form.php:244 +#: src/Module/Calendar/Event/Form.php:245 msgid "Share this event" msgstr "" -#: src/Module/Calendar/Event/Form.php:250 src/Module/Profile/Profile.php:247 +#: src/Module/Calendar/Event/Form.php:251 src/Module/Profile/Profile.php:247 msgid "Basic" msgstr "" @@ -6592,19 +6582,19 @@ msgstr "" msgid "calendar" msgstr "" -#: src/Module/Calendar/Show.php:120 +#: src/Module/Calendar/Show.php:121 msgid "Events" msgstr "" -#: src/Module/Calendar/Show.php:121 +#: src/Module/Calendar/Show.php:122 msgid "View" msgstr "" -#: src/Module/Calendar/Show.php:122 +#: src/Module/Calendar/Show.php:123 msgid "Create New Event" msgstr "" -#: src/Module/Calendar/Show.php:128 +#: src/Module/Calendar/Show.php:129 msgid "list" msgstr "" @@ -7262,6 +7252,13 @@ msgstr "" msgid "Result Item" msgstr "" +#: src/Module/Debug/ActivityPubConversion.php:129 +#: src/Module/Debug/Babel.php:293 src/Module/Security/TwoFactor/Verify.php:98 +msgid "Error" +msgid_plural "Errors" +msgstr[0] "" +msgstr[1] "" + #: src/Module/Debug/ActivityPubConversion.php:138 msgid "Source activity" msgstr "" @@ -8164,6 +8161,18 @@ msgstr "" msgid "Unsupported or missing grant type" msgstr "" +#: src/Module/OStatus/Repair.php:83 +msgid "Resubscribing to OStatus contacts" +msgstr "" + +#: src/Module/OStatus/Repair.php:85 +msgid "✔ Done" +msgstr "" + +#: src/Module/OStatus/Repair.php:86 +msgid "No OStatus contacts to resubscribe to." +msgstr "" + #: src/Module/PermissionTooltip.php:49 #, php-format msgid "Wrong type \"%s\", expected one of: %s" diff --git a/view/templates/ostatus/repair.tpl b/view/templates/ostatus/repair.tpl new file mode 100644 index 0000000000..06298adcfe --- /dev/null +++ b/view/templates/ostatus/repair.tpl @@ -0,0 +1,18 @@ +
+

{{$l10n.title}}

+{{if $total}} + {{if $contact}} +
+ {{$counter}} / {{$total}} : {{$contact.url}} +
+ {{else}} +
+ {{$l10n.done}} +
+ {{/if}} +{{else}} +
+ {{$l10n.nocontacts}} +
+{{/if}} +