Merge pull request #3649 from annando/pleroma2
Enhanced OStatus compatibility
This commit is contained in:
commit
32a8a28b2c
8 changed files with 43 additions and 22 deletions
|
@ -504,7 +504,7 @@ class dfrn {
|
|||
|
||||
if ($public) {
|
||||
// DFRN itself doesn't uses this. But maybe someone else wants to subscribe to the public feed.
|
||||
ostatus::hublinks($doc, $root);
|
||||
ostatus::hublinks($doc, $root, $owner["nick"]);
|
||||
|
||||
$attributes = array("rel" => "salmon", "href" => App::get_baseurl()."/salmon/".$owner["nick"]);
|
||||
xml::add_element($doc, $root, "link", "", $attributes);
|
||||
|
|
|
@ -1470,7 +1470,7 @@ class ostatus {
|
|||
/// "type" => "application/json");
|
||||
/// xml::add_element($doc, $root, "link", "", $attributes);
|
||||
|
||||
self::hublinks($doc, $root);
|
||||
self::hublinks($doc, $root, $owner["nick"]);
|
||||
|
||||
$attributes = array("href" => App::get_baseurl()."/salmon/".$owner["nick"], "rel" => "salmon");
|
||||
xml::add_element($doc, $root, "link", "", $attributes);
|
||||
|
@ -1494,7 +1494,7 @@ class ostatus {
|
|||
* @param object $doc XML document
|
||||
* @param object $root XML root element where the hub links are added
|
||||
*/
|
||||
public static function hublinks($doc, $root) {
|
||||
public static function hublinks($doc, $root, $nick) {
|
||||
$hub = get_config('system','huburl');
|
||||
|
||||
$hubxml = '';
|
||||
|
@ -1505,8 +1505,9 @@ class ostatus {
|
|||
$h = trim($h);
|
||||
if (! strlen($h))
|
||||
continue;
|
||||
if ($h === '[internal]')
|
||||
$h = App::get_baseurl() . '/pubsubhubbub';
|
||||
if ($h === '[internal]') {
|
||||
$h = App::get_baseurl() . '/pubsubhubbub/'.$nick;
|
||||
}
|
||||
xml::add_element($doc, $root, "link", "", array("href" => $h, "rel" => "hub"));
|
||||
}
|
||||
}
|
||||
|
@ -2226,10 +2227,11 @@ class ostatus {
|
|||
* @param App $a The application class
|
||||
* @param string $owner_nick Nickname of the feed owner
|
||||
* @param string $last_update Date of the last update
|
||||
* @param integer $max_items Number of maximum items to fetch
|
||||
*
|
||||
* @return string XML feed
|
||||
*/
|
||||
public static function feed(App $a, $owner_nick, &$last_update) {
|
||||
public static function feed(App $a, $owner_nick, &$last_update, $max_items = 300) {
|
||||
$stamp = microtime(true);
|
||||
|
||||
$cachekey = "ostatus:feed:".$owner_nick.":".$last_update;
|
||||
|
@ -2266,10 +2268,10 @@ class ostatus {
|
|||
`item`.`author-id` = %d AND `item`.`created` > '%s' AND
|
||||
NOT `item`.`deleted` AND NOT `item`.`private` AND
|
||||
`thread`.`network` IN ('%s', '%s')
|
||||
ORDER BY `item`.`created` DESC LIMIT 300",
|
||||
ORDER BY `item`.`created` DESC LIMIT %d",
|
||||
intval($owner["uid"]), intval($owner["id"]),
|
||||
intval($authorid), dbesc($check_date),
|
||||
dbesc(NETWORK_OSTATUS), dbesc(NETWORK_DFRN));
|
||||
dbesc(NETWORK_OSTATUS), dbesc(NETWORK_DFRN), intval($max_items));
|
||||
|
||||
$doc = new DOMDocument('1.0', 'utf-8');
|
||||
$doc->formatOutput = true;
|
||||
|
|
|
@ -54,7 +54,7 @@ function handle_pubsubhubbub($id) {
|
|||
|
||||
$headers = array("Content-type: application/atom+xml",
|
||||
sprintf("Link: <%s>;rel=hub,<%s>;rel=self",
|
||||
App::get_baseurl().'/pubsubhubbub',
|
||||
App::get_baseurl().'/pubsubhubbub/'.$rr['nickname'],
|
||||
$rr['topic']),
|
||||
"X-Hub-Signature: sha1=".$hmac_sig);
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ use Friendica\Core\Config;
|
|||
|
||||
require_once("mod/hostxrd.php");
|
||||
require_once("mod/nodeinfo.php");
|
||||
require_once("mod/xrd.php");
|
||||
|
||||
function _well_known_init(App $a) {
|
||||
if ($a->argc > 1) {
|
||||
|
@ -18,6 +19,9 @@ function _well_known_init(App $a) {
|
|||
case "nodeinfo":
|
||||
nodeinfo_wellknown($a);
|
||||
break;
|
||||
case "webfinger":
|
||||
xrd_init($a);
|
||||
break;
|
||||
}
|
||||
}
|
||||
http_status_exit(404);
|
||||
|
|
|
@ -5,6 +5,7 @@ use Friendica\App;
|
|||
require_once('include/items.php');
|
||||
require_once('include/auth.php');
|
||||
require_once('include/dfrn.php');
|
||||
require_once('include/ostatus.php');
|
||||
|
||||
function dfrn_poll_init(App $a) {
|
||||
$dfrn_id = ((x($_GET,'dfrn_id')) ? $_GET['dfrn_id'] : '');
|
||||
|
@ -17,6 +18,14 @@ function dfrn_poll_init(App $a) {
|
|||
$perm = ((x($_GET,'perm')) ? $_GET['perm'] : 'r');
|
||||
$quiet = ((x($_GET,'quiet')) ? true : false);
|
||||
|
||||
// Possibly it is an OStatus compatible server that requests a user feed
|
||||
if (($a->argc > 1) && ($dfrn_id == '') && !strstr($_SERVER["HTTP_USER_AGENT"], 'Friendica')) {
|
||||
$nickname = $a->argv[1];
|
||||
header("Content-type: application/atom+xml");
|
||||
echo ostatus::feed($a, $nickname, $last_update, 10);
|
||||
killme();
|
||||
}
|
||||
|
||||
$direction = (-1);
|
||||
|
||||
|
||||
|
|
|
@ -160,6 +160,3 @@ function pubsub_post(App $a) {
|
|||
hub_post_return();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -44,9 +44,14 @@ function pubsubhubbub_init(App $a) {
|
|||
logger("pubsubhubbub: $hub_mode request from " .
|
||||
$_SERVER['REMOTE_ADDR']);
|
||||
|
||||
// get the nick name from the topic, a bit hacky but needed
|
||||
// get the nick name from the topic, a bit hacky but needed as a fallback
|
||||
$nick = substr(strrchr($hub_topic, "/"), 1);
|
||||
|
||||
// Normally the url should now contain the nick name as last part of the url
|
||||
if ($a->argc > 1) {
|
||||
$nick = $a->argv[1];
|
||||
}
|
||||
|
||||
if (!$nick) {
|
||||
logger('pubsubhubbub: bad hub_topic=$hub_topic, ignoring.');
|
||||
http_status_exit(404);
|
||||
|
|
|
@ -8,6 +8,10 @@ function xrd_init(App $a) {
|
|||
|
||||
$uri = urldecode(notags(trim($_GET['uri'])));
|
||||
|
||||
if ($uri == "") {
|
||||
$uri = urldecode(notags(trim($_GET['resource'])));
|
||||
}
|
||||
|
||||
if(substr($uri,0,4) === 'http') {
|
||||
$acct = false;
|
||||
$name = basename($uri);
|
||||
|
|
Loading…
Reference in a new issue