X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FProtocol%2FActivityPub%2FTransmitter.php;h=e44ae1cf66c2dfa4ff9413cc2b457d10fbb39279;hb=ce7ec11d1d40b21c68086962791f985d407f1cd1;hp=1d5192d93be6bb2286738b6ae6ead3a3d202d01c;hpb=a248da8f2e720243702426d27e9394ddbac9d0d2;p=friendica.git diff --git a/src/Protocol/ActivityPub/Transmitter.php b/src/Protocol/ActivityPub/Transmitter.php index 1d5192d93b..e44ae1cf66 100644 --- a/src/Protocol/ActivityPub/Transmitter.php +++ b/src/Protocol/ActivityPub/Transmitter.php @@ -386,7 +386,7 @@ class Transmitter } } } else { - $receiver_list = Item::enumeratePermissions($item); + $receiver_list = Item::enumeratePermissions($item, true); foreach ($terms as $term) { $cid = Contact::getIdForURL($term['url'], $item['uid']); @@ -1034,7 +1034,7 @@ class Transmitter // Simplify image codes $body = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $item['body']); - // Grab all pictures and create attachments out of them + // Grab all pictures without alternative descriptions and create attachments out of them if (preg_match_all("/\[img\]([^\[\]]*)\[\/img\]/Usi", $body, $pictures)) { foreach ($pictures[1] as $picture) { $imgdata = Image::getInfoFromURL($picture); @@ -1047,6 +1047,19 @@ class Transmitter } } + // Grab all pictures with alternative description and create attachments out of them + if (preg_match_all("/\[img=([^\[\]]*)\]([^\[\]]*)\[\/img\]/Usi", $body, $pictures, PREG_SET_ORDER)) { + foreach ($pictures as $picture) { + $imgdata = Image::getInfoFromURL($picture[1]); + if ($imgdata) { + $attachments[] = ['type' => 'Document', + 'mediaType' => $imgdata['mime'], + 'url' => $picture[1], + 'name' => $picture[2]]; + } + } + } + return $attachments; } @@ -1287,6 +1300,7 @@ class Transmitter */ private static function createAnnounce($item, $data) { + $orig_body = $item['body']; $announce = api_share_as_retweet($item); if (empty($announce['plink'])) { $data['type'] = 'Create'; @@ -1299,12 +1313,29 @@ class Transmitter if (!empty($activity)) { $ldactivity = JsonLD::compact($activity); $id = JsonLD::fetchElement($ldactivity, '@id'); + $type = str_replace('as:', '', JsonLD::fetchElement($ldactivity, '@type')); if (!empty($id)) { - $data['object'] = $id; + if (empty($announce['share-pre-body'])) { + // Pure announce, without a quote + $data['type'] = 'Announce'; + $data['object'] = $id; + return $data; + } + + // Quote + $data['type'] = 'Create'; + $item['body'] = trim($announce['share-pre-body']) . "\n" . $id; + $data['object'] = self::createNote($item); + + /// @todo Finally descide how to implement this in AP. This is a possible way: + $data['object']['attachment'][] = ['type' => $type, 'id' => $id]; + + $data['object']['source']['content'] = $orig_body; return $data; } } + $item['body'] = $orig_body; $data['type'] = 'Create'; $data['object'] = self::createNote($item); return $data;