]> git.mxchange.org Git - friendica.git/commitdiff
infrastructure for salmon
authorMike Macgirvin <mike@macgirvin.com>
Thu, 7 Oct 2010 02:46:44 +0000 (19:46 -0700)
committerMike Macgirvin <mike@macgirvin.com>
Thu, 7 Oct 2010 02:46:44 +0000 (19:46 -0700)
boot.php
include/items.php
include/notifier.php
mod/pubsub.php
mod/salmon.php [new file with mode: 0644]
mod/xrd.php
view/atom_feed.tpl
view/xrd_person.tpl

index 194ee6a01b02a5064fc90038f01654c55cefe84f..8e42c5fadb6b9a0fbea59dde8ee4a6026c8db1a6 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -28,6 +28,7 @@ define ( 'NAMESPACE_THREAD' ,         'http://purl.org/syndication/thread/1.0' )
 define ( 'NAMESPACE_TOMB' ,           'http://purl.org/atompub/tombstones/1.0' );
 define ( 'NAMESPACE_ACTIVITY',        'http://activitystrea.ms/spec/1.0/' );
 define ( 'NAMESPACE_ACTIVITY_SCHEMA', 'http://activitystrea.ms/schema/1.0/');
+define ( 'NAMESPACE_SALMON_ME',       'http://salmon-protocol.org/ns/magic-env');
 
 define ( 'ACTIVITY_LIKE',        NAMESPACE_ACTIVITY_SCHEMA . 'like' );
 define ( 'ACTIVITY_DISLIKE',     NAMESPACE_DFRN            . '/dislike' );
index 799af48ac18004f90cf619541073f5e23f5ae08a..e4376fbeeb9408d2e83642906f2a87e4b68c1e18 100644 (file)
@@ -127,12 +127,15 @@ function get_feed_for(&$a, $dfrn_id, $owner_id, $last_update, $direction = 0) {
 
        $hubxml = ((strlen($hub)) ? '<link rel="hub" href="' . xmlify($hub) . '" />' . "\n" : '');
 
+       $salmon = '<link rel="salmon" href="' . xmlify($a->get_baseurl() . '/salmon/' . $owner_nick) . '" />' . "\n" ; 
+       $salmon = ''; // remove this line when salmon handler is finished
 
        $atom .= replace_macros($feed_template, array(
                '$feed_id'      => xmlify($a->get_baseurl() . '/profile/' . $owner_nick),
                '$feed_title'   => xmlify($owner['name']),
                '$feed_updated' => xmlify(datetime_convert('UTC', 'UTC', $updated . '+00:00' , ATOM_TIME)) ,
                '$hub'          => $hubxml,
+               '$salmon'       => $salmon,
                '$name'         => xmlify($owner['name']),
                '$profile_page' => xmlify($owner['url']),
                '$photo'        => xmlify($owner['photo']),
index f7d2844c376b2087e5f821b2a3779ffbf0021e69..ce4e5fed4abe54b67489b9576799860981802661 100644 (file)
                        '$feed_title'   => xmlify($owner['name']),
                        '$feed_updated' => xmlify(datetime_convert('UTC', 'UTC', $updated . '+00:00' , ATOM_TIME)) ,
                        '$hub'          => $hubxml,
+                       '$salmon'       => '',   // private feed, we don't use salmon here
                        '$name'         => xmlify($owner['name']),
                        '$profile_page' => xmlify($owner['url']),
                        '$photo'        => xmlify($owner['photo']),
index 1feb80031028ba37a91a6d1b6ff53d73c564bb55..7dea2afb13676cc32c5ba78c95c37059a92ac8c6 100644 (file)
@@ -87,7 +87,7 @@ function pubsub_post(&$a) {
 
        $debugging = get_config('system','debugging');
        if($debugging)
-               file_put_contents('pubsub.out',$xml);
+               file_put_contents('pubsub.out',$xml,FILE_APPEND);
 
        $nick       = (($a->argc > 1) ? notags(trim($a->argv[1])) : '');
        $contact_id = (($a->argc > 2) ? intval($a->argv[2]) : 0);
diff --git a/mod/salmon.php b/mod/salmon.php
new file mode 100644 (file)
index 0000000..d68c746
--- /dev/null
@@ -0,0 +1,52 @@
+<?php
+
+function salmon_return($val) {
+
+       if($val >= 500)
+               $err = 'Error';
+       if($val == 200)
+               $err = 'OK';
+       
+       header($_SERVER["SERVER_PROTOCOL"] . ' ' . $val . ' ' . $err);
+       killme();
+
+}
+
+function salmon_post(&$a) {
+
+       $xml = file_get_contents('php://input');
+       
+       $debugging = get_config('system','debugging');
+       if($debugging)
+               file_put_contents('salmon.out',$xml,FILE_APPEND);
+
+       $nick       = (($a->argc > 1) ? notags(trim($a->argv[1])) : '');
+       $mentions   = (($a->argc > 2 && $a->argv[2] === 'mention') ? true : false);
+
+       $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' LIMIT 1",
+               dbesc($nick)
+       );
+       if(! count($r))
+               salmon_return(500);
+
+       $importer = $r[0];
+
+       require_once('include/items.php');
+
+       // Create a fake feed wrapper so simplepie doesn't choke
+
+       $tpl = load_view_file('view/atom_feed.tpl');
+       
+       $base = substr($xml,strpos($xml,'<entry'));
+
+       $xml = $tpl . $base . '</feed>';
+
+salmon_return(500); // until the handler is finished
+
+//     consume_salmon($xml,$importer);
+
+       salmon_return(200);
+}
+
+
+
index e60fda48dd5a6b7052aff1aff0ba754debb3851f..d36b47519be6cb00a9cb152d0b13439c52eee142 100644 (file)
@@ -21,7 +21,8 @@ function xrd_content(&$a) {
        $o = replace_macros($tpl, array(
                '$accturi' => $uri,
                '$profile_url' => $a->get_baseurl() . '/profile/' . $r[0]['nickname'],
-               '$photo' => $a->get_baseurl() . '/photo/profile/' . $r[0]['uid']
+               '$photo' => $a->get_baseurl() . '/photo/profile/' . $r[0]['uid'],
+               '$salmon' => $a->get_baseurl() . '/salmon/' . $r[0]['nickname'] . '/mention'
        ));
 
        echo $o;
index 893d42036f84e0f7fe49c996602672d3d3414888..7918c0d0968cf05c7eca5de95de8b23cc918e0b9 100644 (file)
@@ -11,6 +11,7 @@
   <generator uri="http://mistpark.com" version="2.0">Mistpark</generator>
   <link rel="license" href="http://creativecommons.org/licenses/by/3.0/" />
   $hub
+  $salmon
 
   <updated>$feed_updated</updated>
 
index 12106216065d09e281130cc3e0c844aa3168f6e6..b559bfadcd85a8ca4ceb0c1afdc7f4da1c04ad9b 100644 (file)
@@ -14,4 +14,6 @@
           href='$profile_url' />
     <Link rel='http://webfinger.net/rel/avatar'
           href='$photo' />
+    <Link rel="salmon" href="$salmon" />
+
 </XRD>