From 66058c6cf41791eeca418d9003aa6daa1a036ce2 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sat, 13 Jun 2015 19:51:45 +0200 Subject: [PATCH 1/5] Remote subscribe from a GNU Social site is now possible --- mod/xrd.php | 1 + view/templates/xrd_person.tpl | 2 ++ 2 files changed, 3 insertions(+) diff --git a/mod/xrd.php b/mod/xrd.php index 7cfb643df1..dfb188c138 100644 --- a/mod/xrd.php +++ b/mod/xrd.php @@ -54,6 +54,7 @@ function xrd_init(&$a) { '$dspr' => $dspr, '$salmon' => $a->get_baseurl() . '/salmon/' . $r[0]['nickname'], '$salmen' => $a->get_baseurl() . '/salmon/' . $r[0]['nickname'] . '/mention', + '$subscribe' => $a->get_baseurl() . '/follow?url={uri}', '$modexp' => 'data:application/magic-public-key,' . $salmon_key, '$bigkey' => salmon_key($r[0]['pubkey']) )); diff --git a/view/templates/xrd_person.tpl b/view/templates/xrd_person.tpl index c5c6f538c7..f3ac0332b8 100644 --- a/view/templates/xrd_person.tpl +++ b/view/templates/xrd_person.tpl @@ -29,6 +29,8 @@ href="{{$salmon}}" /> + From c89c0916e2fd77ed976bd7ecd59c96f74f351b8f Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sat, 13 Jun 2015 20:23:26 +0200 Subject: [PATCH 2/5] Better detection for the mobile client to avoid "{0}" in notifications. --- boot.php | 8 ++++++++ mod/notify.php | 5 +---- mod/ping.php | 5 ++++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/boot.php b/boot.php index 465bec6775..6c9c8fdc4a 100644 --- a/boot.php +++ b/boot.php @@ -379,6 +379,7 @@ if(! class_exists('App')) { public $identities; public $is_mobile; public $is_tablet; + public $is_friendica_app; public $performance = array(); public $nav_sel; @@ -596,6 +597,9 @@ if(! class_exists('App')) { $this->is_mobile = $mobile_detect->isMobile(); $this->is_tablet = $mobile_detect->isTablet(); + // Friendica-Client + $this->is_friendica_app = ($_SERVER['HTTP_USER_AGENT'] == "Apache-HttpClient/UNAVAILABLE (java 1.4)"); + /** * register template engines */ @@ -906,6 +910,10 @@ if(! class_exists('App')) { return(FRIENDICA_PLATFORM." '".FRIENDICA_CODENAME."' ".FRIENDICA_VERSION."-".DB_UPDATE_VERSION."; ".$this->get_baseurl()); } + function is_friendica_app() { + return($this->is_friendica_app); + } + } } diff --git a/mod/notify.php b/mod/notify.php index f9c5a09b27..02260514af 100644 --- a/mod/notify.php +++ b/mod/notify.php @@ -18,11 +18,8 @@ function notify_init(&$a) { intval(local_user()) ); - // Friendica-Client - $friendicamobile = ($_SERVER['HTTP_USER_AGENT'] == "Apache-HttpClient/UNAVAILABLE (java 1.4)"); - // The friendica client has problems with the GUID. this is some workaround - if ($friendicamobile) { + if ($a->is_friendica_app()) { require_once("include/items.php"); $urldata = parse_url($r[0]['link']); $guid = basename($urldata["path"]); diff --git a/mod/ping.php b/mod/ping.php index ee5be67f6b..3ef15a9e7c 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -316,6 +316,8 @@ function ping_get_notifications($uid, $regularnotifications) { $order = ""; $quit = false; + $a = get_app(); + do { $r = q("SELECT `notify`.*, `item`.`visible`, `item`.`spam`, `item`.`deleted` FROM `notify` LEFT JOIN `item` ON `item`.`id` = `notify`.`iid` @@ -354,8 +356,9 @@ function ping_get_notifications($uid, $regularnotifications) { // Replace the name with {0} but ensure to make that only once // The {0} is used later and prints the name in bold. // But don't do it for the android app. + $pos = strpos($notification["msg"],$notification['name']); - if (($pos !== false) AND $regularnotifications) + if (($pos !== false) AND $regularnotifications AND !$a->is_friendica_app()) $notification["msg"] = substr_replace($notification["msg"],"{0}",$pos,strlen($notification["name"])); else $notification["msg"] = str_replace("{0}", $notification["name"], $notification["msg"]); From b7f270de2846d17c2a7804c81015679a19aad54a Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 14 Jun 2015 01:52:26 +0200 Subject: [PATCH 3/5] probe_url: Better detection for non-standard installations of GNU Social --- include/Scrape.php | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/include/Scrape.php b/include/Scrape.php index 1bb1998b0d..90fb1a9e3d 100644 --- a/include/Scrape.php +++ b/include/Scrape.php @@ -335,7 +335,7 @@ function scrape_feed($url) { define ( 'PROBE_NORMAL', 0); define ( 'PROBE_DIASPORA', 1); -function probe_url($url, $mode = PROBE_NORMAL) { +function probe_url($url, $mode = PROBE_NORMAL, $level = 1) { require_once('include/email.php'); $result = array(); @@ -804,13 +804,23 @@ function probe_url($url, $mode = PROBE_NORMAL) { logger('probe_url: ' . print_r($result,true), LOGGER_DEBUG); - // Trying if it maybe a diaspora account - if (($result['network'] == NETWORK_FEED) OR ($result['addr'] == "")) { - require_once('include/bbcode.php'); - $address = GetProfileUsername($url, "", true); - $result2 = probe_url($address, $mode); - if ($result2['network'] != "") - $result = $result2; + if ($level == 1) { + // Trying if it maybe a diaspora account + if (($result['network'] == NETWORK_FEED) OR ($result['addr'] == "")) { + require_once('include/bbcode.php'); + $address = GetProfileUsername($url, "", true); + $result2 = probe_url($address, $mode, ++$level); + if ($result2['network'] != "") + $result = $result2; + } + + // Maybe it's some non standard GNU Social installation (Single user, subfolder or no uri rewrite) + if (($result['network'] == NETWORK_FEED) AND ($result['baseurl'] != "") AND ($result['nick'] != "")) { + $addr = $result['nick'].'@'.str_replace("http://", "", $result['baseurl']); + $result2 = probe_url($addr, $mode, ++$level); + if (($result2['network'] != "") AND ($result2['network'] != NETWORK_FEED)) + $result = $result2; + } } Cache::set("probe_url:".$mode.":".$url,serialize($result)); From fa288173c3603e3b30b98800ceac3d3ce559a133 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 14 Jun 2015 10:56:57 +0200 Subject: [PATCH 4/5] OStatus: Force parent when storing item. --- include/ostatus.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/ostatus.php b/include/ostatus.php index 4e70514e54..74196b56a3 100644 --- a/include/ostatus.php +++ b/include/ostatus.php @@ -376,7 +376,7 @@ function ostatus_import($xml,$importer,&$contact, &$hub) { } else $item["parent-uri"] = $item["uri"]; - $item_id = item_store($item); + $item_id = item_store($item, true); //echo $xml; //print_r($item); //echo $item_id." ".$item["parent-uri"]."\n"; From 9ca04e4e6964ddae6daee8f691bc294b88f2436c Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 14 Jun 2015 11:39:15 +0200 Subject: [PATCH 5/5] Just a to-do added --- include/ostatus.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/ostatus.php b/include/ostatus.php index 74196b56a3..86d0e36dbe 100644 --- a/include/ostatus.php +++ b/include/ostatus.php @@ -376,6 +376,8 @@ function ostatus_import($xml,$importer,&$contact, &$hub) { } else $item["parent-uri"] = $item["uri"]; + // We risk the chance of getting orphan items, we correct it some lines later + // To-Do: See To-Do line below. $item_id = item_store($item, true); //echo $xml; //print_r($item); @@ -416,6 +418,9 @@ function ostatus_import($xml,$importer,&$contact, &$hub) { if ($conversation != "") { // Check for duplicates. We really don't need to check the same conversation twice. if (!in_array($conversation, $conversationlist)) { + // To-Do: + // Call this before item_store is called to avoid posts with orphans + // The routine then needs to get the item array. complete_conversation($item_id, $conversation); $conversationlist[] = $conversation; }