aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs')
-rw-r--r--Zotlabs/Daemon/Checksites.php3
-rw-r--r--Zotlabs/Daemon/Deliver.php70
-rw-r--r--Zotlabs/Daemon/Directory.php3
-rw-r--r--Zotlabs/Daemon/Notifier.php23
-rw-r--r--Zotlabs/Daemon/Ratenotif.php5
-rw-r--r--Zotlabs/Lib/Activity.php10
-rw-r--r--Zotlabs/Module/Admin/Site.php8
-rw-r--r--Zotlabs/Module/Sse.php107
-rw-r--r--Zotlabs/Update/_1239.php27
9 files changed, 148 insertions, 108 deletions
diff --git a/Zotlabs/Daemon/Checksites.php b/Zotlabs/Daemon/Checksites.php
index a2081967a..3bcfdd7cf 100644
--- a/Zotlabs/Daemon/Checksites.php
+++ b/Zotlabs/Daemon/Checksites.php
@@ -2,8 +2,7 @@
namespace Zotlabs\Daemon;
-require_once('include/zot.php');
-
+require_once('include/hubloc.php');
class Checksites {
diff --git a/Zotlabs/Daemon/Deliver.php b/Zotlabs/Daemon/Deliver.php
index 43f426eb7..c853af6a8 100644
--- a/Zotlabs/Daemon/Deliver.php
+++ b/Zotlabs/Daemon/Deliver.php
@@ -2,12 +2,8 @@
namespace Zotlabs\Daemon;
-use Zotlabs\Lib\DReport;
-
-require_once('include/zot.php');
require_once('include/queue_fn.php');
-
class Deliver {
static public function run($argc,$argv) {
@@ -22,72 +18,16 @@ class Deliver {
if(! $argv[$x])
continue;
- $dresult = null;
- $r = q("select * from outq where outq_hash = '%s' limit 1",
+ $r = q("select * from outq where outq_hash = '%s'",
dbesc($argv[$x])
);
- if($r) {
-
- $notify = json_decode($r[0]['outq_notify'],true);
-
- // Messages without an outq_msg will need to go via the web, even if it's a
- // local delivery. This includes conversation requests and refresh packets.
-
- if(($r[0]['outq_posturl'] === z_root() . '/post') && ($r[0]['outq_msg'])) {
- logger('deliver: local delivery', LOGGER_DEBUG);
-
- // local delivery
- // we should probably batch these and save a few delivery processes
-
- if($r[0]['outq_msg']) {
- $m = json_decode($r[0]['outq_msg'],true);
- if(array_key_exists('message_list',$m)) {
- foreach($m['message_list'] as $mm) {
- $msg = array('body' => json_encode(array('success' => true, 'pickup' => array(array('notify' => $notify,'message' => $mm)))));
- zot_import($msg,z_root());
- }
- }
- else {
- $msg = array('body' => json_encode(array('success' => true, 'pickup' => array(array('notify' => $notify,'message' => $m)))));
- $dresult = zot_import($msg,z_root());
- }
-
- remove_queue_item($r[0]['outq_hash']);
-
- if($dresult && is_array($dresult)) {
-
- // delivery reports for local deliveries do not require encryption
-
- foreach($dresult as $xx) {
- if(is_array($xx) && array_key_exists('message_id',$xx)) {
- if(DReport::is_storable($xx)) {
- q("insert into dreport ( dreport_mid, dreport_site, dreport_recip, dreport_name, dreport_result, dreport_time, dreport_xchan ) values ( '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ",
- dbesc($xx['message_id']),
- dbesc($xx['location']),
- dbesc($xx['recipient']),
- dbesc(($xx['name']) ? $xx['name'] : EMPTY_STR),
- dbesc($xx['status']),
- dbesc(datetime_convert($xx['date'])),
- dbesc($xx['sender'])
- );
- }
- }
- }
- }
-
- q("delete from dreport where dreport_queue = '%s'",
- dbesc($argv[$x])
- );
-
- continue;
- }
- }
-
- // otherwise it's a remote delivery - call queue_deliver() with the $immediate flag
+ if($r) {
queue_deliver($r[0],true);
-
}
+
}
+
}
+
}
diff --git a/Zotlabs/Daemon/Directory.php b/Zotlabs/Daemon/Directory.php
index c698995c2..ab58432de 100644
--- a/Zotlabs/Daemon/Directory.php
+++ b/Zotlabs/Daemon/Directory.php
@@ -58,7 +58,8 @@ class Directory {
// otherwise send the changes upstream
$directory = Libzotdir::find_upstream_directory($dirmode);
- $url = $directory['url'] . '/post';
+
+ $url = $directory['url'] . '/zot';
// ensure the upstream directory is updated
diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php
index 8ea75af61..f24eab773 100644
--- a/Zotlabs/Daemon/Notifier.php
+++ b/Zotlabs/Daemon/Notifier.php
@@ -4,6 +4,7 @@ namespace Zotlabs\Daemon;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\Activity;
+use Zotlabs\Lib\Queue;
require_once('include/queue_fn.php');
require_once('include/html2plain.php');
@@ -734,15 +735,17 @@ class Notifier {
}
if($packet) {
- queue_insert(array(
- 'hash' => $hash,
- 'account_id' => $channel['channel_account_id'],
- 'channel_id' => $channel['channel_id'],
- 'posturl' => $hub['hubloc_callback'],
- 'driver' => $hub['hubloc_network'],
- 'notify' => $packet,
- 'msg' => (($pmsg) ? json_encode($pmsg) : '')
- ));
+ Queue::insert(
+ [
+ 'hash' => $hash,
+ 'account_id' => $channel['channel_account_id'],
+ 'channel_id' => $channel['channel_id'],
+ 'posturl' => $hub['hubloc_callback'],
+ 'driver' => $hub['hubloc_network'],
+ 'notify' => $packet,
+ 'msg' => (($pmsg) ? json_encode($pmsg) : '')
+ ]
+ );
}
else {
$env = (($hub_env && $hub_env[$hub['hubloc_host'] . $hub['hubloc_sitekey']]) ? $hub_env[$hub['hubloc_host'] . $hub['hubloc_sitekey']] : '');
@@ -803,7 +806,7 @@ class Notifier {
}
}
- queue_insert(
+ Queue::insert(
[
'hash' => $hash,
'account_id' => $target_item['aid'],
diff --git a/Zotlabs/Daemon/Ratenotif.php b/Zotlabs/Daemon/Ratenotif.php
index c7bf79854..8afde2c4c 100644
--- a/Zotlabs/Daemon/Ratenotif.php
+++ b/Zotlabs/Daemon/Ratenotif.php
@@ -10,6 +10,11 @@ class Ratenotif {
static public function run($argc,$argv) {
+
+ // Deprecated
+ return;
+
+
require_once("datetime.php");
require_once('include/items.php');
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php
index 48714a48d..5f222754b 100644
--- a/Zotlabs/Lib/Activity.php
+++ b/Zotlabs/Lib/Activity.php
@@ -1493,6 +1493,14 @@ class Activity {
if(! is_array($person_obj))
return;
+ $inbox = $person_obj['inbox'];
+
+ // invalid identity
+
+ if (! $inbox || strpos($inbox,z_root()) !== false) {
+ return;
+ }
+
$name = $person_obj['name'];
if(! $name)
$name = $person_obj['preferredUsername'];
@@ -1540,8 +1548,6 @@ class Activity {
$profile = $url;
}
- $inbox = $person_obj['inbox'];
-
$collections = [];
if($inbox) {
diff --git a/Zotlabs/Module/Admin/Site.php b/Zotlabs/Module/Admin/Site.php
index 4bb34b7b7..011bf3ce4 100644
--- a/Zotlabs/Module/Admin/Site.php
+++ b/Zotlabs/Module/Admin/Site.php
@@ -62,6 +62,9 @@ class Site {
$from_email = ((array_key_exists('from_email',$_POST) && trim($_POST['from_email'])) ? trim($_POST['from_email']) : 'Administrator@' . \App::get_hostname());
$from_email_name = ((array_key_exists('from_email_name',$_POST) && trim($_POST['from_email_name'])) ? trim($_POST['from_email_name']) : \Zotlabs\Lib\System::get_site_name());
+
+ $sse_enabled = ((x($_POST,'sse_enabled')) ? true : false);
+
$verifyssl = ((x($_POST,'verifyssl')) ? True : False);
$proxyuser = ((x($_POST,'proxyuser')) ? notags(trim($_POST['proxyuser'])) : '');
$proxy = ((x($_POST,'proxy')) ? notags(trim($_POST['proxy'])) : '');
@@ -151,6 +154,9 @@ class Site {
set_config('system','no_community_page', $no_community_page);
set_config('system','no_utf', $no_utf);
+
+ set_config('system','sse_enabled', $sse_enabled);
+
set_config('system','verifyssl', $verifyssl);
set_config('system','proxyuser', $proxyuser);
set_config('system','proxy', $proxy);
@@ -331,6 +337,8 @@ class Site {
'$directory_server' => (($dir_choices) ? array('directory_server', t("Directory Server URL"), get_config('system','directory_server'), t("Default directory server"), $dir_choices) : null),
+ '$sse_enabled' => array('sse_enabled', t('Enable SSE Notifications'), get_config('system', 'sse_enabled', 0), t('If disabled, traditional polling will be used. Warning: this setting might not be suited for shared hosting')),
+
'$proxyuser' => array('proxyuser', t("Proxy user"), get_config('system','proxyuser'), ""),
'$proxy' => array('proxy', t("Proxy URL"), get_config('system','proxy'), ""),
'$timeout' => array('timeout', t("Network timeout"), (x(get_config('system','curl_timeout'))?get_config('system','curl_timeout'):60), t("Value is in seconds. Set to 0 for unlimited (not recommended).")),
diff --git a/Zotlabs/Module/Sse.php b/Zotlabs/Module/Sse.php
index b68fe6705..46b4a8d87 100644
--- a/Zotlabs/Module/Sse.php
+++ b/Zotlabs/Module/Sse.php
@@ -14,6 +14,7 @@ class Sse extends Controller {
public static $ob_hash;
public static $sse_id;
public static $vnotify;
+ public static $sse_enabled;
function init() {
@@ -49,18 +50,86 @@ class Sse extends Controller {
$sys = get_sys_channel();
$sleep_seconds = 3;
- header("Content-Type: text/event-stream");
- header("Cache-Control: no-cache");
- header("Connection: keep-alive");
- header("X-Accel-Buffering: no");
+ self::$sse_enabled = get_config('system', 'sse_enabled', 0);
- while(true) {
+ if(self::$sse_enabled) {
- /**
- * Update chat presence indication (if applicable)
- */
+ // Server Sent Events
+
+ header("Content-Type: text/event-stream");
+ header("Cache-Control: no-cache");
+ header("Connection: keep-alive");
+ header("X-Accel-Buffering: no");
+
+ while(true) {
+
+ if(! self::$sse_id) {
+
+ // Update chat presence indication
+
+ $r = q("select cp_id, cp_room from chatpresence where cp_xchan = '%s' and cp_client = '%s' and cp_room = 0 limit 1",
+ dbesc(self::$ob_hash),
+ dbesc($_SERVER['REMOTE_ADDR'])
+ );
+ $basic_presence = false;
+ if($r) {
+ $basic_presence = true;
+ q("update chatpresence set cp_last = '%s' where cp_id = %d",
+ dbesc(datetime_convert()),
+ intval($r[0]['cp_id'])
+ );
+ }
+ if(! $basic_presence) {
+ q("insert into chatpresence ( cp_xchan, cp_last, cp_status, cp_client)
+ values( '%s', '%s', '%s', '%s' ) ",
+ dbesc(self::$ob_hash),
+ dbesc(datetime_convert()),
+ dbesc('online'),
+ dbesc($_SERVER['REMOTE_ADDR'])
+ );
+ }
+ }
+
+ XConfig::Load(self::$ob_hash);
+
+ $result = XConfig::Get(self::$ob_hash, 'sse', 'notifications', []);
+ $lock = XConfig::Get(self::$ob_hash, 'sse', 'lock');
+
+ if($result && !$lock) {
+ echo "event: notifications\n";
+ echo 'data: ' . json_encode($result);
+ echo "\n\n";
+
+ XConfig::Set(self::$ob_hash, 'sse', 'notifications', []);
+ unset($result);
+ }
+
+ // always send heartbeat to detect disconnected clients
+ echo "event: heartbeat\n";
+ echo 'data: {}';
+ echo "\n\n";
+
+ ob_end_flush();
+ flush();
+
+ if(connection_status() != CONNECTION_NORMAL || connection_aborted()) {
+ //TODO: this does not seem to be triggered
+ XConfig::Set(self::$ob_hash, 'sse', 'timestamp', NULL_DATE);
+ break;
+ }
+
+ sleep($sleep_seconds);
+
+ }
+
+ }
+ else {
+ // Fallback to traditional polling
if(! self::$sse_id) {
+
+ // Update chat presence indication
+
$r = q("select cp_id, cp_room from chatpresence where cp_xchan = '%s' and cp_client = '%s' and cp_room = 0 limit 1",
dbesc(self::$ob_hash),
dbesc($_SERVER['REMOTE_ADDR'])
@@ -90,29 +159,11 @@ class Sse extends Controller {
$lock = XConfig::Get(self::$ob_hash, 'sse', 'lock');
if($result && !$lock) {
- echo "event: notifications\n";
- echo 'data: ' . json_encode($result);
- echo "\n\n";
-
XConfig::Set(self::$ob_hash, 'sse', 'notifications', []);
- unset($result);
- }
-
- // always send heartbeat to detect disconnected clients
- echo "event: heartbeat\n";
- echo 'data: {}';
- echo "\n\n";
-
- ob_end_flush();
- flush();
-
- if(connection_status() != CONNECTION_NORMAL || connection_aborted()) {
- //TODO: this does not seem to be triggered
- XConfig::Set(self::$ob_hash, 'sse', 'timestamp', NULL_DATE);
- break;
+ json_return_and_die($result);
}
- sleep($sleep_seconds);
+ killme();
}
diff --git a/Zotlabs/Update/_1239.php b/Zotlabs/Update/_1239.php
new file mode 100644
index 000000000..ed8de30bb
--- /dev/null
+++ b/Zotlabs/Update/_1239.php
@@ -0,0 +1,27 @@
+<?php
+
+namespace Zotlabs\Update;
+
+class _1239 {
+
+ function run() {
+
+ dbq("START TRANSACTION");
+
+ // remove broken activitypub hubloc entries
+ $r = dbq("DELETE FROM hubloc WHERE hubloc_network = 'activitypub' and hubloc_callback = ''");
+
+ // remove broken hubloc entries from friendica
+ $r1 = dbq("DELETE FROM hubloc WHERE hubloc_hash = ''");
+
+ if($r && $r1) {
+ dbq("COMMIT");
+ return UPDATE_SUCCESS;
+ }
+
+ dbq("ROLLBACK");
+ return UPDATE_FAILED;
+
+ }
+
+}