Browse Source

pass notify endpoint with friend suggestions

pull/1/head
Friendika 9 years ago
parent
commit
3fe1e19725
6 changed files with 49 additions and 11 deletions
  1. +1
    -1
      boot.php
  2. +3
    -1
      database.sql
  3. +31
    -1
      include/notifier.php
  4. +8
    -6
      mod/dfrn_notify.php
  5. +5
    -2
      update.php
  6. +1
    -0
      view/atom_suggest.tpl

+ 1
- 1
boot.php View File

@ -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' );


+ 3
- 1
database.sql View 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


+ 31
- 1
include/notifier.php View 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


+ 8
- 6
mod/dfrn_notify.php View 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'];


+ 5
- 2
update.php View 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` ");
}

+ 1
- 0
view/atom_suggest.tpl View 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>


Loading…
Cancel
Save