Add Delete delivery and some minor bug fixes
This commit is contained in:
parent
2d4e634fad
commit
a5b56b3089
@ -219,6 +219,36 @@ class ActivityPubPlugin extends Plugin
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify remote users when their notices get deleted
|
||||||
|
*
|
||||||
|
* @return boolean hook flag
|
||||||
|
*/
|
||||||
|
public function onEndDeleteOwnNotice ($user, $notice)
|
||||||
|
{
|
||||||
|
$profile = $user->getProfile ();
|
||||||
|
|
||||||
|
// Only distribute local users' delete actions, remote users
|
||||||
|
// will have already distributed theirs.
|
||||||
|
if (!$profile->isLocal ()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$other = array ();
|
||||||
|
foreach ($notice->getAttentionProfileIDs () as $to_id) {
|
||||||
|
try {
|
||||||
|
$other[] = Activitypub_profile::from_profile (Profile::getById ($to_id));
|
||||||
|
} catch (Exception $e) {
|
||||||
|
// Local user can be ignored
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$postman = new Activitypub_postman ($profile, $other);
|
||||||
|
|
||||||
|
$postman->delete ($notice);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,7 +30,7 @@ if (!defined ('GNUSOCIAL')) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Activitypub_notice::getByUri ($data->object)->deleteAs ($actor_profile);
|
Activitypub_notice::getKV ("url", $data->object)->deleteAs ($actor_profile);
|
||||||
$res = array ("@context" => "https://www.w3.org/ns/activitystreams",
|
$res = array ("@context" => "https://www.w3.org/ns/activitystreams",
|
||||||
"type" => "Delete",
|
"type" => "Delete",
|
||||||
"actor" => $data->actor,
|
"actor" => $data->actor,
|
||||||
|
@ -132,6 +132,29 @@ class Activitypub_postman
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a Delete notification to remote instances holding the notice
|
||||||
|
*
|
||||||
|
* @param Notice $notice
|
||||||
|
*/
|
||||||
|
public function delete ($notice)
|
||||||
|
{
|
||||||
|
$data = array ("@context" => "https://www.w3.org/ns/activitystreams",
|
||||||
|
"type" => "Delete",
|
||||||
|
"actor" => $this->actor->getUrl (),
|
||||||
|
"object" => $notice->getUrl ()
|
||||||
|
);
|
||||||
|
$this->client->setBody (json_encode ($data));
|
||||||
|
foreach ($this->to_inbox () as $inbox) {
|
||||||
|
$this->client->post ($inbox, $this->headers);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clean list of inboxes to deliver messages
|
||||||
|
*
|
||||||
|
* @return array To Inbox URLs
|
||||||
|
*/
|
||||||
private function to_inbox ()
|
private function to_inbox ()
|
||||||
{
|
{
|
||||||
$to_inboxes = array ();
|
$to_inboxes = array ();
|
||||||
|
Reference in New Issue
Block a user