aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorredmatrix <git@macgirvin.com>2016-04-26 17:38:44 -0700
committerredmatrix <git@macgirvin.com>2016-04-26 17:38:44 -0700
commita67fa2651d3fe4016ba8cc5f0eb90bf3993fb028 (patch)
tree6932350659fa9b2948b54adf7f50e363b9ef6db9 /include
parent509f25e46a37d7fae1a2d1934c6143e96aa6497d (diff)
downloadvolse-hubzilla-a67fa2651d3fe4016ba8cc5f0eb90bf3993fb028.tar.gz
volse-hubzilla-a67fa2651d3fe4016ba8cc5f0eb90bf3993fb028.tar.bz2
volse-hubzilla-a67fa2651d3fe4016ba8cc5f0eb90bf3993fb028.zip
implement the singleton delivery stuff
Diffstat (limited to 'include')
-rw-r--r--include/import.php25
-rw-r--r--include/notifier.php19
-rw-r--r--include/zot.php2
3 files changed, 38 insertions, 8 deletions
diff --git a/include/import.php b/include/import.php
index ae7f417af..f6e62f9e0 100644
--- a/include/import.php
+++ b/include/import.php
@@ -499,6 +499,7 @@ function import_items($channel,$items,$sync = false) {
$deliver = false; // Don't deliver any messages or notifications when importing
foreach($items as $i) {
+ $item_result = false;
$item = get_item_elements($i,$allow_code);
if(! $item)
continue;
@@ -511,7 +512,13 @@ function import_items($channel,$items,$sync = false) {
if($item['edited'] > $r[0]['edited']) {
$item['id'] = $r[0]['id'];
$item['uid'] = $channel['channel_id'];
- item_store_update($item,$allow_code,$deliver);
+ $item_result = item_store_update($item,$allow_code,$deliver);
+ if($sync && $item['item_wall']) {
+ // deliver singletons if we have any
+ if($item_result && $item_result['success']) {
+ proc_run('php','include/notifier.php','single_activity',$item_result['item_id']);
+ }
+ }
continue;
}
}
@@ -520,8 +527,11 @@ function import_items($channel,$items,$sync = false) {
$item['uid'] = $channel['channel_id'];
$item_result = item_store($item,$allow_code,$deliver);
}
- if($sync) {
+ if($sync && $item['item_wall']) {
// deliver singletons if we have any
+ if($item_result && $item_result['success']) {
+ proc_run('php','include/notifier.php','single_activity',$item_result['item_id']);
+ }
}
}
}
@@ -842,7 +852,7 @@ function import_conv($channel,$convs) {
-function import_mail($channel,$mails) {
+function import_mail($channel,$mails,$sync = false) {
if($channel && $mails) {
foreach($mails as $mail) {
if(array_key_exists('flags',$mail) && in_array('deleted',$mail['flags'])) {
@@ -866,12 +876,17 @@ function import_mail($channel,$mails) {
$m['aid'] = $channel['channel_account_id'];
$m['uid'] = $channel['channel_id'];
- mail_store($m);
+ $mail_id = mail_store($m);
+ if($sync && $mail_id) {
+ proc_run('php','include/notifier.php','single_mail',$mail_id);
+ }
}
}
}
-
+function sync_mail($channel,$mails) {
+ import_mail($channel,$mails,true);
+}
function sync_files($channel,$files) {
diff --git a/include/notifier.php b/include/notifier.php
index 4435c7497..f0c6d7275 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -118,7 +118,7 @@ function notifier_run($argv, $argc){
$normal_mode = true;
$packet_type = 'undefined';
- if($cmd === 'mail') {
+ if($cmd === 'mail' || $cmd === 'single_mail') {
$normal_mode = false;
$mail = true;
$private = true;
@@ -280,7 +280,7 @@ function notifier_run($argv, $argc){
logger('notifier: target item not forwardable: type ' . $target_item['item_type'], LOGGER_DEBUG);
return;
}
- if(intval($target_item['item_unpublished']) || intval($target_item['item_delayed'])) {
+ if(intval($target_item['item_unpublished']) || intval($target_item['item_delayed']) || intval($target_item['item_hidden'])) {
logger('notifier: target item not published, so not forwardable', LOGGER_DEBUG);
return;
}
@@ -454,6 +454,7 @@ function notifier_run($argv, $argc){
'uplink' => $uplink,
'cmd' => $cmd,
'mail' => $mail,
+ 'single' => (($cmd === 'single_mail' || $cmd === 'single_activity') ? true : false),
'location' => $location,
'request' => $request,
'normal_mode' => $normal_mode,
@@ -550,6 +551,7 @@ function notifier_run($argv, $argc){
'uplink' => $uplink,
'cmd' => $cmd,
'mail' => $mail,
+ 'single' => (($cmd === 'single_mail' || $cmd === 'single_activity') ? true : false),
'location' => $location,
'request' => $request,
'normal_mode' => $normal_mode,
@@ -568,6 +570,19 @@ function notifier_run($argv, $argc){
}
+ // singleton deliveries by definition 'not got zot'.
+ // Single deliveries are other federated networks (plugins) and we're essentially
+ // delivering only to those that have this site url in their abook_instance
+ // and only from within a sync operation. This means if you post from a clone,
+ // and a connection is connected to one of your other clones; assuming that hub
+ // is running it will receive a sync packet. On receipt of this sync packet it
+ // will invoke a delivery to those connections which are connected to just that
+ // hub instance.
+
+ if($cmd === 'single_mail' || $cmd === 'single_activity') {
+ continue;
+ }
+
// default: zot protocol
$hash = random_string();
diff --git a/include/zot.php b/include/zot.php
index 9d9f9ab5f..1ca1b862b 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -3121,7 +3121,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
import_conv($channel,$arr['conv']);
if(array_key_exists('mail',$arr) && $arr['mail'])
- import_mail($channel,$arr['mail']);
+ sync_mail($channel,$arr['mail']);
if(array_key_exists('event',$arr) && $arr['event'])
sync_events($channel,$arr['event']);