Merge pull request #871 from pixelfed/frontend-ui-refactor

Update ActivityPub Inbox
This commit is contained in:
daniel 2019-02-24 20:46:28 -07:00 committed by GitHub
commit cc54eca212
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -185,9 +185,7 @@ class Inbox
'following_id' => $target->id, 'following_id' => $target->id,
'local_profile' => empty($actor->domain) 'local_profile' => empty($actor->domain)
]); ]);
if($follower->wasRecentlyCreated == false) { if($follower->wasRecentlyCreated == true) {
return;
}
// send notification // send notification
Notification::firstOrCreate([ Notification::firstOrCreate([
'profile_id' => $target->id, 'profile_id' => $target->id,
@ -198,6 +196,7 @@ class Inbox
'item_id' => $target->id, 'item_id' => $target->id,
'item_type' => 'App\Profile' 'item_type' => 'App\Profile'
]); ]);
}
// send Accept to remote profile // send Accept to remote profile
$accept = [ $accept = [
@ -248,7 +247,28 @@ class Inbox
public function handleAcceptActivity() public function handleAcceptActivity()
{ {
$actor = $this->payload['actor'];
$obj = $this->payload['object'];
switch ($obj['type']) {
case 'Follow':
$accept = [
'@context' => 'https://www.w3.org/ns/activitystreams',
'id' => $target->permalink().'#accepts/follows/' . $follower->id,
'type' => 'Accept',
'actor' => $target->permalink(),
'object' => [
'id' => $actor->permalink('#follows/'.$target->id),
'type' => 'Follow',
'actor' => $actor->permalink(),
'object' => $target->permalink()
]
];
break;
default:
# code...
break;
}
} }
public function handleDeleteActivity() public function handleDeleteActivity()
@ -298,11 +318,7 @@ class Inbox
$obj = $this->payload['object']; $obj = $this->payload['object'];
switch ($obj['type']) { switch ($obj['type']) {
case 'Like': case 'Accept':
$status = Helpers::statusFirstOrFetch($obj['object']);
Like::whereProfileId($profile->id)
->whereStatusId($status->id)
->forceDelete();
break; break;
case 'Announce': case 'Announce':
@ -318,6 +334,29 @@ class Inbox
->forceDelete(); ->forceDelete();
$status->forceDelete(); $status->forceDelete();
break; break;
case 'Block':
break;
case 'Follow':
$following = self::actorFirstOrCreate($obj['object']);
Follower::whereProfileId($profile->id)
->whereFollowingId($following->id)
->delete();
break;
case 'Like':
$status = Helpers::statusFirstOrFetch($obj['object']);
Like::whereProfileId($profile->id)
->whereStatusId($status->id)
->forceDelete();
Notification::whereProfileId($status->profile->id)
->whereActorId($profile->id)
->whereAction('like')
->whereItemId($status->id)
->whereItemType('App\Status')
->forceDelete();
break;
} }
} }