aboutsummaryrefslogtreecommitdiffstats
path: root/include/zot.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-11-27 17:09:01 -0800
committerfriendica <info@friendica.com>2012-11-27 17:09:01 -0800
commit2fe2de1d5ac991d2bc20dd2df8eb071f5c8039a7 (patch)
tree53a36053fd4057d8c31932b5f089583669492580 /include/zot.php
parentf3fdbb6021bd2e20f728149e7534ffdaadbfda36 (diff)
downloadvolse-hubzilla-2fe2de1d5ac991d2bc20dd2df8eb071f5c8039a7.tar.gz
volse-hubzilla-2fe2de1d5ac991d2bc20dd2df8eb071f5c8039a7.tar.bz2
volse-hubzilla-2fe2de1d5ac991d2bc20dd2df8eb071f5c8039a7.zip
got comments going back and forth - we really need local_deliver now since even local deliveries are going through zot and that isn't necessary or desirable in the long term
Diffstat (limited to 'include/zot.php')
-rw-r--r--include/zot.php31
1 files changed, 24 insertions, 7 deletions
diff --git a/include/zot.php b/include/zot.php
index 654b17353..318948ccc 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -610,6 +610,9 @@ function zot_import($arr) {
logger('zot_import: ' . print_r($arr,true), LOGGER_DATA);
$data = json_decode($arr['body'],true);
+
+ logger('zot_import: data1: ' . print_r($data,true));
+
if(array_key_exists('iv',$data)) {
$data = json_decode(aes_unencapsulate($data,get_config('system','prvkey')),true);
}
@@ -620,6 +623,10 @@ function zot_import($arr) {
if(is_array($incoming)) {
foreach($incoming as $i) {
+ if(array_key_exists('iv',$i['notify'])) {
+ $i['notify'] = json_decode(aes_unencapsulate($i['notify'],get_config('system','prvkey')),true);
+ }
+
$i['notify']['sender']['hash'] = base64url_encode(hash('whirlpool',$i['notify']['sender']['guid'] . $i['notify']['sender']['guid_sig'], true));
$deliveries = null;
@@ -658,7 +665,8 @@ function zot_import($arr) {
logger('Activity received: ' . print_r($arr,true));
logger('Activity recipients: ' . print_r($deliveries,true));
dbg(1);
- process_delivery($i['notify']['sender'],$arr,$deliveries);
+ $relay = ((array_key_exists('flags',$i['message']) && in_array('relay',$i['message']['flags'])) ? true : false);
+ process_delivery($i['notify']['sender'],$arr,$deliveries,$relay);
dbg(0);
}
elseif($i['message']['type'] === 'mail') {
@@ -726,7 +734,7 @@ function public_recips($msg) {
}
-function process_delivery($sender,$arr,$deliveries) {
+function process_delivery($sender,$arr,$deliveries,$relay) {
foreach($deliveries as $d) {
@@ -745,29 +753,38 @@ function process_delivery($sender,$arr,$deliveries) {
logger("permission denied for delivery {$channel['channel_id']}");
continue;
}
+
if($arr['item_restrict'] & ITEM_DELETED) {
delete_imported_item($sender,$arr,$channel['channel_id']);
continue;
}
- $r = q("select edited from item where uri = '%s' and uid = %d limit 1",
+ $r = q("select id, edited from item where uri = '%s' and uid = %d limit 1",
dbesc($arr['uri']),
- intval($channel['uid'])
+ intval($channel['channel_id'])
);
- if($r)
- update_imported_item($sender,$arr,$channel['channel_id']);
+ if($r) {
+ if($arr['edited'] > $r[0]['edited'])
+ update_imported_item($sender,$arr,$channel['channel_id']);
+ $item_id = $r[0]['id'];
+ }
else {
$arr['aid'] = $channel['channel_account_id'];
$arr['uid'] = $channel['channel_id'];
$item_id = item_store($arr);
}
+
+ if($relay && $item_id) {
+ logger('process_delivery: invoking relay');
+ proc_run('php','include/notifier.php','relay',intval($item_id));
+ }
}
}
function update_imported_item($sender,$item,$uid) {
// FIXME
- logger('item exists: updating or ignoring');
+ logger('update_imported_item');
}