3 * @copyright Copyright (C) 2010-2022, the Friendica project
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 use Friendica\Core\Protocol;
24 use Friendica\Database\DBA;
26 use Friendica\Model\Contact;
28 function repair_ostatus_content(App $a) {
31 notice(DI::l10n()->t('Permission denied.'));
32 DI::baseUrl()->redirect('ostatus_repair');
36 $o = '<h2>' . DI::l10n()->t('Resubscribing to OStatus contacts') . '</h2>';
40 $counter = intval($_REQUEST['counter'] ?? 0);
42 $condition = ['uid' => $uid, 'network' => Protocol::OSTATUS, 'rel' => [Contact::FRIEND, Contact::SHARING]];
43 $total = DBA::count('contact', $condition);
46 return ($o . DI::l10n()->t('Error'));
49 $contact = Contact::selectToArray(['url'], $condition, ['order' => ['url'], 'limit' => [$counter++, 1]]);
50 if (!DBA::isResult($contact)) {
51 $o .= DI::l10n()->t('Done');
55 $o .= '<p>' . $counter . '/' . $total . ': ' . $contact[0]['url'] . '</p>';
57 $o .= '<p>' . DI::l10n()->t('Keep this window open until done.') . '</p>';
59 Contact::createFromProbeForUser($a->getLoggedInUserId(), $contact[0]['url']);
61 DI::page()['htmlhead'] = '<meta http-equiv="refresh" content="1; URL=' . DI::baseUrl() . '/repair_ostatus?counter=' . $counter . '">';