commit
dc3c8f915d
4 changed files with 30 additions and 70 deletions
|
@ -40,7 +40,7 @@ function salmon_post(App $a, $xml = '') {
|
||||||
$xml = Network::postdata();
|
$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])) : '');
|
$nick = ((DI::args()->getArgc() > 1) ? Strings::escapeTags(trim(DI::args()->getArgv()[1])) : '');
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ function salmon_post(App $a, $xml = '') {
|
||||||
$base = $dom;
|
$base = $dom;
|
||||||
|
|
||||||
if (empty($base)) {
|
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();
|
throw new \Friendica\Network\HTTPException\BadRequestException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,18 +102,18 @@ function salmon_post(App $a, $xml = '') {
|
||||||
$author_link = $author["author-link"];
|
$author_link = $author["author-link"];
|
||||||
|
|
||||||
if(! $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();
|
throw new \Friendica\Network\HTTPException\BadRequestException();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Once we have the author URI, go to the web and try to find their public key
|
// 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);
|
$key = Salmon::getKey($author_link, $keyhash);
|
||||||
|
|
||||||
if(! $key) {
|
if(! $key) {
|
||||||
Logger::log('Could not retrieve author key.');
|
Logger::notice('Could not retrieve author key.');
|
||||||
throw new \Friendica\Network\HTTPException\BadRequestException();
|
throw new \Friendica\Network\HTTPException\BadRequestException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,23 +133,23 @@ function salmon_post(App $a, $xml = '') {
|
||||||
$mode = 1;
|
$mode = 1;
|
||||||
|
|
||||||
if (! $verify) {
|
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);
|
$verify = Crypto::rsaVerify($compliant_format, $signature, $pubkey);
|
||||||
$mode = 2;
|
$mode = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $verify) {
|
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);
|
$verify = Crypto::rsaVerify($stnet_signed_data, $signature, $pubkey);
|
||||||
$mode = 3;
|
$mode = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $verify) {
|
if (! $verify) {
|
||||||
Logger::log('Message did not verify. Discarding.');
|
Logger::notice('Message did not verify. Discarding.');
|
||||||
throw new \Friendica\Network\HTTPException\BadRequestException();
|
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')
|
$contact = DBA::selectFirst('contact', ["`network` IN (?, ?) AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `uid` = ?",
|
||||||
AND (`nurl` = '%s' OR `alias` = '%s' OR `alias` = '%s')
|
Protocol::OSTATUS, Protocol::DFRN, Strings::normaliseLink($author_link), $author_link, Strings::normaliseLink($author_link), $importer['uid']]);
|
||||||
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'])
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!empty($r[0]['gsid'])) {
|
if (!empty($contact['gsid'])) {
|
||||||
GServer::setProtocol($r[0]['gsid'], Post\DeliveryData::OSTATUS);
|
GServer::setProtocol($contact['gsid'], Post\DeliveryData::OSTATUS);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Have we ignored the person?
|
// Have we ignored the person?
|
||||||
// If so we can not accept this post.
|
// If so we can not accept this post.
|
||||||
|
|
||||||
if (DBA::isResult($r) && $r[0]['blocked']) {
|
if (!empty($contact['blocked'])) {
|
||||||
Logger::log('Ignoring this author.');
|
Logger::notice('Ignoring this author.');
|
||||||
throw new \Friendica\Network\HTTPException\AcceptedException();
|
throw new \Friendica\Network\HTTPException\AcceptedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Placeholder for hub discovery.
|
// Placeholder for hub discovery.
|
||||||
$hub = '';
|
$hub = '';
|
||||||
|
|
||||||
$contact_rec = ((DBA::isResult($r)) ? $r[0] : []);
|
OStatus::import($data, $importer, $contact ?: [], $hub);
|
||||||
|
|
||||||
OStatus::import($data, $importer, $contact_rec, $hub);
|
|
||||||
|
|
||||||
throw new \Friendica\Network\HTTPException\OKException();
|
throw new \Friendica\Network\HTTPException\OKException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ use Friendica\Core\System;
|
||||||
use Friendica\Core\Worker;
|
use Friendica\Core\Worker;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
|
use Friendica\Model\Contact;
|
||||||
use Friendica\Model\Item;
|
use Friendica\Model\Item;
|
||||||
use Friendica\Model\Post;
|
use Friendica\Model\Post;
|
||||||
use Friendica\Model\Tag;
|
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);
|
$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]);
|
$item = Post::selectFirst([], ['id' => $item_id]);
|
||||||
|
|
||||||
if (!$item_id || !DBA::isResult($item)) {
|
if (!$item_id || !DBA::isResult($item)) {
|
||||||
Logger::log('tagger: no item ' . $item_id);
|
Logger::notice('tagger: no item ' . $item_id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$owner_uid = $item['uid'];
|
$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) {
|
if (local_user() != $owner_uid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = q("select * from contact where self = 1 and uid = %d limit 1",
|
$contact = Contact::selectFirst([], ['self' => true, 'uid' => local_user()]);
|
||||||
intval(local_user())
|
if (!DBA::isResult($contact)) {
|
||||||
);
|
Logger::notice('tagger: no contact_id');
|
||||||
if (DBA::isResult($r)) {
|
|
||||||
$contact = $r[0];
|
|
||||||
} else {
|
|
||||||
Logger::log('tagger: no contact_id');
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,11 +33,8 @@ function wall_attach_post(App $a) {
|
||||||
|
|
||||||
if (DI::args()->getArgc() > 1) {
|
if (DI::args()->getArgc() > 1) {
|
||||||
$nick = DI::args()->getArgv()[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",
|
$owner = User::getOwnerDataByNick($nick);
|
||||||
DBA::escape($nick)
|
if (!DBA::isResult($owner)) {
|
||||||
);
|
|
||||||
|
|
||||||
if (! DBA::isResult($r)) {
|
|
||||||
if ($r_json) {
|
if ($r_json) {
|
||||||
echo json_encode(['error' => DI::l10n()->t('Invalid request.')]);
|
echo json_encode(['error' => DI::l10n()->t('Invalid request.')]);
|
||||||
exit();
|
exit();
|
||||||
|
@ -55,22 +52,15 @@ function wall_attach_post(App $a) {
|
||||||
|
|
||||||
$can_post = false;
|
$can_post = false;
|
||||||
|
|
||||||
$page_owner_uid = $r[0]['uid'];
|
$page_owner_uid = $owner['uid'];
|
||||||
$page_owner_cid = $r[0]['id'];
|
$page_owner_cid = $owner['id'];
|
||||||
$community_page = (($r[0]['page-flags'] == User::PAGE_FLAGS_COMMUNITY) ? true : false);
|
$community_page = $owner['page-flags'] == User::PAGE_FLAGS_COMMUNITY;
|
||||||
|
|
||||||
if (local_user() && (local_user() == $page_owner_uid)) {
|
if (local_user() && (local_user() == $page_owner_uid)) {
|
||||||
$can_post = true;
|
$can_post = true;
|
||||||
} elseif ($community_page && !empty(Session::getRemoteContactID($page_owner_uid))) {
|
} elseif ($community_page && !empty(Session::getRemoteContactID($page_owner_uid))) {
|
||||||
$contact_id = 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",
|
$can_post = DBA::exists('contact', ['blocked' => false, 'pending' => false, 'id' => $contact_id, 'uid' => $page_owner_uid]);
|
||||||
intval($contact_id),
|
|
||||||
intval($page_owner_uid)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (DBA::isResult($r)) {
|
|
||||||
$can_post = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$can_post) {
|
if (!$can_post) {
|
||||||
|
|
|
@ -81,17 +81,8 @@ function wall_upload_post(App $a, $desktopmode = true)
|
||||||
$can_post = true;
|
$can_post = true;
|
||||||
} elseif ($community_page && !empty(Session::getRemoteContactID($page_owner_uid))) {
|
} elseif ($community_page && !empty(Session::getRemoteContactID($page_owner_uid))) {
|
||||||
$contact_id = Session::getRemoteContactID($page_owner_uid);
|
$contact_id = Session::getRemoteContactID($page_owner_uid);
|
||||||
|
$can_post = DBA::exists('contact', ['blocked' => false, 'pending' => false, 'id' => $contact_id, 'uid' => $page_owner_uid]);
|
||||||
$r = q("SELECT `uid` FROM `contact`
|
$visitor = $contact_id;
|
||||||
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;
|
|
||||||
$visitor = $contact_id;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$can_post) {
|
if (!$can_post) {
|
||||||
|
|
Loading…
Reference in a new issue