3 * @copyright Copyright (C) 2020, Friendica
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']);
42 $r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE
43 `uid` = %d AND `network` = '%s' AND `rel` IN (%d, %d)",
45 DBA::escape(Protocol::OSTATUS),
46 intval(Contact::FRIEND),
47 intval(Contact::SHARING));
49 if (!DBA::isResult($r)) {
50 return ($o . DI::l10n()->t("Error"));
53 $total = $r[0]["total"];
55 $r = q("SELECT `url` FROM `contact` WHERE
56 `uid` = %d AND `network` = '%s' AND `rel` IN (%d, %d)
60 DBA::escape(Protocol::OSTATUS),
61 intval(Contact::FRIEND),
62 intval(Contact::SHARING), $counter++);
64 if (!DBA::isResult($r)) {
65 $o .= DI::l10n()->t("Done");
69 $o .= "<p>".$counter."/".$total.": ".$r[0]["url"]."</p>";
71 $o .= "<p>".DI::l10n()->t("Keep this window open until done.")."</p>";
73 Contact::createFromProbe($a->user, $r[0]["url"], true);
75 DI::page()['htmlhead'] = '<meta http-equiv="refresh" content="1; URL=' . DI::baseUrl() . '/repair_ostatus?counter='.$counter.'">';