kopia lustrzana https://github.com/friendica/friendica
commit
dc3c8f915d
|
@ -40,7 +40,7 @@ function salmon_post(App $a, $xml = '') {
|
|||
$xml = Network::postdata();
|
||||
}
|
||||
|
||||
Logger::log('new salmon ' . $xml, Logger::DATA);
|
||||
Logger::debug('new salmon ' . $xml);
|
||||
|
||||
$nick = ((DI::args()->getArgc() > 1) ? Strings::escapeTags(trim(DI::args()->getArgv()[1])) : '');
|
||||
|
||||
|
@ -64,7 +64,7 @@ function salmon_post(App $a, $xml = '') {
|
|||
$base = $dom;
|
||||
|
||||
if (empty($base)) {
|
||||
Logger::log('unable to locate salmon data in xml ');
|
||||
Logger::notice('unable to locate salmon data in xml');
|
||||
throw new \Friendica\Network\HTTPException\BadRequestException();
|
||||
}
|
||||
|
||||
|
@ -102,18 +102,18 @@ function salmon_post(App $a, $xml = '') {
|
|||
$author_link = $author["author-link"];
|
||||
|
||||
if(! $author_link) {
|
||||
Logger::log('Could not retrieve author URI.');
|
||||
Logger::notice('Could not retrieve author URI.');
|
||||
throw new \Friendica\Network\HTTPException\BadRequestException();
|
||||
}
|
||||
|
||||
// Once we have the author URI, go to the web and try to find their public key
|
||||
|
||||
Logger::log('Fetching key for ' . $author_link);
|
||||
Logger::notice('Fetching key for ' . $author_link);
|
||||
|
||||
$key = Salmon::getKey($author_link, $keyhash);
|
||||
|
||||
if(! $key) {
|
||||
Logger::log('Could not retrieve author key.');
|
||||
Logger::notice('Could not retrieve author key.');
|
||||
throw new \Friendica\Network\HTTPException\BadRequestException();
|
||||
}
|
||||
|
||||
|
@ -133,23 +133,23 @@ function salmon_post(App $a, $xml = '') {
|
|||
$mode = 1;
|
||||
|
||||
if (! $verify) {
|
||||
Logger::log('message did not verify using protocol. Trying compliant format.');
|
||||
Logger::notice('message did not verify using protocol. Trying compliant format.');
|
||||
$verify = Crypto::rsaVerify($compliant_format, $signature, $pubkey);
|
||||
$mode = 2;
|
||||
}
|
||||
|
||||
if (! $verify) {
|
||||
Logger::log('message did not verify using padding. Trying old statusnet format.');
|
||||
Logger::notice('message did not verify using padding. Trying old statusnet format.');
|
||||
$verify = Crypto::rsaVerify($stnet_signed_data, $signature, $pubkey);
|
||||
$mode = 3;
|
||||
}
|
||||
|
||||
if (! $verify) {
|
||||
Logger::log('Message did not verify. Discarding.');
|
||||
Logger::notice('Message did not verify. Discarding.');
|
||||
throw new \Friendica\Network\HTTPException\BadRequestException();
|
||||
}
|
||||
|
||||
Logger::log('Message verified with mode '.$mode);
|
||||
Logger::notice('Message verified with mode '.$mode);
|
||||
|
||||
|
||||
/*
|
||||
|
@ -158,35 +158,25 @@ function salmon_post(App $a, $xml = '') {
|
|||
*
|
||||
*/
|
||||
|
||||
$r = q("SELECT * FROM `contact` WHERE `network` IN ('%s', '%s')
|
||||
AND (`nurl` = '%s' OR `alias` = '%s' OR `alias` = '%s')
|
||||
AND `uid` = %d LIMIT 1",
|
||||
DBA::escape(Protocol::OSTATUS),
|
||||
DBA::escape(Protocol::DFRN),
|
||||
DBA::escape(Strings::normaliseLink($author_link)),
|
||||
DBA::escape($author_link),
|
||||
DBA::escape(Strings::normaliseLink($author_link)),
|
||||
intval($importer['uid'])
|
||||
);
|
||||
$contact = DBA::selectFirst('contact', ["`network` IN (?, ?) AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `uid` = ?",
|
||||
Protocol::OSTATUS, Protocol::DFRN, Strings::normaliseLink($author_link), $author_link, Strings::normaliseLink($author_link), $importer['uid']]);
|
||||
|
||||
if (!empty($r[0]['gsid'])) {
|
||||
GServer::setProtocol($r[0]['gsid'], Post\DeliveryData::OSTATUS);
|
||||
if (!empty($contact['gsid'])) {
|
||||
GServer::setProtocol($contact['gsid'], Post\DeliveryData::OSTATUS);
|
||||
}
|
||||
|
||||
// Have we ignored the person?
|
||||
// If so we can not accept this post.
|
||||
|
||||
if (DBA::isResult($r) && $r[0]['blocked']) {
|
||||
Logger::log('Ignoring this author.');
|
||||
if (!empty($contact['blocked'])) {
|
||||
Logger::notice('Ignoring this author.');
|
||||
throw new \Friendica\Network\HTTPException\AcceptedException();
|
||||
}
|
||||
|
||||
// Placeholder for hub discovery.
|
||||
$hub = '';
|
||||
|
||||
$contact_rec = ((DBA::isResult($r)) ? $r[0] : []);
|
||||
|
||||
OStatus::import($data, $importer, $contact_rec, $hub);
|
||||
OStatus::import($data, $importer, $contact ?: [], $hub);
|
||||
|
||||
throw new \Friendica\Network\HTTPException\OKException();
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ use Friendica\Core\System;
|
|||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Model\Tag;
|
||||
|
@ -51,37 +52,25 @@ function tagger_content(App $a) {
|
|||
|
||||
$item_id = ((DI::args()->getArgc() > 1) ? Strings::escapeTags(trim(DI::args()->getArgv()[1])) : 0);
|
||||
|
||||
Logger::log('tagger: tag ' . $term . ' item ' . $item_id);
|
||||
Logger::notice('tagger: tag ' . $term . ' item ' . $item_id);
|
||||
|
||||
|
||||
$item = Post::selectFirst([], ['id' => $item_id]);
|
||||
|
||||
if (!$item_id || !DBA::isResult($item)) {
|
||||
Logger::log('tagger: no item ' . $item_id);
|
||||
Logger::notice('tagger: no item ' . $item_id);
|
||||
return;
|
||||
}
|
||||
|
||||
$owner_uid = $item['uid'];
|
||||
$blocktags = 0;
|
||||
|
||||
$r = q("select `blocktags` from user where uid = %d limit 1",
|
||||
intval($owner_uid)
|
||||
);
|
||||
if (DBA::isResult($r)) {
|
||||
$blocktags = $r[0]['blocktags'];
|
||||
}
|
||||
|
||||
if (local_user() != $owner_uid) {
|
||||
return;
|
||||
}
|
||||
|
||||
$r = q("select * from contact where self = 1 and uid = %d limit 1",
|
||||
intval(local_user())
|
||||
);
|
||||
if (DBA::isResult($r)) {
|
||||
$contact = $r[0];
|
||||
} else {
|
||||
Logger::log('tagger: no contact_id');
|
||||
$contact = Contact::selectFirst([], ['self' => true, 'uid' => local_user()]);
|
||||
if (!DBA::isResult($contact)) {
|
||||
Logger::notice('tagger: no contact_id');
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,11 +33,8 @@ function wall_attach_post(App $a) {
|
|||
|
||||
if (DI::args()->getArgc() > 1) {
|
||||
$nick = DI::args()->getArgv()[1];
|
||||
$r = q("SELECT `user`.*, `contact`.`id` FROM `user` LEFT JOIN `contact` on `user`.`uid` = `contact`.`uid` WHERE `user`.`nickname` = '%s' AND `user`.`blocked` = 0 and `contact`.`self` = 1 LIMIT 1",
|
||||
DBA::escape($nick)
|
||||
);
|
||||
|
||||
if (! DBA::isResult($r)) {
|
||||
$owner = User::getOwnerDataByNick($nick);
|
||||
if (!DBA::isResult($owner)) {
|
||||
if ($r_json) {
|
||||
echo json_encode(['error' => DI::l10n()->t('Invalid request.')]);
|
||||
exit();
|
||||
|
@ -55,22 +52,15 @@ function wall_attach_post(App $a) {
|
|||
|
||||
$can_post = false;
|
||||
|
||||
$page_owner_uid = $r[0]['uid'];
|
||||
$page_owner_cid = $r[0]['id'];
|
||||
$community_page = (($r[0]['page-flags'] == User::PAGE_FLAGS_COMMUNITY) ? true : false);
|
||||
$page_owner_uid = $owner['uid'];
|
||||
$page_owner_cid = $owner['id'];
|
||||
$community_page = $owner['page-flags'] == User::PAGE_FLAGS_COMMUNITY;
|
||||
|
||||
if (local_user() && (local_user() == $page_owner_uid)) {
|
||||
$can_post = true;
|
||||
} elseif ($community_page && !empty(Session::getRemoteContactID($page_owner_uid))) {
|
||||
$contact_id = Session::getRemoteContactID($page_owner_uid);
|
||||
$r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
|
||||
intval($contact_id),
|
||||
intval($page_owner_uid)
|
||||
);
|
||||
|
||||
if (DBA::isResult($r)) {
|
||||
$can_post = true;
|
||||
}
|
||||
$can_post = DBA::exists('contact', ['blocked' => false, 'pending' => false, 'id' => $contact_id, 'uid' => $page_owner_uid]);
|
||||
}
|
||||
|
||||
if (!$can_post) {
|
||||
|
|
|
@ -81,18 +81,9 @@ function wall_upload_post(App $a, $desktopmode = true)
|
|||
$can_post = true;
|
||||
} elseif ($community_page && !empty(Session::getRemoteContactID($page_owner_uid))) {
|
||||
$contact_id = Session::getRemoteContactID($page_owner_uid);
|
||||
|
||||
$r = q("SELECT `uid` FROM `contact`
|
||||
WHERE `blocked` = 0 AND `pending` = 0
|
||||
AND `id` = %d AND `uid` = %d LIMIT 1",
|
||||
intval($contact_id),
|
||||
intval($page_owner_uid)
|
||||
);
|
||||
if (DBA::isResult($r)) {
|
||||
$can_post = true;
|
||||
$can_post = DBA::exists('contact', ['blocked' => false, 'pending' => false, 'id' => $contact_id, 'uid' => $page_owner_uid]);
|
||||
$visitor = $contact_id;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$can_post) {
|
||||
if ($r_json) {
|
||||
|
|
Ładowanie…
Reference in New Issue