diff options
-rw-r--r-- | Zotlabs/Lib/Activity.php | 33 | ||||
-rw-r--r-- | Zotlabs/Lib/Enotify.php | 12 | ||||
-rw-r--r-- | Zotlabs/Module/Feed.php | 2 | ||||
-rw-r--r-- | Zotlabs/Module/Fhubloc_id_url.php | 58 | ||||
-rw-r--r-- | Zotlabs/Update/_1238.php | 28 | ||||
-rwxr-xr-x | boot.php | 2 | ||||
-rw-r--r-- | include/zot.php | 5 | ||||
-rw-r--r-- | view/js/main.js | 6 | ||||
-rw-r--r-- | view/tpl/notifications_widget.tpl | 8 |
9 files changed, 126 insertions, 28 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index b8432f95a..25f19510d 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -1456,11 +1456,35 @@ class Activity { $icon = $person_obj['icon']; } - if(is_array($person_obj['url']) && array_key_exists('href', $person_obj['url'])) - $profile = $person_obj['url']['href']; - else - $profile = $url; + $links = false; + $profile = false; + + if (is_array($person_obj['url'])) { + if (! array_key_exists(0,$person_obj['url'])) { + $links = [ $person_obj['url'] ]; + } + else { + $links = $person_obj['url']; + } + } + + if ($links) { + foreach ($links as $link) { + if (array_key_exists('mediaType',$link) && $link['mediaType'] === 'text/html') { + $profile = $link['href']; + } + } + if (! $profile) { + $profile = $links[0]['href']; + } + } + elseif (isset($person_obj['url']) && is_string($person_obj['url'])) { + $profile = $person_obj['url']; + } + if (! $profile) { + $profile = $url; + } $inbox = $person_obj['inbox']; @@ -1492,6 +1516,7 @@ class Activity { ); if(! $r) { // create a new record + $r = xchan_store_lowlevel( [ 'xchan_hash' => $url, diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index f706b0fb9..90c498d78 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -856,11 +856,11 @@ class Enotify { 'photo' => $item[$who]['xchan_photo_s'], 'when' => (($edit) ? datetime_convert('UTC', date_default_timezone_get(), $item['edited']) : datetime_convert('UTC', date_default_timezone_get(), $item['created'])), 'class' => (intval($item['item_unseen']) ? 'notify-unseen' : 'notify-seen'), - 'b64mid' => 'b64.' . base64url_encode($item['mid']), + 'b64mid' => (($item['mid']) ? 'b64.' . base64url_encode($item['mid']) : ''), //'b64mid' => ((in_array($item['verb'], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) ? 'b64.' . base64url_encode($item['thr_parent']) : 'b64.' . base64url_encode($item['mid'])), - 'notify_id' => 'undefined', 'thread_top' => (($item['item_thread_top']) ? true : false), 'message' => bbcode(escape_tags($itemem_text)), + 'body' => htmlentities(html2plain(bbcode($item['body'])), ENT_COMPAT, 'UTF-8', false), // these are for the superblock addon 'hash' => $item[$who]['xchan_hash'], 'uid' => $item['uid'], @@ -885,7 +885,6 @@ class Enotify { $mid = basename($tt['link']); $b64mid = ((strpos($mid, 'b64.') === 0) ? $mid : 'b64.' . base64url_encode($mid)); - $x = [ 'notify_link' => z_root() . '/notify/view/' . $tt['id'], 'name' => $tt['xname'], @@ -893,8 +892,8 @@ class Enotify { 'photo' => $tt['photo'], 'when' => datetime_convert('UTC', date_default_timezone_get(), $tt['created']), 'hclass' => (($tt['seen']) ? 'notify-seen' : 'notify-unseen'), - 'b64mid' => (($tt['otype'] == 'item') ? $b64mid : 'undefined'), - 'notify_id' => (($tt['otype'] == 'item') ? $tt['id'] : 'undefined'), + 'b64mid' => (($tt['otype'] == 'item') ? $b64mid : ''), + 'notify_id' => (($tt['otype'] == 'item') ? $tt['id'] : ''), 'message' => $message ]; @@ -980,8 +979,7 @@ class Enotify { $x = [ 'notify_link' => z_root() . '/admin/accounts', 'name' => $rr['account_email'], - 'addr' => $rr['account_email'], - 'url' => '', + //'addr' => $rr['account_email'], 'photo' => z_root() . '/' . get_default_profile_photo(48), 'when' => datetime_convert('UTC', date_default_timezone_get(),$rr['account_created']), 'hclass' => ('notify-unseen'), diff --git a/Zotlabs/Module/Feed.php b/Zotlabs/Module/Feed.php index 36869abbe..b5e7b28fa 100644 --- a/Zotlabs/Module/Feed.php +++ b/Zotlabs/Module/Feed.php @@ -17,7 +17,7 @@ class Feed extends \Zotlabs\Web\Controller { $params['pages'] = ((x($_REQUEST,'pages')) ? intval($_REQUEST['pages']) : 0); $params['top'] = ((x($_REQUEST,'top')) ? intval($_REQUEST['top']) : 0); $params['start'] = ((x($_REQUEST,'start')) ? intval($_REQUEST['start']) : 0); - $params['records'] = ((x($_REQUEST,'records')) ? intval($_REQUEST['records']) : 40); + $params['records'] = ((x($_REQUEST,'records')) ? intval($_REQUEST['records']) : 10); $params['direction'] = ((x($_REQUEST,'direction')) ? dbesc($_REQUEST['direction']) : 'desc'); $params['cat'] = ((x($_REQUEST,'cat')) ? escape_tags($_REQUEST['cat']) : ''); $params['compat'] = ((x($_REQUEST,'compat')) ? intval($_REQUEST['compat']) : 0); diff --git a/Zotlabs/Module/Fhubloc_id_url.php b/Zotlabs/Module/Fhubloc_id_url.php new file mode 100644 index 000000000..d332c7400 --- /dev/null +++ b/Zotlabs/Module/Fhubloc_id_url.php @@ -0,0 +1,58 @@ +<?php +namespace Zotlabs\Module; + +/* fix missing or hubloc_id_url entries */ + +class Fhubloc_id_url extends \Zotlabs\Web\Controller { + + function get() { + + if(! is_site_admin()) + return; + + // fix legacy zot hubloc_id_url + $r1 = dbq("UPDATE hubloc + SET hubloc_id_url = CONCAT(hubloc_url, '/channel/', SUBSTRING(hubloc_addr FROM 1 FOR POSITION('@' IN hubloc_addr) -1)) + WHERE hubloc_network = 'zot' + AND hubloc_id_url = ''" + ); + + // fix singleton networks hubloc_id_url + if(ACTIVE_DBTYPE == DBTYPE_MYSQL) { + // fix entries for activitypub which miss the xchan_url due to an earlier bug + $r2 = dbq("UPDATE xchan + SET xchan_url = xchan_hash + WHERE xchan_network = 'activitypub' + AND xchan_url = '' + AND xchan_hash != ''" + ); + + $r3 = dbq("UPDATE hubloc + LEFT JOIN xchan ON hubloc_hash = xchan_hash + SET hubloc_id_url = xchan_url + WHERE hubloc_network IN ('activitypub', 'diaspora', 'friendica-over-diaspora', 'gnusoc') + AND hubloc_id_url = ''" + ); + + } + if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { + // fix entries for activitypub which miss the xchan_url due to an earlier bug + $r2 = dbq("UPDATE xchan + SET xchan_url = xchan_hash + WHERE xchan_network = 'activitypub' + AND xchan_url = '' + AND xchan_hash != ''" + ); + + $r3 = dbq("UPDATE hubloc + SET hubloc_id_url = xchan_url + FROM xchan + WHERE hubloc_hash = xchan_hash + AND hubloc_network IN ('activitypub', 'diaspora', 'friendica-over-diaspora', 'gnusoc') + AND hubloc_id_url = ''" + ); + + + } + } +} diff --git a/Zotlabs/Update/_1238.php b/Zotlabs/Update/_1238.php index 77a14c3fa..32c21f161 100644 --- a/Zotlabs/Update/_1238.php +++ b/Zotlabs/Update/_1238.php @@ -21,26 +21,40 @@ class _1238 { // fix singleton networks hubloc_id_url if(ACTIVE_DBTYPE == DBTYPE_MYSQL) { - $r2 = dbq("UPDATE hubloc + // fix entries for activitypub which miss the xchan_url due to an earlier bug + $r2 = dbq("UPDATE xchan + SET xchan_url = xchan_hash + WHERE xchan_network = 'activitypub' + AND xchan_url = '' + AND xchan_hash != ''" + ); + + $r3 = dbq("UPDATE hubloc LEFT JOIN xchan ON hubloc_hash = xchan_hash SET hubloc_id_url = xchan_url WHERE hubloc_network IN ('activitypub', 'diaspora', 'friendica-over-diaspora', 'gnusoc') - AND hubloc_id_url = '' - AND xchan_url != ''" + AND hubloc_id_url = ''" ); } if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { - $r2 = dbq("UPDATE hubloc + // fix entries for activitypub which miss the xchan_url due to an earlier bug + $r2 = dbq("UPDATE xchan + SET xchan_url = xchan_hash + WHERE xchan_network = 'activitypub' + AND xchan_url = '' + AND xchan_hash != ''" + ); + + $r3 = dbq("UPDATE hubloc SET hubloc_id_url = xchan_url FROM xchan WHERE hubloc_hash = xchan_hash AND hubloc_network IN ('activitypub', 'diaspora', 'friendica-over-diaspora', 'gnusoc') - AND hubloc_id_url = '' - AND xchan_url != ''" + AND hubloc_id_url = ''" ); } - if($r1 && $r2) { + if($r1 && $r2 && $r3) { q("COMMIT"); return UPDATE_SUCCESS; } @@ -50,7 +50,7 @@ require_once('include/attach.php'); require_once('include/bbcode.php'); define ( 'PLATFORM_NAME', 'hubzilla' ); -define ( 'STD_VERSION', '4.7.10' ); +define ( 'STD_VERSION', '4.7.12' ); define ( 'ZOT_REVISION', '6.0' ); define ( 'DB_UPDATE_VERSION', 1238 ); diff --git a/include/zot.php b/include/zot.php index fb0804aa7..e10ef6fd7 100644 --- a/include/zot.php +++ b/include/zot.php @@ -2763,6 +2763,8 @@ function sync_locations($sender, $arr, $absolute = false) { } logger('New hub: ' . $location['url']); + $addr_arr = explode('@', $location['address']); + $r = hubloc_store_lowlevel( [ 'hubloc_guid' => $sender['guid'], @@ -2777,7 +2779,8 @@ function sync_locations($sender, $arr, $absolute = false) { 'hubloc_callback' => $location['callback'], 'hubloc_sitekey' => $location['sitekey'], 'hubloc_updated' => datetime_convert(), - 'hubloc_connected' => datetime_convert() + 'hubloc_connected' => datetime_convert(), + 'hubloc_id_url' => $location['url'] . '/channel/' . $addr_arr[0] ] ); diff --git a/view/js/main.js b/view/js/main.js index f6a009937..4d3b2d770 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -971,7 +971,7 @@ function liveUpdate(notify_id) { var orgHeight = $("#region_2").height(); } - if(page_cache.data && bParam_page == page_cache.page && page_cache.time > (Date.now() - 90000)) { + if(page_cache.data && bParam_page == page_cache.page && page_cache.time > (Date.now() - 180000)) { page_load = false; scroll_next = false; updateConvItems(update_mode,page_cache.data); @@ -1550,7 +1550,7 @@ String.prototype.format = function() { var formatted = this; for (var i = 0; i < arguments.length; i++) { var regexp = new RegExp('\\{'+i+'\\}', 'gi'); - formatted = formatted.replace(regexp, arguments[i]); + formatted = formatted.replace(regexp, ((typeof arguments[i] !== 'undefined') ? arguments[i] : '')); } return formatted; }; @@ -1876,7 +1876,7 @@ function sse_handleNotificationsItems(notifyType, data, replace, followup) { } $(data).each(function() { - html = notifications_tpl.format(this.notify_link,this.photo,this.name,this.addr,this.message,this.when,this.hclass,this.b64mid,this.notify_id,this.thread_top,this.unseen,this.private_forum, encodeURIComponent(this.mids)); + html = notifications_tpl.format(this.notify_link,this.photo,this.name,this.addr,this.message,this.when,this.hclass,this.b64mid,this.notify_id,this.thread_top,this.unseen,this.private_forum, encodeURIComponent(this.mids), this.body); notify_menu.append(html); }); diff --git a/view/tpl/notifications_widget.tpl b/view/tpl/notifications_widget.tpl index bf2c4c945..d8cc76ccb 100644 --- a/view/tpl/notifications_widget.tpl +++ b/view/tpl/notifications_widget.tpl @@ -36,12 +36,12 @@ var path = $(this)[0].pathname.substr(1,7); var stateObj = { b64mid: b64mid }; - if(b64mid === 'undefined' && notify_id === 'undefined') + if(! b64mid && ! notify_id) return; {{if $module != 'hq' && $startpage == 'hq'}} e.preventDefault(); - if(typeof notify_id !== 'undefined' && notify_id !== 'undefined') { + if(notify_id != null) { $.post( "hq", { @@ -142,9 +142,9 @@ {{$no_notifications}}<span class="jumping-dots"><span class="dot-1">.</span><span class="dot-2">.</span><span class="dot-3">.</span></span> </div> <div id="nav-notifications-template" rel="template"> - <a class="list-group-item clearfix notification {6}" href="{0}" title="{3}" data-b64mid="{7}" data-notify_id="{8}" data-thread_top="{9}" data-contact_name="{2}" data-contact_addr="{3}" data-when="{5}"> + <a class="list-group-item clearfix notification {6}" href="{0}" title="{13}" data-b64mid="{7}" data-notify_id="{8}" data-thread_top="{9}" data-contact_name="{2}" data-contact_addr="{3}" data-when="{5}"> <img class="menu-img-3" src="{1}"> - <span class="contactname">{2}</span> + <span class="contactname">{2} <span class="font-weight-normal text-muted">{3}</span></span> <span class="dropdown-sub-text">{4}</span><br> <span class="dropdown-sub-text notifications-autotime" title="{5}">{5}</span> </a> |