]> git.mxchange.org Git - friendica.git/commitdiff
pass notify endpoint with friend suggestions
authorFriendika <info@friendika.com>
Mon, 27 Jun 2011 02:30:57 +0000 (19:30 -0700)
committerFriendika <info@friendika.com>
Mon, 27 Jun 2011 02:30:57 +0000 (19:30 -0700)
boot.php
database.sql
include/notifier.php
mod/dfrn_notify.php
update.php
view/atom_suggest.tpl

index f2c9474011594dcce38cc76ccd57e5be16c7ebae..0bab002eddce7528f3e81196c178e580c18d5a55 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -6,7 +6,7 @@ ini_set('pcre.backtrack_limit', 250000);
 
 define ( 'FRIENDIKA_VERSION',      '2.2.1023' );
 define ( 'DFRN_PROTOCOL_VERSION',  '2.21'    );
-define ( 'DB_UPDATE_VERSION',      1069      );
+define ( 'DB_UPDATE_VERSION',      1070      );
 
 define ( 'EOL',                    "<br />\r\n"     );
 define ( 'ATOM_TIME',              'Y-m-d\TH:i:s\Z' );
index b33c0cdcb6b69ecf192bb2935bbf4be45fa73549..df99ca7f6cbb8a7cff634bbd3b2d51d8d7e2abd3 100644 (file)
@@ -509,7 +509,8 @@ CREATE TABLE IF NOT EXISTS `fcontact` (
 `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
 `url` CHAR( 255 ) NOT NULL ,
 `name` CHAR( 255 ) NOT NULL ,
-`photo` CHAR( 255 ) NOT NULL
+`photo` CHAR( 255 ) NOT NULL ,
+`request` CHAR( 255 ) NOT NULL
 ) ENGINE = MYISAM DEFAULT CHARSET=utf8;
 
 CREATE TABLE IF NOT EXISTS `ffinder` (
@@ -526,6 +527,7 @@ CREATE TABLE IF NOT EXISTS `fsuggest` (
 `cid` INT NOT NULL ,
 `name` CHAR( 255 ) NOT NULL ,
 `url` CHAR( 255 ) NOT NULL ,
+`request` CHAR( 255 ) NOT NULL,
 `photo` CHAR( 255 ) NOT NULL ,
 `note` TEXT NOT NULL ,
 `created` DATETIME NOT NULL
index 842e1108093d7cc5acf5bd06b5c094f6f866b0b3..d9f9038533c9b1638e4a31d6edcaec886ff71a6b 100644 (file)
@@ -71,6 +71,16 @@ function notifier_run($argv, $argc){
                if(! count($items))
                        return;
        }
+       elseif($cmd === 'suggest') {
+               $suggest = q("SELECT * FROM `fsuggest` WHERE `id` = %d LIMIT 1",
+                       intval($item_id)
+               );
+               if(! count($suggest))
+                       return;
+               $uid = $suggest[0]['uid'];
+               $recipients[] = $suggest[0]['cid'];
+               $item = $suggest[0];
+       }
        else {
 
                // find ancestors
@@ -126,7 +136,7 @@ function notifier_run($argv, $argc){
        // fill this in with a single salmon slap if applicable
        $slap = '';
 
-       if($cmd != 'mail') {
+       if($cmd != 'mail' && $cmd != 'suggest') {
 
                require_once('include/group.php');
 
@@ -236,6 +246,26 @@ function notifier_run($argv, $argc){
                        '$parent_id'    => xmlify($item['parent-uri'])
                ));
        }
+       elseif($cmd === 'suggest') {
+               $notify_hub = false;  // suggestions are not public
+
+               $sugg_template = get_markup_template('atom_suggest.tpl');
+
+               $atom .= replace_macros($sugg_template, array(
+                       '$name'         => xmlify($item['name']),
+                       '$url'          => xmlify($item['url']),
+                       '$photo'        => xmlify($item['photo']),
+                       '$request'      => xmlify($item['request']),
+                       '$note'         => xmlify($item['note'])
+               ));
+
+               // We don't need this any more
+
+               q("DELETE FROM `fsuggest` WHERE `id` = %d LIMIT 1",
+                       intval($item['id'])
+               );
+
+       }
        else {
                if($followup) {
                        foreach($items as $item) {  // there is only one item
index 6cb4f69a0f731ebabc9457d66894167d8c4509e2..31314da7b20fa62911de5d28eda4cdf6d46d6287 100644 (file)
@@ -165,6 +165,7 @@ function dfrn_notify_post(&$a) {
                $fsugg['name'] = notags(unxmlify($base['name'][0]['data']));
                $fsugg['photo'] = notags(unxmlify($base['photo'][0]['data']));
                $fsugg['url'] = notags(unxmlify($base['url'][0]['data']));
+               $fsugg['request'] = notags(unxmlify($base['request'][0]['data']));
                $fsugg['body'] = escape_tags(unxmlify($base['note'][0]['data']));
 
                // Does our member already have a friend matching this description?
@@ -180,24 +181,25 @@ function dfrn_notify_post(&$a) {
                // Do we already have an fcontact record for this person?
 
                $fid = 0;
-               $r = q("SELECT * FROM `fcontact` WHERE `url` = '%s' AND `name` = '%s' AND `photo` = '%s' LIMIT 1",
+               $r = q("SELECT * FROM `fcontact` WHERE `url` = '%s' AND `name` = '%s' AND `request` = '%s' LIMIT 1",
                        dbesc($fsugg['url']),
                        dbesc($fsugg['name']),
-                       dbesc($fsugg['photo'])
+                       dbesc($fsugg['request'])
                );
                if(count($r)) {
                        $fid = $r[0]['id'];
                }
                if(! $fid)
-                       $r = q("INSERT INTO `fcontact` ( `name`,`url`,`photo` ) VALUES ( '%s', '%s', '%s' ) ",
+                       $r = q("INSERT INTO `fcontact` ( `name`,`url`,`photo`,`request` ) VALUES ( '%s', '%s', '%s', '%s' ) ",
                        dbesc($fsugg['name']),
                        dbesc($fsugg['url']),
-                       dbesc($fsugg['photo'])
+                       dbesc($fsugg['photo']),
+                       dbesc($fsugg['request'])
                );
-               $r = q("SELECT * FROM `fcontact` WHERE `url` = '%s' AND `name` = '%s' AND `photo` = '%s' LIMIT 1",
+               $r = q("SELECT * FROM `fcontact` WHERE `url` = '%s' AND `name` = '%s' AND `request` = '%s' LIMIT 1",
                        dbesc($fsugg['url']),
                        dbesc($fsugg['name']),
-                       dbesc($fsugg['photo'])
+                       dbesc($fsugg['request'])
                );
                if(count($r)) {
                        $fid = $r[0]['id'];
index 2e22b9d1cc85858b74a7e920acad9588574a183e..ce8c694cab50cb1914640829323579a1148d689c 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-define( 'UPDATE_VERSION' , 1069 );
+define( 'UPDATE_VERSION' , 1070 );
 
 /**
  *
@@ -561,4 +561,7 @@ function update_1068() {
 
 }
 
-
+function update_1069() {
+       q("ALTER TABLE `fsuggest` ADD `request` CHAR( 255 ) NOT NULL AFTER `url` ");
+       q("ALTER TABLE `fcontact` ADD `request` CHAR( 255 ) NOT NULL AFTER `photo` ");
+}
index 8df011bfd35e818f08a7589a9ab4231ea5339ea4..66c61f9b6e6beddffae01836e9c6986b020c657e 100644 (file)
@@ -4,6 +4,7 @@
        <dfrn:url>$url</dfrn:url>
        <dfrn:name>$name</dfrn:name>
        <dfrn:photo>$photo</dfrn:photo>
+       <dfrn:request>$request</dfrn:request>
        <dfrn:note>$note</dfrn:note>
 
 </dfrn:suggest>