fix follow id

This commit is contained in:
Mike Macgirvin 2024-08-20 06:24:01 +10:00
parent 082b8f7760
commit 4894de3c1c

View file

@ -2151,11 +2151,13 @@ class Activity
self::actor_store($person_obj['id'], $person_obj);
$actorId = new ActorId($person_obj['id']);
// Find any existing abook record
$r = q(
"select * from abook left join xchan on abook_xchan = xchan_hash where abook_xchan = '%s' and abook_channel = %d limit 1",
dbesc($person_obj['id']),
dbesc($actorId->getId()),
intval($channel['channel_id'])
);
if ($r) {
@ -2164,8 +2166,10 @@ class Activity
}
$x = PermissionRoles::role_perms('social');
logger('their_perms: ' . print_r($theirPerms, true));
if (!$theirPerms) {
$theirPerms = $x['perms_connect'];
}
// add tag_deliver permissions to remote groups (deprecated, use post_wall instead)
if (is_array($person_obj) && $person_obj['type'] === 'Group' && !in_array('tag_deliver', $theirPerms)) {
$theirPerms[] = 'tag_deliver';
@ -2187,11 +2191,11 @@ class Activity
// We've already approved them or followed them first
// Send an Accept back to them
set_abconfig($channel['channel_id'], $person_obj['id'], 'activitypub', 'their_follow_id', $their_follow_id);
set_abconfig($channel['channel_id'], $person_obj['id'], 'activitypub', 'their_follow_type', $act->type);
set_abconfig($channel['channel_id'], $actorId->getId(), 'activitypub', 'their_follow_id', $their_follow_id);
set_abconfig($channel['channel_id'], $actorId->getId(), 'activitypub', 'their_follow_type', $act->type);
// In case they unfollowed us and followed again, reset their permissions to show that we're connected again.
if ($theirPerms) {
AbConfig::Set($channel['channel_id'], $person_obj['id'], 'system', 'their_perms', implode(',', $theirPerms));
AbConfig::Set($channel['channel_id'], $actorId->getId(), 'system', 'their_perms', implode(',', $theirPerms));
}
Run::Summon(['Notifier', 'permissions_accept', $contact['abook_id']]);
return;
@ -2237,18 +2241,18 @@ class Activity
// From here on out we assume a Follow activity from somebody we have no existing relationship with
set_abconfig($channel['channel_id'], $person_obj['id'], 'activitypub', 'their_follow_id', $their_follow_id);
set_abconfig($channel['channel_id'], $person_obj['id'], 'activitypub', 'their_follow_type', $act->type);
set_abconfig($channel['channel_id'], $actorId->getId(), 'activitypub', 'their_follow_id', $their_follow_id);
set_abconfig($channel['channel_id'], $actorId->getId(), 'activitypub', 'their_follow_type', $act->type);
// The xchan should have been created by actor_store() above
$r = q(
"select * from xchan where xchan_hash = '%s' and xchan_network = 'activitypub' limit 1",
dbesc($person_obj['id'])
dbesc($actorId->getId())
);
if (!$r) {
logger('xchan not found for ' . $person_obj['id']);
logger('xchan not found for ' . $actorId->getId());
return;
}
$ret = $r[0];