aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2022-01-28 20:03:30 +0000
committerMario <mario@mariovavti.com>2022-01-28 20:03:30 +0000
commit755076a8e55b734c8921418a829517ef5e07b52e (patch)
treeef341ce525f8ad887a85f31bac71a7782b8857da /Zotlabs/Lib
parentc2e21e837f3d3449a44e976bc6192863ba7e75d7 (diff)
parentb49f7b8b3441300c8dcd4f3f6fe51af7b31b8010 (diff)
downloadvolse-hubzilla-755076a8e55b734c8921418a829517ef5e07b52e.tar.gz
volse-hubzilla-755076a8e55b734c8921418a829517ef5e07b52e.tar.bz2
volse-hubzilla-755076a8e55b734c8921418a829517ef5e07b52e.zip
Merge branch 'dev'
Diffstat (limited to 'Zotlabs/Lib')
-rw-r--r--Zotlabs/Lib/AccessList.php9
-rw-r--r--Zotlabs/Lib/Activity.php56
-rw-r--r--Zotlabs/Lib/ActivityStreams.php1
-rw-r--r--Zotlabs/Lib/Permcat.php65
4 files changed, 78 insertions, 53 deletions
diff --git a/Zotlabs/Lib/AccessList.php b/Zotlabs/Lib/AccessList.php
index 03052fab5..026148c9f 100644
--- a/Zotlabs/Lib/AccessList.php
+++ b/Zotlabs/Lib/AccessList.php
@@ -160,8 +160,10 @@ class AccessList {
return false;
}
- static function member_remove($uid, $name, $member) {
- $gid = self::by_name($uid, $name);
+ static function member_remove($uid, $name, $member, $gid = 0) {
+ if (!$gid) {
+ $gid = self::by_name($uid, $name);
+ }
if (!($uid && $gid && $member)) {
return false;
@@ -192,7 +194,8 @@ class AccessList {
dbesc($member)
);
if ($r) {
- return true; // You might question this, but
+ return true;
+ // You might question this, but
// we indicate success because the group member was in fact created
// -- It was just created at another time
}
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php
index 2de25885a..74a146345 100644
--- a/Zotlabs/Lib/Activity.php
+++ b/Zotlabs/Lib/Activity.php
@@ -1748,7 +1748,7 @@ class Activity {
// update existing xchan record
q("update xchan set xchan_name = '%s', xchan_guid = '%s', xchan_pubkey = '%s', xchan_addr = '%s', xchan_network = 'activitypub', xchan_name_date = '%s' where xchan_hash = '%s'",
dbesc(escape_tags($name)),
- dbesc(escape_tags($url)),
+ dbesc($url),
dbesc(escape_tags($pubkey)),
dbesc(escape_tags($webfinger_addr)),
dbescdate(datetime_convert()),
@@ -1757,13 +1757,13 @@ class Activity {
// update existing hubloc record
q("update hubloc set hubloc_guid = '%s', hubloc_addr = '%s', hubloc_network = 'activitypub', hubloc_url = '%s', hubloc_host = '%s', hubloc_callback = '%s', hubloc_updated = '%s', hubloc_id_url = '%s' where hubloc_hash = '%s'",
- dbesc(escape_tags($url)),
+ dbesc($url),
dbesc(escape_tags($webfinger_addr)),
- dbesc(escape_tags($baseurl)),
- dbesc(escape_tags($hostname)),
- dbesc(escape_tags($inbox)),
+ dbesc($baseurl),
+ dbesc($hostname),
+ dbesc($inbox),
dbescdate(datetime_convert()),
- dbesc(escape_tags($profile)),
+ dbesc($profile),
dbesc($url)
);
}
@@ -1772,8 +1772,8 @@ class Activity {
xchan_store_lowlevel(
[
- 'xchan_hash' => escape_tags($url),
- 'xchan_guid' => escape_tags($url),
+ 'xchan_hash' => $url,
+ 'xchan_guid' => $url,
'xchan_pubkey' => escape_tags($pubkey),
'xchan_addr' => $webfinger_addr,
'xchan_url' => escape_tags($profile),
@@ -1785,16 +1785,16 @@ class Activity {
hubloc_store_lowlevel(
[
- 'hubloc_guid' => escape_tags($url),
- 'hubloc_hash' => escape_tags($url),
+ 'hubloc_guid' => $url,
+ 'hubloc_hash' => $url,
'hubloc_addr' => $webfinger_addr,
'hubloc_network' => 'activitypub',
- 'hubloc_url' => escape_tags($baseurl),
- 'hubloc_host' => escape_tags($hostname),
- 'hubloc_callback' => escape_tags($inbox),
+ 'hubloc_url' => $baseurl,
+ 'hubloc_host' => $hostname,
+ 'hubloc_callback' => $inbox,
'hubloc_updated' => datetime_convert(),
'hubloc_primary' => 1,
- 'hubloc_id_url' => escape_tags($profile)
+ 'hubloc_id_url' => $profile
]
);
}
@@ -2638,13 +2638,35 @@ class Activity {
}
}
- set_iconfig($s, 'activitypub', 'recips', $act->raw_recips);
+ $zot_rawmsg = '';
+ $raw_arr = [];
- $parent = (($s['parent_mid'] && $s['parent_mid'] === $s['mid']) ? true : false);
- if ($parent) {
+ $raw_arr = json_decode($act->raw, true);
+
+ // This is a zot6 packet and the raw activitypub message json
+ // is possibly available in the attachement.
+ if (array_key_exists('signed', $raw_arr) && is_array($act->obj) && is_array($act->obj['attachment'])) {
+ foreach($act->obj['attachment'] as $a) {
+ if (
+ isset($a['type']) && $a['type'] === 'PropertyValue' &&
+ isset($a['name']) && $a['name'] === 'zot.activitypub.rawmsg' &&
+ isset($a['value'])
+ ) {
+ $zot_rawmsg = $a['value'];
+ break;
+ }
+ }
+ }
+
+ if ($zot_rawmsg) {
+ set_iconfig($s, 'activitypub', 'rawmsg', $zot_rawmsg, 1);
+ }
+ else {
set_iconfig($s, 'activitypub', 'rawmsg', $act->raw, 1);
}
+ set_iconfig($s, 'activitypub', 'recips', $act->raw_recips);
+
$hookinfo = [
'act' => $act,
's' => $s
diff --git a/Zotlabs/Lib/ActivityStreams.php b/Zotlabs/Lib/ActivityStreams.php
index 09e1679ac..323b0e273 100644
--- a/Zotlabs/Lib/ActivityStreams.php
+++ b/Zotlabs/Lib/ActivityStreams.php
@@ -40,6 +40,7 @@ class ActivityStreams {
if (is_array($string)) {
$this->data = $string;
+ $this->raw = json_encode($string, JSON_UNESCAPED_SLASHES);
}
else {
$this->data = json_decode($string, true);
diff --git a/Zotlabs/Lib/Permcat.php b/Zotlabs/Lib/Permcat.php
index bda35a9cb..0a38ca324 100644
--- a/Zotlabs/Lib/Permcat.php
+++ b/Zotlabs/Lib/Permcat.php
@@ -4,7 +4,6 @@ namespace Zotlabs\Lib;
use Zotlabs\Access\PermissionRoles;
use Zotlabs\Access\Permissions;
-use Zotlabs\Lib\Libsync;
use Zotlabs\Daemon\Master;
/**
@@ -40,33 +39,33 @@ class Permcat {
// first check role perms for a perms_connect setting
- $role = get_pconfig($channel_id,'system','permissions_role');
- if($role) {
+ $role = get_pconfig($channel_id, 'system', 'permissions_role');
+ if ($role) {
$x = PermissionRoles::role_perms($role);
- if($x['perms_connect']) {
+ if ($x['perms_connect']) {
$perms = Permissions::FilledPerms($x['perms_connect']);
}
}
// if no role perms it may be a custom role, see if there any autoperms
- if(! $perms) {
+ if (!$perms) {
$perms = Permissions::FilledAutoPerms($channel_id);
}
// if no autoperms it may be a custom role with manual perms
- if(! $perms) {
+ if (!$perms) {
$r = q("select channel_hash from channel where channel_id = %d",
intval($channel_id)
);
- if($r) {
+ if ($r) {
$x = q("select * from abconfig where chan = %d and xchan = '%s' and cat = 'my_perms'",
intval($channel_id),
dbesc($r[0]['channel_hash'])
);
- if($x) {
- foreach($x as $xv) {
+ if ($x) {
+ foreach ($x as $xv) {
$perms[$xv['k']] = intval($xv['v']);
}
}
@@ -75,13 +74,13 @@ class Permcat {
// nothing was found - create a filled permission array where all permissions are 0
- if(! $perms) {
+ if (!$perms) {
$perms = Permissions::FilledPerms([]);
}
$this->permcats[] = [
'name' => 'default',
- 'localname' => t('Default','permcat'),
+ 'localname' => t('Default', 'permcat'),
'perms' => Permissions::Operms($perms),
'raw_perms' => $perms,
'system' => 1
@@ -89,8 +88,8 @@ class Permcat {
$p = $this->load_permcats($channel_id);
- if($p) {
- for($x = 0; $x < count($p); $x++) {
+ if ($p) {
+ for ($x = 0; $x < count($p); $x++) {
$this->permcats[] = [
'name' => $p[$x][0],
'localname' => $p[$x][1],
@@ -120,9 +119,9 @@ class Permcat {
* * \e bool \b error if $name not found in permcats true
*/
public function fetch($name) {
- if($name && $this->permcats) {
- foreach($this->permcats as $permcat) {
- if(strcasecmp($permcat['name'], $name) === 0) {
+ if ($name && $this->permcats) {
+ foreach ($this->permcats as $permcat) {
+ if (strcasecmp($permcat['name'], $name) === 0) {
return $permcat;
}
}
@@ -132,7 +131,7 @@ class Permcat {
}
public function load_permcats($uid) {
-/*
+ /*
$permcats = [
[ 'contributor', t('Contributor','permcat'),
[ 'view_stream','view_profile','view_contacts','view_storage','view_pages',
@@ -144,16 +143,16 @@ class Permcat {
'post_comments','write_wiki','post_like' ], 1
],
];
-*/
- if($uid) {
+ */
+ if ($uid) {
$x = q("select * from pconfig where uid = %d and cat = 'permcat'",
intval($uid)
);
- if($x) {
- foreach($x as $xv) {
- $value = ((preg_match('|^a:[0-9]+:{.*}$|s', $xv['v'])) ? unserialize($xv['v']) : $xv['v']);
- $permcats[] = [ $xv['k'], $xv['k'], $value, 0 ];
+ if ($x) {
+ foreach ($x as $xv) {
+ $value = ((preg_match('|^a:[0-9]+:{.*}$|s', $xv['v'])) ? unserialize($xv['v']) : $xv['v']);
+ $permcats[] = [$xv['k'], $xv['k'], $value, 0];
}
}
}
@@ -168,11 +167,11 @@ class Permcat {
}
static public function find_permcat($arr, $name) {
- if((! $arr) || (! $name))
+ if ((!$arr) || (!$name))
return false;
- foreach($arr as $p)
- if($p['name'] == $name)
+ foreach ($arr as $p)
+ if ($p['name'] == $name)
return $p['value'];
}
@@ -187,23 +186,23 @@ class Permcat {
/**
* @brief assign a contact role to contacts
*
- * @param int $channel_id
+ * @param array $channel
* @param string $role the name of the role
* @param array $contacts an array of contact hashes
*/
public static function assign($channel, $role, $contacts) {
- if(!isset($channel['channel_id'])) {
+ if (!isset($channel['channel_id'])) {
return;
}
- if(!is_array($contacts) || empty($contacts)) {
+ if (!is_array($contacts) || empty($contacts)) {
return;
}
- if(!$role) {
+ if (!$role) {
// lookup the default
- $role = get_pconfig($channel_id, 'system', 'default_permcat', 'default');
+ $role = get_pconfig($channel['channel_id'], 'system', 'default_permcat', 'default');
}
@@ -231,10 +230,10 @@ class Permcat {
foreach ($contacts as $contact) {
foreach ($all_perms as $perm => $desc) {
if (array_key_exists($perm, $perms)) {
- $values_sql .= " (" . intval($channel['channel_id']) . ", " . protect_sprintf($contact) . ", 'my_perms', '" . dbesc($perm) . "', " . intval($perms[$perm]) . "),";
+ $values_sql .= " (" . intval($channel['channel_id']) . ", " . protect_sprintf($contact) . ", 'my_perms', '" . dbesc($perm) . "', " . intval($perms[$perm]) . "),";
}
else {
- $values_sql .= " (" . intval($channel['channel_id']) . ", " . protect_sprintf($contact) . ", 'my_perms', '" . dbesc($perm) . "', 0), ";
+ $values_sql .= " (" . intval($channel['channel_id']) . ", " . protect_sprintf($contact) . ", 'my_perms', '" . dbesc($perm) . "', 0), ";
}
}
}