mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-20 05:35:12 +00:00
support mastodon account move notifications
This commit is contained in:
parent
29a4777452
commit
dbf477f3d8
3 changed files with 59 additions and 1 deletions
|
@ -1356,8 +1356,9 @@ class Activity {
|
|||
|
||||
static function actor_store($url,$person_obj) {
|
||||
|
||||
if (! is_array($person_obj))
|
||||
if (! is_array($person_obj)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// logger('person_obj: ' . print_r($person_obj,true));
|
||||
|
||||
|
@ -1373,6 +1374,13 @@ class Activity {
|
|||
}
|
||||
}
|
||||
|
||||
if (array_key_exists('movedTo',$person_obj) && $person_obj['movedTo'] && ! is_array($person_obj['movedTo'])) {
|
||||
$tgt = self::fetch($person_obj['movedTo']);
|
||||
self::actor_store($person_obj['movedTo'],$tgt);
|
||||
ActivityPub::move($person_obj['id'],$tgt);
|
||||
return;
|
||||
}
|
||||
|
||||
$url = $person_obj['id'];
|
||||
|
||||
if (! $url) {
|
||||
|
|
|
@ -421,4 +421,48 @@ class ActivityPub {
|
|||
return false;
|
||||
}
|
||||
|
||||
static public function move($src,$dst) {
|
||||
|
||||
if (! ($src && $dst)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($src && ! is_array($src)) {
|
||||
$src = Activity::fetch($src);
|
||||
if (is_array($src)) {
|
||||
$src_xchan = $src['id'];
|
||||
}
|
||||
}
|
||||
|
||||
$approvals = null;
|
||||
|
||||
if ($dst && ! is_array($dst)) {
|
||||
$dst = Activity::fetch($dst);
|
||||
if (is_array($dst)) {
|
||||
$dst_xchan = $dst['id'];
|
||||
if (array_key_exists('alsoKnownAs',$dst)) {
|
||||
if(! is_array($dst['alsoKnownAs'])) {
|
||||
$dst['alsoKnownAs'] = [ $dst['alsoKnownAs'] ];
|
||||
}
|
||||
$approvals = $dst['alsoKnownAs'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(! ($src_xchan && $dst_xchan)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($approvals) {
|
||||
foreach($approvals as $approval) {
|
||||
if($approval === $src_xchan) {
|
||||
$r = q("update abook set abook_xchan = '%s' where abook_xchan = '%s'",
|
||||
dbesc($dst_xchan),
|
||||
dbesc($src_xchan)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -242,6 +242,12 @@ class Inbox extends Controller {
|
|||
case 'Delete':
|
||||
Activity::drop($channel,$observer_hash,$AS);
|
||||
break;
|
||||
|
||||
case 'Move':
|
||||
if($observer_hash && $observer_hash === $AS->actor && Activity::is_an_actor($AS->obj) && Activity::is_an_actor($AS->tgt)) {
|
||||
ActivityPub::move($AS->obj,$AS->tgt);
|
||||
}
|
||||
break;
|
||||
case 'Add':
|
||||
case 'Remove':
|
||||
default:
|
||||
|
|
Loading…
Reference in a new issue