Remove dependency to App in Contact::createFromProbe

- Address https://github.com/friendica/friendica/issues/8473#issuecomment-641259906
This commit is contained in:
Hypolite Petovan 2020-06-10 10:36:42 -04:00
commit a5a7855d39
7 changed files with 32 additions and 33 deletions

View file

@ -40,7 +40,6 @@ function follow_post(App $a)
DI::baseUrl()->redirect('contact');
}
$uid = local_user();
$url = Probe::cleanURI($_REQUEST['url']);
$return_path = 'follow?url=' . urlencode($url);
@ -48,7 +47,7 @@ function follow_post(App $a)
// This is just a precaution if maybe this page is called somewhere directly via POST
$_SESSION['fastlane'] = $url;
$result = Contact::createFromProbe($uid, $url, true);
$result = Contact::createFromProbe($a->user, $url, true);
if ($result['success'] == false) {
// Possibly it is a remote item and not an account

View file

@ -91,7 +91,7 @@ function ostatus_subscribe_content(App $a)
$probed = Probe::uri($url);
if ($probed['network'] == Protocol::OSTATUS) {
$result = Contact::createFromProbe($uid, $url, true, Protocol::OSTATUS);
$result = Contact::createFromProbe($a->user, $url, true, Protocol::OSTATUS);
if ($result['success']) {
$o .= ' - ' . DI::l10n()->t('success');
} else {

View file

@ -70,7 +70,7 @@ function repair_ostatus_content(App $a) {
$o .= "<p>".DI::l10n()->t("Keep this window open until done.")."</p>";
Contact::createFromProbe($uid, $r[0]["url"], true);
Contact::createFromProbe($a->user, $r[0]["url"], true);
DI::page()['htmlhead'] = '<meta http-equiv="refresh" content="1; URL=' . DI::baseUrl() . '/repair_ostatus?counter='.$counter.'">';

View file

@ -42,15 +42,11 @@ function salmon_post(App $a, $xml = '') {
$nick = (($a->argc > 1) ? Strings::escapeTags(trim($a->argv[1])) : '');
$r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1",
DBA::escape($nick)
);
if (! DBA::isResult($r)) {
$importer = DBA::selectFirst('user', [], ['nickname' => $nick, 'account_expired' => false, 'account_removed' => false]);
if (! DBA::isResult($importer)) {
throw new \Friendica\Network\HTTPException\InternalServerErrorException();
}
$importer = $r[0];
// parse the xml
$dom = simplexml_load_string($xml,'SimpleXMLElement',0, ActivityNamespace::SALMON_ME);
@ -175,7 +171,7 @@ function salmon_post(App $a, $xml = '') {
Logger::log('Author ' . $author_link . ' unknown to user ' . $importer['uid'] . '.');
if (DI::pConfig()->get($importer['uid'], 'system', 'ostatus_autofriend')) {
$result = Contact::createFromProbe($importer['uid'], $author_link);
$result = Contact::createFromProbe($importer, $author_link);
if ($result['success']) {
$r = q("SELECT * FROM `contact` WHERE `network` = '%s' AND ( `url` = '%s' OR `alias` = '%s')