We can delete notes / changed credits

This commit is contained in:
Michael 2018-09-23 09:20:25 +00:00
parent 6df6d82427
commit feeec908d3
3 changed files with 23 additions and 8 deletions

View File

@ -34,10 +34,6 @@ use Friendica\Util\LDSignature;
* *
* Digest: https://tools.ietf.org/html/rfc5843 * Digest: https://tools.ietf.org/html/rfc5843
* https://tools.ietf.org/html/draft-cavage-http-signatures-10#ref-15 * https://tools.ietf.org/html/draft-cavage-http-signatures-10#ref-15
* https://github.com/digitalbazaar/php-json-ld
*
* Part of the code for HTTP signing is taken from the Osada project.
* https://framagit.org/macgirvin/osada
* *
* To-do: * To-do:
* *
@ -46,8 +42,8 @@ use Friendica\Util\LDSignature;
* - Object Types: Person, Tombstome * - Object Types: Person, Tombstome
* *
* Transmitter: * Transmitter:
* - Activities: Announce, Delete Notes * - Activities: Announce
* - Object Tyoes: Person, Tombstone * - Object Tyoes: Person
* *
* General: * General:
* - Endpoints: Outbox, Follower, Following * - Endpoints: Outbox, Follower, Following
@ -344,8 +340,10 @@ class ActivityPub
'atomUri' => 'ostatus:atomUri', 'conversation' => 'ostatus:conversation', 'atomUri' => 'ostatus:atomUri', 'conversation' => 'ostatus:conversation',
'inReplyToAtomUri' => 'ostatus:inReplyToAtomUri']]]; 'inReplyToAtomUri' => 'ostatus:inReplyToAtomUri']]];
if ($item['deleted']) { if ($item['deleted'] && ($item['gravity'] == GRAVITY_ACTIVITY)) {
$type = 'Undo'; $type = 'Undo';
} elseif ($item['deleted']) {
$type = 'Delete';
} }
} else { } else {
$data = []; $data = [];
@ -365,7 +363,7 @@ class ActivityPub
$data = array_merge($data, ActivityPub::createPermissionBlockForItem($item)); $data = array_merge($data, ActivityPub::createPermissionBlockForItem($item));
if (in_array($data['type'], ['Create', 'Update', 'Announce'])) { if (in_array($data['type'], ['Create', 'Update', 'Announce', 'Delete'])) {
$data['object'] = self::CreateNote($item); $data['object'] = self::CreateNote($item);
} elseif ($data['type'] == 'Undo') { } elseif ($data['type'] == 'Undo') {
$data['object'] = self::createActivityFromItem($item_id, true); $data['object'] = self::createActivityFromItem($item_id, true);
@ -441,9 +439,18 @@ class ActivityPub
$type = 'Note'; $type = 'Note';
} }
if ($item['deleted']) {
$type = 'Tombstone';
}
$data = []; $data = [];
$data['id'] = $item['uri']; $data['id'] = $item['uri'];
$data['type'] = $type; $data['type'] = $type;
if ($item['deleted']) {
return $data;
}
$data['summary'] = null; // Ignore by now $data['summary'] = null; // Ignore by now
if ($item['uri'] != $item['thr-parent']) { if ($item['uri'] != $item['thr-parent']) {

View File

@ -16,6 +16,9 @@ use Friendica\Protocol\ActivityPub;
* *
* Ported from Hubzilla: https://framagit.org/hubzilla/core/blob/master/Zotlabs/Web/HTTPSig.php * Ported from Hubzilla: https://framagit.org/hubzilla/core/blob/master/Zotlabs/Web/HTTPSig.php
* *
* Other parts of the code for HTTP signing are taken from the Osada project.
* https://framagit.org/macgirvin/osada
*
* @see https://tools.ietf.org/html/draft-cavage-http-signatures-07 * @see https://tools.ietf.org/html/draft-cavage-http-signatures-07
*/ */

View File

@ -6,6 +6,11 @@ use Friendica\Util\JsonLD;
use Friendica\Util\DateTimeFormat; use Friendica\Util\DateTimeFormat;
use Friendica\Protocol\ActivityPub; use Friendica\Protocol\ActivityPub;
/**
* @brief Implements JSON-LD signatures
*
* Ported from Osada: https://framagit.org/macgirvin/osada
*/
class LDSignature class LDSignature
{ {
public static function isSigned($data) public static function isSigned($data)