From f0eceb03ed110d9d3c04a6c1c0acdc200d8ad3a3 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 16 Apr 2021 08:08:15 +0000 Subject: prepare Activity::follow() for pubcrawl --- Zotlabs/Lib/Activity.php | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'Zotlabs/Lib/Activity.php') diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php index fd4dc4286..82e74fc83 100644 --- a/Zotlabs/Lib/Activity.php +++ b/Zotlabs/Lib/Activity.php @@ -1323,12 +1323,12 @@ class Activity { * */ - $person_obj = $act->actor; - - if ($act->type === 'Follow') { + if (in_array($act->type, [ 'Follow', 'Invite', 'Join'])) { $their_follow_id = $act->id; } + $person_obj = (($act->type == 'Invite') ? $act->obj : $act->actor); + if (is_array($person_obj)) { // store their xchan and hubloc @@ -1346,9 +1346,8 @@ class Activity { } } - $x = PermissionRoles::role_perms('social'); - $p = Permissions::FilledPerms($x['perms_connect']); - $their_perms = Permissions::serialise($p); + $x = \Zotlabs\Access\PermissionRoles::role_perms('social'); + $their_perms = \Zotlabs\Access\Permissions::FilledPerms($x['perms_connect']); if ($contact && $contact['abook_id']) { @@ -1357,6 +1356,8 @@ class Activity { switch ($act->type) { case 'Follow': + case 'Invite': + case 'Join': // A second Follow request, but we haven't approved the first one @@ -1422,8 +1423,8 @@ class Activity { } $ret = $r[0]; - $p = Permissions::connect_perms($channel['channel_id']); - $my_perms = Permissions::serialise($p['perms']); + $p = \Zotlabs\Access\Permissions::connect_perms($channel['channel_id']); + $my_perms = $p['perms']; $automatic = $p['automatic']; $closeness = get_pconfig($channel['channel_id'], 'system', 'new_abook_closeness', 80); @@ -1443,12 +1444,13 @@ class Activity { ] ); - if ($my_perms) - set_abconfig($channel['channel_id'], $ret['xchan_hash'], 'system', 'my_perms', $my_perms); - - if ($their_perms) - set_abconfig($channel['channel_id'], $ret['xchan_hash'], 'system', 'their_perms', $their_perms); + if($my_perms) + foreach($my_perms as $k => $v) + set_abconfig($channel['channel_id'],$ret['xchan_hash'],'my_perms',$k,$v); + if($their_perms) + foreach($their_perms as $k => $v) + set_abconfig($channel['channel_id'],$ret['xchan_hash'],'their_perms',$k,$v); if ($r) { logger("New ActivityPub follower for {$channel['channel_name']}"); -- cgit v1.2.3