begin moving diaspora to plugin
This commit is contained in:
parent
49532aa6dd
commit
9f5dfe797b
3021
include/diaspora.php
3021
include/diaspora.php
File diff suppressed because it is too large
Load Diff
@ -113,11 +113,9 @@ function notifier_run($argv, $argc){
|
|||||||
intval($r[0]['abook_channel'])
|
intval($r[0]['abook_channel'])
|
||||||
);
|
);
|
||||||
if($s) {
|
if($s) {
|
||||||
if($r[0]['hubloc_network'] === 'diaspora' || $r[0]['hubloc_network'] === 'friendica-over-diaspora') {
|
$perm_update = array('sender' => $s[0], 'recipient' => $r[0], 'success' => false);
|
||||||
require_once('include/diaspora.php');
|
call_hooks('permissions_update',$perm_update);
|
||||||
diaspora_share($s[0],$r[0]);
|
if(! $perm_update['success']) {
|
||||||
}
|
|
||||||
else {
|
|
||||||
// send a refresh message to each hub they have registered here
|
// send a refresh message to each hub they have registered here
|
||||||
$h = q("select * from hubloc where hubloc_hash = '%s'
|
$h = q("select * from hubloc where hubloc_hash = '%s'
|
||||||
and not (hubloc_flags & %d) > 0 and not (hubloc_status & %d) > 0",
|
and not (hubloc_flags & %d) > 0 and not (hubloc_status & %d) > 0",
|
||||||
@ -606,18 +604,9 @@ function notifier_run($argv, $argc){
|
|||||||
|
|
||||||
foreach($dhubs as $hub) {
|
foreach($dhubs as $hub) {
|
||||||
|
|
||||||
if($hub['hubloc_network'] === 'diaspora' || $hub['hubloc_network'] === 'friendica-over-diaspora') {
|
if($hub['hubloc_network'] !== 'zot') {
|
||||||
if(! get_config('system','diaspora_enabled'))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// allow this to be set per message
|
$narr = array(
|
||||||
|
|
||||||
if(strpos($target_item['postopts'],'nodspr') !== false)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
require_once('include/diaspora.php');
|
|
||||||
|
|
||||||
diaspora_process_outbound(array(
|
|
||||||
'channel' => $channel,
|
'channel' => $channel,
|
||||||
'env_recips' => $env_recips,
|
'env_recips' => $env_recips,
|
||||||
'recipients' => $recipients,
|
'recipients' => $recipients,
|
||||||
@ -638,13 +627,14 @@ function notifier_run($argv, $argc){
|
|||||||
'normal_mode' => $normal_mode,
|
'normal_mode' => $normal_mode,
|
||||||
'packet_type' => $packet_type,
|
'packet_type' => $packet_type,
|
||||||
'walltowall' => $walltowall
|
'walltowall' => $walltowall
|
||||||
));
|
);
|
||||||
|
|
||||||
|
|
||||||
|
call_hooks('notifier_hub',$narr);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// default: zot protocol
|
// default: zot protocol
|
||||||
|
|
||||||
|
|
||||||
|
51
mod/p.php
51
mod/p.php
@ -1,51 +0,0 @@
|
|||||||
<?php /** @file */
|
|
||||||
|
|
||||||
require_once('include/bb2diaspora.php');
|
|
||||||
|
|
||||||
// used in Diaspora communications to provide a server copy of a sent post in XML format.
|
|
||||||
|
|
||||||
function p_init(&$a) {
|
|
||||||
|
|
||||||
if(argc() < 2)
|
|
||||||
http_status_exit(401);
|
|
||||||
|
|
||||||
$mid = str_replace('.xml','',argv(1));
|
|
||||||
|
|
||||||
$r = q("select * from item where mid = '%s' and item_wall = 1 and item_private = 0 limit 1",
|
|
||||||
dbesc($mid)
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
if((! $r) || (! perm_is_allowed($r[0]['uid'],'','view_stream')))
|
|
||||||
http_status_exit(404);
|
|
||||||
|
|
||||||
|
|
||||||
$c = q("select * from channel where channel_id = %d limit 1",
|
|
||||||
intval($r[0]['uid'])
|
|
||||||
);
|
|
||||||
|
|
||||||
if(! $c)
|
|
||||||
http_status_exit(404);
|
|
||||||
|
|
||||||
$myaddr = $c[0]['channel_address'] . '@' . $a->get_hostname();
|
|
||||||
|
|
||||||
$item = $r[0];
|
|
||||||
|
|
||||||
$title = $item['title'];
|
|
||||||
$body = bb2diaspora_itembody($item);
|
|
||||||
$created = datetime_convert('UTC','UTC',$item['created'],'Y-m-d H:i:s \U\T\C');
|
|
||||||
|
|
||||||
$tpl = get_markup_template('diaspora_post.tpl');
|
|
||||||
$msg = replace_macros($tpl, array(
|
|
||||||
'$body' => xmlify($body),
|
|
||||||
'$guid' => $item['mid'],
|
|
||||||
'$handle' => xmlify($myaddr),
|
|
||||||
'$public' => 'true',
|
|
||||||
'$created' => $created,
|
|
||||||
'$provider' => (($item['app']) ? $item['app'] : t('$projectname'))
|
|
||||||
));
|
|
||||||
|
|
||||||
header('Content-type: text/xml');
|
|
||||||
echo $msg;
|
|
||||||
killme();
|
|
||||||
}
|
|
@ -1,76 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Diaspora endpoint
|
|
||||||
*/
|
|
||||||
|
|
||||||
require_once('include/crypto.php');
|
|
||||||
require_once('include/diaspora.php');
|
|
||||||
|
|
||||||
|
|
||||||
function receive_post(&$a) {
|
|
||||||
|
|
||||||
|
|
||||||
$enabled = intval(get_config('system','diaspora_enabled'));
|
|
||||||
if(! $enabled) {
|
|
||||||
logger('mod-diaspora: disabled');
|
|
||||||
http_status_exit(500);
|
|
||||||
}
|
|
||||||
|
|
||||||
$public = false;
|
|
||||||
|
|
||||||
if((argc() == 2) && (argv(1) === 'public')) {
|
|
||||||
$public = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
if(argc() != 3 || argv(1) !== 'users')
|
|
||||||
http_status_exit(500);
|
|
||||||
|
|
||||||
$guid = argv(2);
|
|
||||||
|
|
||||||
// Diaspora sites *may* provide a truncated guid.
|
|
||||||
|
|
||||||
$r = q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_guid like '%s' AND channel_removed = 0 LIMIT 1",
|
|
||||||
dbesc($guid . '%')
|
|
||||||
);
|
|
||||||
if(! $r)
|
|
||||||
http_status_exit(500);
|
|
||||||
|
|
||||||
$importer = $r[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
// It is an application/x-www-form-urlencoded that has been urlencoded twice.
|
|
||||||
|
|
||||||
logger('mod-diaspora: receiving post', LOGGER_DEBUG);
|
|
||||||
|
|
||||||
$xml = urldecode($_POST['xml']);
|
|
||||||
|
|
||||||
logger('mod-diaspora: new salmon ' . $xml, LOGGER_DATA);
|
|
||||||
|
|
||||||
if(! $xml)
|
|
||||||
http_status_exit(500);
|
|
||||||
|
|
||||||
logger('mod-diaspora: message is okay', LOGGER_DEBUG);
|
|
||||||
|
|
||||||
$msg = diaspora_decode($importer,$xml);
|
|
||||||
|
|
||||||
logger('mod-diaspora: decoded', LOGGER_DEBUG);
|
|
||||||
|
|
||||||
logger('mod-diaspora: decoded msg: ' . print_r($msg,true), LOGGER_DATA);
|
|
||||||
|
|
||||||
if(! is_array($msg))
|
|
||||||
http_status_exit(500);
|
|
||||||
|
|
||||||
logger('mod-diaspora: dispatching', LOGGER_DEBUG);
|
|
||||||
|
|
||||||
$ret = 0;
|
|
||||||
if($public)
|
|
||||||
diaspora_dispatch_public($msg);
|
|
||||||
else
|
|
||||||
$ret = diaspora_dispatch($importer,$msg);
|
|
||||||
|
|
||||||
http_status_exit(($ret) ? $ret : 200);
|
|
||||||
// NOTREACHED
|
|
||||||
}
|
|
||||||
|
|
Reference in New Issue
Block a user