aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib
diff options
context:
space:
mode:
authornobody <nobody@zotlabs.com>2021-05-31 14:36:14 -0700
committernobody <nobody@zotlabs.com>2021-05-31 14:36:14 -0700
commit462980c70a2698490d97a481cee0f2500dacb91c (patch)
tree4935db45ad6fbe37cd0af3b93bbb20ecb656c752 /Zotlabs/Lib
parenta96345401f47be71a6eef531e204c0e25b792a16 (diff)
parent217168628421f4e394b9b85e33d2d653d8b5b3d6 (diff)
downloadvolse-hubzilla-462980c70a2698490d97a481cee0f2500dacb91c.tar.gz
volse-hubzilla-462980c70a2698490d97a481cee0f2500dacb91c.tar.bz2
volse-hubzilla-462980c70a2698490d97a481cee0f2500dacb91c.zip
Merge branch 'dev' of https://framagit.org/hubzilla/core into dev
Diffstat (limited to 'Zotlabs/Lib')
-rw-r--r--Zotlabs/Lib/Activity.php12
-rw-r--r--Zotlabs/Lib/ActivityStreams.php2
-rw-r--r--Zotlabs/Lib/Enotify.php2
-rw-r--r--Zotlabs/Lib/Libzot.php20
-rw-r--r--Zotlabs/Lib/NativeWiki.php35
-rw-r--r--Zotlabs/Lib/NativeWikiPage.php29
6 files changed, 68 insertions, 32 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php
index 82e74fc83..6e8344def 100644
--- a/Zotlabs/Lib/Activity.php
+++ b/Zotlabs/Lib/Activity.php
@@ -132,8 +132,8 @@ class Activity {
}
static function fetch_profile($x) {
- $r = q("select * from xchan where xchan_url like '%s' limit 1",
- dbesc($x['id'] . '/%')
+ $r = q("select * from xchan where xchan_url = '%s' limit 1",
+ dbesc($x['id'])
);
if (!$r) {
$r = q("select * from xchan where xchan_hash = '%s' limit 1",
@@ -1360,16 +1360,14 @@ class Activity {
case 'Join':
// A second Follow request, but we haven't approved the first one
-
if ($contact['abook_pending']) {
return;
}
// We've already approved them or followed them first
// Send an Accept back to them
-
set_abconfig($channel['channel_id'], $person_obj['id'], 'pubcrawl', 'their_follow_id', $their_follow_id);
- Master::Summon(['Notifier', 'permissions_accept', $contact['abook_id']]);
+ Master::Summon(['Notifier', 'permission_accept', $contact['abook_id']]);
return;
case 'Accept':
@@ -1471,9 +1469,9 @@ class Activity {
if ($my_perms && $automatic) {
// send an Accept for this Follow activity
- Master::Summon(['Notifier', 'permissions_accept', $new_connection[0]['abook_id']]);
+ Master::Summon(['Notifier', 'permission_accept', $new_connection[0]['abook_id']]);
// Send back a Follow notification to them
- Master::Summon(['Notifier', 'permissions_create', $new_connection[0]['abook_id']]);
+ Master::Summon(['Notifier', 'permission_create', $new_connection[0]['abook_id']]);
}
$clone = [];
diff --git a/Zotlabs/Lib/ActivityStreams.php b/Zotlabs/Lib/ActivityStreams.php
index ba7ec0c65..a5fb4a756 100644
--- a/Zotlabs/Lib/ActivityStreams.php
+++ b/Zotlabs/Lib/ActivityStreams.php
@@ -304,7 +304,7 @@ class ActivityStreams {
// SECURITY: If we have already stored the actor profile, re-generate it
// from cached data - don't refetch it from the network
- $r = q("select * from xchan left join hubloc on xchan_hash = hubloc_hash where hubloc_id_url = '%s' limit 1",
+ $r = q("select * from xchan join hubloc on xchan_hash = hubloc_hash where hubloc_network in ('zot6', 'activitypub') and hubloc_id_url = '%s'",
dbesc($x)
);
if ($r) {
diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php
index ac782c740..7e33f09b8 100644
--- a/Zotlabs/Lib/Enotify.php
+++ b/Zotlabs/Lib/Enotify.php
@@ -983,7 +983,7 @@ class Enotify {
'photo' => z_root() . '/' . get_default_profile_photo(48),
'when' => datetime_convert('UTC', date_default_timezone_get(),$rr['reg_created']),
'hclass' => ('notify-unseen'),
- 'message' => t('verified')
+ 'message' => t('status verified')
];
return $x;
diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php
index db35dfb70..c7d001d21 100644
--- a/Zotlabs/Lib/Libzot.php
+++ b/Zotlabs/Lib/Libzot.php
@@ -2664,9 +2664,9 @@ class Libzot {
// we may only end up with one; which results in posts with no author name or photo and are a bit
// of a hassle to repair. If either or both are missing, do a full discovery probe.
- if (!array_key_exists('id', $x)) {
- return import_author_activitypub($x);
- }
+ //if (!array_key_exists('id', $x)) {
+ //return import_author_activitypub($x);
+ //}
$hash = self::make_xchan_hash($x['id'], $x['key']);
@@ -2924,7 +2924,19 @@ class Libzot {
];
$ret['channel_role'] = get_pconfig($e['channel_id'], 'system', 'permissions_role', 'custom');
- $ret['protocols'] = ['zot6', 'zot'];
+
+ $hookinfo = [
+ 'channel_id' => $id,
+ 'protocols' => ['zot6', 'zot']
+ ];
+ /**
+ * @hooks channel_protocols
+ * * \e int \b channel_id
+ * * \e array \b protocols
+ */
+ call_hooks('channel_protocols', $hookinfo);
+
+ $ret['protocols'] = $hookinfo['protocols'];
$ret['searchable'] = $searchable;
$ret['adult_content'] = $adult_channel;
$ret['public_forum'] = $public_forum;
diff --git a/Zotlabs/Lib/NativeWiki.php b/Zotlabs/Lib/NativeWiki.php
index c3032d02c..9e6a3ac85 100644
--- a/Zotlabs/Lib/NativeWiki.php
+++ b/Zotlabs/Lib/NativeWiki.php
@@ -101,6 +101,7 @@ class NativeWiki {
}
}
+
public static function update_wiki($channel_id, $observer_hash, $arr, $acl) {
$w = self::get_wiki($channel_id, $observer_hash, $arr['resource_id']);
@@ -156,8 +157,8 @@ class NativeWiki {
}
}
- public static function sync_a_wiki_item($uid,$id,$resource_id) {
+ public static function sync_a_wiki_item($uid,$id,$resource_id) {
$r = q("SELECT * from item WHERE uid = %d AND ( id = %d OR ( resource_type = '%s' and resource_id = '%s' )) ",
intval($uid),
@@ -165,8 +166,8 @@ class NativeWiki {
dbesc(NWIKI_ITEM_RESOURCE_TYPE),
dbesc($resource_id)
);
-
if($r) {
+
$q = q("select * from item where resource_type = 'nwikipage' and resource_id = '%s'",
dbesc($r[0]['resource_id'])
);
@@ -185,20 +186,27 @@ class NativeWiki {
}
}
+
public static function delete_wiki($channel_id,$observer_hash,$resource_id) {
$w = self::get_wiki($channel_id,$observer_hash,$resource_id);
- $item = $w['wiki'];
- if(! $item) {
- return array('item' => null, 'success' => false);
- }
- else {
- $drop = drop_item($item['id'], false, DROPITEM_NORMAL);
+ if(! $w['wiki']) {
+ return [ 'success' => false ];
}
+ else {
+
+ $r = q("SELECT id FROM item WHERE uid = %s AND resource_id = '%s'",
+ intval($channel_id),
+ dbesc($resource_id)
+ );
+
+ $ids = array_column($r, 'id');
+ drop_items($ids, true, DROPITEM_PHASE1);
- info( t('Wiki files deleted successfully'));
+ info(t('Wiki files deleted successfully'));
- return array('item' => $item, 'item_id' => $item['id'], 'success' => (($drop === 1) ? true : false));
+ return [ 'success' => true ];
+ }
}
@@ -207,13 +215,13 @@ class NativeWiki {
$sql_extra = item_permissions_sql($channel_id,$observer_hash);
$item = q("SELECT * FROM item WHERE uid = %d AND resource_type = '%s' AND resource_id = '%s' AND item_deleted = 0
- $sql_extra limit 1",
+ $sql_extra ORDER BY id LIMIT 1",
intval($channel_id),
dbesc(NWIKI_ITEM_RESOURCE_TYPE),
dbesc($resource_id)
);
if(! $item) {
- return array('wiki' => null);
+ return [ 'wiki' => null ];
}
else {
@@ -259,6 +267,7 @@ class NativeWiki {
public static function get_permissions($resource_id, $owner_id, $observer_hash) {
+
// TODO: For now, only the owner can edit
$sql_extra = item_permissions_sql($owner_id, $observer_hash);
@@ -283,6 +292,7 @@ class NativeWiki {
}
}
+
public static function name_encode ($string) {
$string = html_entity_decode($string);
@@ -298,6 +308,7 @@ class NativeWiki {
return $ret;
}
+
public static function name_decode ($string) {
$encoding = mb_internal_encoding();
diff --git a/Zotlabs/Lib/NativeWikiPage.php b/Zotlabs/Lib/NativeWikiPage.php
index 71f193b70..3c61ea800 100644
--- a/Zotlabs/Lib/NativeWikiPage.php
+++ b/Zotlabs/Lib/NativeWikiPage.php
@@ -109,6 +109,7 @@ class NativeWikiPage {
return [ 'success' => false, 'message' => t('Wiki page create failed.') ];
}
+
static public function rename_page($arr) {
$pageUrlName = ((array_key_exists('pageUrlName',$arr)) ? $arr['pageUrlName'] : '');
@@ -167,7 +168,9 @@ class NativeWikiPage {
}
+
static public function get_page_content($arr) {
+
$pageUrlName = ((array_key_exists('pageUrlName',$arr)) ? $arr['pageUrlName'] : '');
$resource_id = ((array_key_exists('resource_id',$arr)) ? $arr['resource_id'] : '');
$observer_hash = ((array_key_exists('observer_hash',$arr)) ? $arr['observer_hash'] : '');
@@ -198,7 +201,9 @@ class NativeWikiPage {
}
+
static public function page_history($arr) {
+
$pageUrlName = ((array_key_exists('pageUrlName',$arr)) ? $arr['pageUrlName'] : '');
$resource_id = ((array_key_exists('resource_id',$arr)) ? $arr['resource_id'] : '');
$observer_hash = ((array_key_exists('observer_hash',$arr)) ? $arr['observer_hash'] : '');
@@ -290,6 +295,7 @@ class NativeWikiPage {
return null;
}
+
static public function load_page_history($arr) {
$pageUrlName = ((array_key_exists('pageUrlName',$arr)) ? $arr['pageUrlName'] : '');
@@ -338,6 +344,7 @@ class NativeWikiPage {
return null;
}
+
static public function save_page($arr) {
$pageUrlName = ((array_key_exists('pageUrlName',$arr)) ? $arr['pageUrlName'] : '');
$content = ((array_key_exists('content',$arr)) ? $arr['content'] : '');
@@ -389,14 +396,15 @@ class NativeWikiPage {
return array('message' => t('Page update failed.'), 'success' => false);
}
+
static public function delete_page($arr) {
- $pageUrlName = ((array_key_exists('pageUrlName',$arr)) ? $arr['pageUrlName'] : '');
- $resource_id = ((array_key_exists('resource_id',$arr)) ? $arr['resource_id'] : '');
- $observer_hash = ((array_key_exists('observer_hash',$arr)) ? $arr['observer_hash'] : '');
- $channel_id = ((array_key_exists('channel_id',$arr)) ? $arr['channel_id'] : 0);
- $w = Zlib\NativeWiki::get_wiki($channel_id, $observer_hash, $resource_id);
+ $pageUrlName = (array_key_exists('pageUrlName',$arr) ? $arr['pageUrlName'] : '');
+ $resource_id = (array_key_exists('resource_id',$arr) ? $arr['resource_id'] : '');
+ $observer_hash = (array_key_exists('observer_hash',$arr) ? $arr['observer_hash'] : '');
+ $channel_id = (array_key_exists('channel_id',$arr) ? $arr['channel_id'] : 0);
+ $w = Zlib\NativeWiki::get_wiki($channel_id, $observer_hash, $resource_id);
if(! $w['wiki']) {
return [ 'success' => false, 'message' => t('Error reading wiki') ];
}
@@ -416,14 +424,16 @@ class NativeWikiPage {
}
if($ids) {
- drop_items($ids);
+ drop_items($ids, true, DROPITEM_PHASE1);
return [ 'success' => true ];
}
return [ 'success' => false, 'message' => t('Nothing deleted') ];
}
+
static public function revert_page($arr) {
+
$pageUrlName = ((array_key_exists('pageUrlName',$arr)) ? $arr['pageUrlName'] : '');
$resource_id = ((array_key_exists('resource_id',$arr)) ? $arr['resource_id'] : '');
$commitHash = ((array_key_exists('commitHash',$arr)) ? $arr['commitHash'] : null);
@@ -454,7 +464,9 @@ class NativeWikiPage {
}
}
+
static public function compare_page($arr) {
+
$pageUrlName = ((array_key_exists('pageUrlName',$arr)) ? $arr['pageUrlName'] : '');
$resource_id = ((array_key_exists('resource_id',$arr)) ? $arr['resource_id'] : '');
$currentCommit = ((array_key_exists('currentCommit',$arr)) ? $arr['currentCommit'] : (-1));
@@ -490,6 +502,7 @@ class NativeWikiPage {
}
+
static public function commit($arr) {
$commit_msg = ((array_key_exists('commit_msg', $arr)) ? $arr['commit_msg'] : t('Page updated'));
@@ -570,7 +583,6 @@ class NativeWikiPage {
}
-
/**
* Replace the instances of the string [toc] with a list element that will be populated by
* a table of contents by the JavaScript library
@@ -586,6 +598,7 @@ class NativeWikiPage {
return $s;
}
+
/**
* Converts a select set of bbcode tags. Much of the code is copied from include/bbcode.php
* @param string $s
@@ -625,7 +638,9 @@ class NativeWikiPage {
return $s;
}
+
static public function get_file_ext($arr) {
+
if($arr['mimetype'] === 'text/bbcode')
return '.bb';
elseif($arr['mimetype'] === 'text/markdown')