D* queue
This commit is contained in:
parent
2cfdcee29a
commit
2aa23843e4
36
database.sql
36
database.sql
|
@ -38,7 +38,7 @@ CREATE TABLE IF NOT EXISTS `config` (
|
|||
`k` char(255) NOT NULL,
|
||||
`v` text NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MYISAM DEFAULT CHARSET=utf8;
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
|
||||
|
@ -428,7 +428,7 @@ CREATE TABLE IF NOT EXISTS `register` (
|
|||
`password` CHAR(255) NOT NULL,
|
||||
`language` CHAR(16) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE = MYISAM DEFAULT CHARSET=utf8;
|
||||
) ENGINE = MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `clients` (
|
||||
|
@ -436,7 +436,7 @@ CREATE TABLE IF NOT EXISTS `clients` (
|
|||
`pw` VARCHAR( 20 ) NOT NULL ,
|
||||
`redirect_uri` VARCHAR( 200 ) NOT NULL ,
|
||||
PRIMARY KEY ( `client_id` )
|
||||
) ENGINE = MYISAM DEFAULT CHARSET=utf8;
|
||||
) ENGINE = MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tokens` (
|
||||
`id` VARCHAR( 40 ) NOT NULL ,
|
||||
|
@ -444,7 +444,7 @@ CREATE TABLE IF NOT EXISTS `tokens` (
|
|||
`expires` INT NOT NULL ,
|
||||
`scope` VARCHAR( 200 ) NOT NULL ,
|
||||
PRIMARY KEY ( `id` )
|
||||
) ENGINE = MYISAM DEFAULT CHARSET=utf8;
|
||||
) ENGINE = MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `auth_codes` (
|
||||
`id` VARCHAR( 40 ) NOT NULL ,
|
||||
|
@ -453,7 +453,7 @@ CREATE TABLE IF NOT EXISTS `auth_codes` (
|
|||
`expires` INT NOT NULL ,
|
||||
`scope` VARCHAR( 250 ) NOT NULL ,
|
||||
PRIMARY KEY ( `id` )
|
||||
) ENGINE = MYISAM DEFAULT CHARSET=utf8;
|
||||
) ENGINE = MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `queue` (
|
||||
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
|
||||
|
@ -462,7 +462,7 @@ CREATE TABLE IF NOT EXISTS `queue` (
|
|||
`created` DATETIME NOT NULL ,
|
||||
`last` DATETIME NOT NULL ,
|
||||
`content` MEDIUMTEXT NOT NULL
|
||||
) ENGINE = MYISAM DEFAULT CHARSET=utf8;
|
||||
) ENGINE = MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `pconfig` (
|
||||
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
|
||||
|
@ -470,7 +470,7 @@ CREATE TABLE IF NOT EXISTS `pconfig` (
|
|||
`cat` CHAR( 255 ) NOT NULL ,
|
||||
`k` CHAR( 255 ) NOT NULL ,
|
||||
`v` MEDIUMTEXT NOT NULL
|
||||
) ENGINE = MYISAM DEFAULT CHARSET=utf8;
|
||||
) ENGINE = MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `hook` (
|
||||
|
@ -478,7 +478,7 @@ CREATE TABLE IF NOT EXISTS `hook` (
|
|||
`hook` CHAR( 255 ) NOT NULL ,
|
||||
`file` CHAR( 255 ) NOT NULL ,
|
||||
`function` CHAR( 255 ) NOT NULL
|
||||
) ENGINE = MYISAM DEFAULT CHARSET=utf8;
|
||||
) ENGINE = MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `addon` (
|
||||
|
@ -488,7 +488,7 @@ CREATE TABLE IF NOT EXISTS `addon` (
|
|||
`installed` TINYINT( 1 ) NOT NULL DEFAULT '0' ,
|
||||
`timestamp` BIGINT NOT NULL DEFAULT '0' ,
|
||||
`plugin_admin` TINYINT( 1 ) NOT NULL DEFAULT '0'
|
||||
) ENGINE = MYISAM DEFAULT CHARSET=utf8;
|
||||
) ENGINE = MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `event` (
|
||||
|
@ -509,13 +509,13 @@ CREATE TABLE IF NOT EXISTS `event` (
|
|||
`allow_gid` MEDIUMTEXT NOT NULL ,
|
||||
`deny_cid` MEDIUMTEXT NOT NULL ,
|
||||
`deny_gid` MEDIUMTEXT NOT NULL
|
||||
) ENGINE = MYISAM DEFAULT CHARSET=utf8;
|
||||
) ENGINE = MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `cache` (
|
||||
`k` CHAR( 255 ) NOT NULL PRIMARY KEY ,
|
||||
`v` TEXT NOT NULL,
|
||||
`updated` DATETIME NOT NULL
|
||||
) ENGINE = MYISAM DEFAULT CHARSET=utf8;
|
||||
) ENGINE = MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `fcontact` (
|
||||
|
@ -536,14 +536,14 @@ CREATE TABLE IF NOT EXISTS `fcontact` (
|
|||
`updated` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||
INDEX ( `addr` ),
|
||||
INDEX ( `network` )
|
||||
) ENGINE = MYISAM DEFAULT CHARSET=utf8;
|
||||
) ENGINE = MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `ffinder` (
|
||||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
|
||||
`uid` INT UNSIGNED NOT NULL ,
|
||||
`cid` INT UNSIGNED NOT NULL ,
|
||||
`fid` INT UNSIGNED NOT NULL
|
||||
) ENGINE = MYISAM DEFAULT CHARSET=utf8;
|
||||
) ENGINE = MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `fsuggest` (
|
||||
|
@ -556,7 +556,7 @@ CREATE TABLE IF NOT EXISTS `fsuggest` (
|
|||
`photo` CHAR( 255 ) NOT NULL ,
|
||||
`note` TEXT NOT NULL ,
|
||||
`created` DATETIME NOT NULL
|
||||
) ENGINE = MYISAM DEFAULT CHARSET=utf8;
|
||||
) ENGINE = MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `mailacct` (
|
||||
|
@ -571,7 +571,7 @@ CREATE TABLE IF NOT EXISTS `mailacct` (
|
|||
`reply_to` CHAR( 255 ) NOT NULL ,
|
||||
`pubmail` TINYINT(1) NOT NULL DEFAULT '0',
|
||||
`last_check` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'
|
||||
) ENGINE = MYISAM DEFAULT CHARSET=utf8;
|
||||
) ENGINE = MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `attach` (
|
||||
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
|
||||
|
@ -587,13 +587,13 @@ CREATE TABLE IF NOT EXISTS `attach` (
|
|||
`allow_gid` MEDIUMTEXT NOT NULL ,
|
||||
`deny_cid` MEDIUMTEXT NOT NULL ,
|
||||
`deny_gid` MEDIUMTEXT NOT NULL
|
||||
) ENGINE = MYISAM DEFAULT CHARSET=utf8;
|
||||
) ENGINE = MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `guid` (
|
||||
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
|
||||
`guid` CHAR( 64 ) NOT NULL ,
|
||||
INDEX ( `guid` )
|
||||
) ENGINE = MYISAM DEFAULT CHARSET=utf8;
|
||||
) ENGINE = MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `sign` (
|
||||
|
@ -603,6 +603,6 @@ CREATE TABLE IF NOT EXISTS `sign` (
|
|||
`signature` TEXT NOT NULL ,
|
||||
`signer` CHAR( 255 ) NOT NULL ,
|
||||
INDEX ( `iid` )
|
||||
) ENGINE = MYISAM DEFAULT CHARSET=utf8;
|
||||
) ENGINE = MyISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
|
|
|
@ -4,6 +4,36 @@ require_once('include/crypto.php');
|
|||
require_once('include/items.php');
|
||||
require_once('include/bb2diaspora.php');
|
||||
|
||||
function diaspora_dispatch($importer,$msg) {
|
||||
|
||||
$parsed_xml = parse_xml_string($msg['message'],false);
|
||||
|
||||
$xmlbase = $parsed_xml->post;
|
||||
|
||||
if($xmlbase->request) {
|
||||
diaspora_request($importer,$xmlbase->request);
|
||||
}
|
||||
elseif($xmlbase->status_message) {
|
||||
diaspora_post($importer,$xmlbase->status_message);
|
||||
}
|
||||
elseif($xmlbase->comment) {
|
||||
diaspora_comment($importer,$xmlbase->comment,$msg);
|
||||
}
|
||||
elseif($xmlbase->like) {
|
||||
diaspora_like($importer,$xmlbase->like,$msg);
|
||||
}
|
||||
elseif($xmlbase->retraction) {
|
||||
diaspora_retraction($importer,$xmlbase->retraction,$msg);
|
||||
}
|
||||
elseif($xmlbase->photo) {
|
||||
diaspora_photo($importer,$xmlbase->photo,$msg);
|
||||
}
|
||||
else {
|
||||
logger('diaspora_dispatch: unknown message type: ' . print_r($xmlbase,true));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
function diaspora_get_contact_by_handle($uid,$handle) {
|
||||
$r = q("SELECT * FROM `contact` WHERE `network` = '%s' AND `uid` = %d AND `addr` = '%s' LIMIT 1",
|
||||
dbesc(NETWORK_DIASPORA),
|
||||
|
@ -866,10 +896,7 @@ function diaspora_share($me,$contact) {
|
|||
|
||||
$slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$me,$contact,$me['prvkey'],$contact['pubkey'])));
|
||||
|
||||
post_url($contact['notify'] . '/',$slap);
|
||||
$return_code = $a->get_curl_code();
|
||||
logger('diaspora_send_share: returns: ' . $return_code);
|
||||
return $return_code;
|
||||
return(diaspora_transmit($owner,$contact,$slap));
|
||||
}
|
||||
|
||||
function diaspora_unshare($me,$contact) {
|
||||
|
@ -886,10 +913,8 @@ function diaspora_unshare($me,$contact) {
|
|||
|
||||
$slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$me,$contact,$me['prvkey'],$contact['pubkey'])));
|
||||
|
||||
post_url($contact['notify'] . '/',$slap);
|
||||
$return_code = $a->get_curl_code();
|
||||
logger('diaspora_send_unshare: returns: ' . $return_code);
|
||||
return $return_code;
|
||||
return(diaspora_transmit($owner,$contact,$slap));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -937,9 +962,7 @@ function diaspora_send_status($item,$owner,$contact) {
|
|||
|
||||
$slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'])));
|
||||
|
||||
post_url($contact['notify'] . '/',$slap);
|
||||
$return_code = $a->get_curl_code();
|
||||
logger('diaspora_send_status: returns: ' . $return_code);
|
||||
$return_code = diaspora_transmit($owner,$contact,$slap);
|
||||
|
||||
if(count($images)) {
|
||||
diaspora_send_images($item,$owner,$contact,$images);
|
||||
|
@ -979,12 +1002,11 @@ function diaspora_send_images($item,$owner,$contact,$images) {
|
|||
'$created_at' => xmlify(datetime_convert('UTC','UTC',$r[0]['created'],'Y-m-d h:i:s \U\T\C'))
|
||||
));
|
||||
|
||||
|
||||
logger('diaspora_send_photo: base message: ' . $msg, LOGGER_DATA);
|
||||
$slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'])));
|
||||
|
||||
post_url($contact['notify'] . '/',$slap);
|
||||
$return_code = $a->get_curl_code();
|
||||
logger('diaspora_send_photo: returns: ' . $return_code);
|
||||
diaspora_transmit($owner,$contact,$slap);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1039,11 +1061,7 @@ function diaspora_send_followup($item,$owner,$contact) {
|
|||
|
||||
$slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'])));
|
||||
|
||||
post_url($contact['notify'] . '/',$slap);
|
||||
$return_code = $a->get_curl_code();
|
||||
logger('diaspora_send_followup: returns: ' . $return_code);
|
||||
return $return_code;
|
||||
|
||||
return(diaspora_transmit($owner,$contact,$slap));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1115,10 +1133,7 @@ function diaspora_send_relay($item,$owner,$contact) {
|
|||
|
||||
$slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'])));
|
||||
|
||||
post_url($contact['notify'] . '/',$slap);
|
||||
$return_code = $a->get_curl_code();
|
||||
logger('diaspora_send_relay: returns: ' . $return_code);
|
||||
return $return_code;
|
||||
return(diaspora_transmit($owner,$contact,$slap));
|
||||
|
||||
}
|
||||
|
||||
|
@ -1138,9 +1153,30 @@ function diaspora_send_retraction($item,$owner,$contact) {
|
|||
|
||||
$slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'])));
|
||||
|
||||
return(diaspora_transmit($owner,$contact,$slap));
|
||||
}
|
||||
|
||||
|
||||
|
||||
function diaspora_transmit($owner,$contact,$slap) {
|
||||
|
||||
$a = get_app();
|
||||
|
||||
post_url($contact['notify'] . '/',$slap);
|
||||
$return_code = $a->get_curl_code();
|
||||
logger('diaspora_send_retraction: returns: ' . $return_code);
|
||||
return $return_code;
|
||||
logger('diaspora_transmit: returns: ' . $return_code);
|
||||
|
||||
}
|
||||
if(! $return_code) {
|
||||
logger('diaspora_transmit: queue message');
|
||||
// queue message for redelivery
|
||||
q("INSERT INTO `queue` ( `cid`, `created`, `last`, `content`)
|
||||
VALUES ( %d, '%s', '%s', '%s') ",
|
||||
intval($contact['id']),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc($slap)
|
||||
);
|
||||
}
|
||||
|
||||
return(($return_code) ? $return_code : (-1));
|
||||
}
|
||||
|
|
|
@ -56,6 +56,7 @@ function queue_run($argv, $argc){
|
|||
// delivery loop
|
||||
|
||||
require_once('include/salmon.php');
|
||||
require_once('include/diaspora.php');
|
||||
|
||||
foreach($r as $q_item) {
|
||||
|
||||
|
@ -120,6 +121,18 @@ function queue_run($argv, $argc){
|
|||
remove_queue_item($q_item['id']);
|
||||
}
|
||||
break;
|
||||
case NETWORK_DIASPORA:
|
||||
if($contact['notify']) {
|
||||
logger('queue: diaspora_delivery: item ' . $q_item['id'] . ' for ' . $contact['name']);
|
||||
$deliver_status = diaspora_transmit($owner,$contact['notify'],$data);
|
||||
|
||||
if($deliver_status == (-1))
|
||||
update_queue_time($q_item['id']);
|
||||
else
|
||||
remove_queue_item($q_item['id']);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$params = array('owner' => $owner, 'contact' => $contact, 'queue' => $q_item, 'result' => false);
|
||||
call_hooks('queue_deliver', $a, $params);
|
||||
|
|
|
@ -15,8 +15,6 @@ function receive_post(&$a) {
|
|||
if($a->argc != 3 || $a->argv[1] !== 'users')
|
||||
http_status_exit(500);
|
||||
|
||||
logger('receive: raw input: ' . file_get_contents('php://input'), LOGGER_DATA);
|
||||
|
||||
$guid = $a->argv[2];
|
||||
|
||||
$r = q("SELECT * FROM `user` WHERE `guid` = '%s' LIMIT 1",
|
||||
|
@ -43,32 +41,7 @@ function receive_post(&$a) {
|
|||
if(! is_array($msg))
|
||||
http_status_exit(500);
|
||||
|
||||
|
||||
$parsed_xml = parse_xml_string($msg['message'],false);
|
||||
|
||||
$xmlbase = $parsed_xml->post;
|
||||
|
||||
if($xmlbase->request) {
|
||||
diaspora_request($importer,$xmlbase->request);
|
||||
}
|
||||
elseif($xmlbase->status_message) {
|
||||
diaspora_post($importer,$xmlbase->status_message);
|
||||
}
|
||||
elseif($xmlbase->comment) {
|
||||
diaspora_comment($importer,$xmlbase->comment,$msg);
|
||||
}
|
||||
elseif($xmlbase->like) {
|
||||
diaspora_like($importer,$xmlbase->like,$msg);
|
||||
}
|
||||
elseif($xmlbase->retraction) {
|
||||
diaspora_retraction($importer,$xmlbase->retraction,$msg);
|
||||
}
|
||||
elseif($xmlbase->photo) {
|
||||
diaspora_photo($importer,$xmlbase->photo,$msg);
|
||||
}
|
||||
else {
|
||||
logger('mod-diaspora: unknown message type: ' . print_r($xmlbase,true));
|
||||
}
|
||||
diaspora_dispatch($importer,$msg);
|
||||
|
||||
http_status_exit(200);
|
||||
// NOTREACHED
|
||||
|
|
Loading…
Reference in New Issue
Block a user