Logger::log("Fetch post from ".$source_url, Logger::DEBUG);
- $envelope = DI::httpRequest()->fetch($source_url);
+ $envelope = DI::httpClient()->fetch($source_url);
if ($envelope) {
Logger::log("Envelope was fetched.", Logger::DEBUG);
$x = self::verifyMagicEnvelope($envelope);
if (!intval(DI::config()->get("system", "diaspora_test"))) {
$content_type = (($public_batch) ? "application/magic-envelope+xml" : "application/json");
- $postResult = DI::httpRequest()->post($dest_url . "/", $envelope, ["Content-Type: " . $content_type]);
+ $postResult = DI::httpClient()->post($dest_url . "/", $envelope, ['Content-Type' => $content_type]);
$return_code = $postResult->getReturnCode();
} else {
Logger::log("test_mode");
if (!empty($fcontact)) {
$pubkey = $fcontact['pubkey'];
}
+ } else {
+ // The "addr" field should always be filled.
+ // If this isn't the case, it will raise a notice some lines later.
+ // And in the log we will see where it came from and we can handle it there.
+ Logger::notice('Empty addr', ['contact' => $contact ?? [], 'callstack' => System::callstack(20)]);
}
$envelope = self::buildMessage($msg, $owner, $contact, $owner['uprvkey'], $pubkey, $public_batch);
$dob = '';
if ($profile['dob'] && ($profile['dob'] > '0000-00-00')) {
- list($year, $month, $day) = sscanf($profile['dob'], '%4d-%2d-%2d');
+ [$year, $month, $day] = sscanf($profile['dob'], '%4d-%2d-%2d');
if ($year < 1004) {
$year = 1004;
}
}
if (!$recips) {
- $recips = q(
- "SELECT `id`,`name`,`network`,`pubkey`,`notify` FROM `contact` WHERE `network` = '%s'
- AND `uid` = %d AND `rel` != %d",
- DBA::escape(Protocol::DIASPORA),
- intval($uid),
- intval(Contact::SHARING)
- );
+ $recips = DBA::selectToArray('contact', [], ['network' => Protocol::DIASPORA, 'uid' => $uid, 'rel' => [Contact::FOLLOWER, Contact::FRIEND]]);
}
if (!$recips) {
*/
public static function createCommentSignature(array $item)
{
- $contact = Contact::getById($item['author-id'], ['url']);
- if (empty($contact['url'])) {
- Logger::warning('Author Contact not found', ['author-id' => $item['author-id']]);
- return false;
+ if (!empty($item['author-link'])) {
+ $url = $item['author-link'];
+ } else {
+ $contact = Contact::getById($item['author-id'], ['url']);
+ if (empty($contact['url'])) {
+ Logger::warning('Author Contact not found', ['author-id' => $item['author-id']]);
+ return false;
+ }
+ $url = $contact['url'];
}
- $uid = User::getIdForURL($contact['url']);
+ $uid = User::getIdForURL($url);
if (empty($uid)) {
Logger::info('No owner post, so not storing signature', ['url' => $contact['url']]);
return false;