]> git.mxchange.org Git - friendica.git/commitdiff
Store "audience" and "attributedTo" data
authorMichael <heluecht@pirati.ca>
Fri, 14 Apr 2023 17:21:20 +0000 (17:21 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 14 Apr 2023 17:21:20 +0000 (17:21 +0000)
src/Content/Conversation.php
src/Model/Item.php
src/Model/Tag.php
src/Module/PermissionTooltip.php
src/Protocol/ActivityPub/ClientToServer.php
src/Protocol/ActivityPub/Processor.php
src/Protocol/ActivityPub/Receiver.php
view/lang/C/messages.po

index 458a0a690f19fe97ed5a481723cc4d9b2340e0fd..6e7820a6f0cadc461eae0d3a0b62fc45508d233b 100644 (file)
@@ -873,6 +873,9 @@ class Conversation
                        case ItemModel::PR_BCC:
                                $row['direction'] = ['direction' => 7, 'title' => $this->l10n->t('You had been addressed (%s).', 'bcc')];
                                break;
+                       case ItemModel::PR_AUDIENCE:
+                               $row['direction'] = ['direction' => 7, 'title' => $this->l10n->t('You had been addressed (%s).', 'audience')];
+                               break;
                        case ItemModel::PR_FOLLOWER:
                                $row['direction'] = ['direction' => 6, 'title' => $this->l10n->t('You are following %s.', $row['causer-name'] ?: $row['author-name'])];
                                break;
index d7de9ca49635fd3eae1286744edfb93eba69b721..89446c492bc01697dcad8114d925290575426d73 100644 (file)
@@ -79,6 +79,7 @@ class Item
        const PR_DISTRIBUTE = 79;
        const PR_PUSHED = 80;
        const PR_LOCAL = 81;
+       const PR_AUDIENCE = 82;
 
        // system.accept_only_sharer setting values
        const COMPLETION_NONE    = 1;
@@ -1624,7 +1625,7 @@ class Item
 
                if (($uid != 0) && (($item['gravity'] == self::GRAVITY_PARENT) || $is_reshare) &&
                        DI::pConfig()->get($uid, 'system', 'accept_only_sharer') == self::COMPLETION_NONE &&
-                       !in_array($item['post-reason'], [self::PR_FOLLOWER, self::PR_TAG, self::PR_TO, self::PR_CC, self::PR_ACTIVITY])) {
+                       !in_array($item['post-reason'], [self::PR_FOLLOWER, self::PR_TAG, self::PR_TO, self::PR_CC, self::PR_ACTIVITY, self::PR_AUDIENCE])) {
                        Logger::info('Contact is not a follower, thread will not be stored', ['author' => $item['author-link'], 'uid' => $uid, 'uri-id' => $uri_id, 'post-reason' => $item['post-reason']]);
                        return 0;
                }
index 0e891f9c6f27870e314aa75a7b8e74329f3e94ff..215d817133554a078519ef92d24a86a80ee71a95 100644 (file)
@@ -54,10 +54,12 @@ class Tag
         */
        const EXCLUSIVE_MENTION = 9;
 
-       const TO  = 10;
-       const CC  = 11;
-       const BTO = 12;
-       const BCC = 13;
+       const TO         = 10;
+       const CC         = 11;
+       const BTO        = 12;
+       const BCC        = 13;
+       const AUDIENCE   = 14;
+       const ATTRIBUTED = 15;
 
        const ACCOUNT             = 1;
        const GENERAL_COLLECTION  = 2;
@@ -103,7 +105,7 @@ class Tag
                $cid = 0;
                $tagid = 0;
 
-               if (in_array($type, [self::MENTION, self::EXCLUSIVE_MENTION, self::IMPLICIT_MENTION, self::TO, self::CC, self::BTO, self::BCC])) {
+               if (in_array($type, [self::MENTION, self::EXCLUSIVE_MENTION, self::IMPLICIT_MENTION, self::TO, self::CC, self::BTO, self::BCC, self::AUDIENCE, self::ATTRIBUTED])) {
                        if (empty($url)) {
                                // No mention without a contact url
                                return;
@@ -130,7 +132,7 @@ class Tag
                }
 
                if (empty($cid)) {
-                       if (!in_array($type, [self::TO, self::CC, self::BTO, self::BCC])) {
+                       if (!in_array($type, [self::TO, self::CC, self::BTO, self::BCC, self::AUDIENCE, self::ATTRIBUTED])) {
                                if (($type != self::HASHTAG) && !empty($url) && ($url != $name)) {
                                        $url = strtolower($url);
                                } else {
index ad5c11cc05740e886e426017fdd2ef8ce5492503..41cc8e0e9556713939e3230e53172562ad3cdc22 100644 (file)
@@ -190,7 +190,7 @@ class PermissionTooltip extends \Friendica\BaseModule
                }
 
                $receivers = [];
-               foreach (Tag::getByURIId($uriId, [Tag::TO, Tag::CC, Tag::BCC]) as $receiver) {
+               foreach (Tag::getByURIId($uriId, [Tag::TO, Tag::CC, Tag::BCC, Tag::AUDIENCE, Tag::ATTRIBUTED]) as $receiver) {
                        // We only display BCC when it contains the current user
                        if (($receiver['type'] == Tag::BCC) && ($receiver['url'] != $own_url)) {
                                continue;
@@ -236,7 +236,13 @@ class PermissionTooltip extends \Friendica\BaseModule
                                case Tag::BCC:
                                        $output .= DI::l10n()->t('<b>BCC:</b> %s<br>', implode(', ', $receiver));
                                        break;
-                       }
+                               case Tag::AUDIENCE:
+                                       $output .= DI::l10n()->t('<b>Audience:</b> %s<br>', implode(', ', $receiver));
+                                       break;
+                               case Tag::ATTRIBUTED:
+                                       $output .= DI::l10n()->t('<b>Attributed To:</b> %s<br>', implode(', ', $receiver));
+                                       break;
+                               }
                }
 
                return $output;
index 48a5cfdec5aed3f5ccc23dcbf91769d216723357..fed0bc55b1ae2579bf8f80a02d8d89f1f3e6b4ec 100644 (file)
@@ -208,7 +208,7 @@ class ClientToServer
 
                $targets = [];
 
-               foreach (['as:to', 'as:cc', 'as:bto', 'as:bcc'] as $element) {
+               foreach (['as:to', 'as:cc', 'as:bto', 'as:bcc', 'as:audience'] as $element) {
                        switch ($element) {
                                case 'as:to':
                                        $type = Receiver::TARGET_TO;
@@ -222,7 +222,10 @@ class ClientToServer
                                case 'as:bcc':
                                        $type = Receiver::TARGET_BCC;
                                        break;
-                       }
+                               case 'as:audience':
+                                       $type = Receiver::TARGET_AUDIENCE;
+                                       break;
+                               }
                        $receiver_list = JsonLD::fetchElementArray($object, $element, '@id');
                        if (empty($receiver_list)) {
                                continue;
index 86394bd91c8166d047cc195cdfdc38eab137d65c..b8d4005a6131df06c35677e79023ca7377611dbc 100644 (file)
@@ -1026,6 +1026,9 @@ class Processor
                                case Receiver::TARGET_BCC:
                                        $item['post-reason'] = Item::PR_BCC;
                                        break;
+                               case Receiver::TARGET_AUDIENCE:
+                                       $item['post-reason'] = Item::PR_AUDIENCE;
+                                       break;
                                case Receiver::TARGET_FOLLOWER:
                                        $item['post-reason'] = Item::PR_FOLLOWER;
                                        break;
@@ -1071,7 +1074,7 @@ class Processor
                                continue;
                        }
 
-                       if (($receiver != 0) && ($item['gravity'] == Item::GRAVITY_PARENT) && !in_array($item['post-reason'], [Item::PR_FOLLOWER, Item::PR_TAG, item::PR_TO, Item::PR_CC])) {
+                       if (($receiver != 0) && ($item['gravity'] == Item::GRAVITY_PARENT) && !in_array($item['post-reason'], [Item::PR_FOLLOWER, Item::PR_TAG, item::PR_TO, Item::PR_CC, Item::PR_AUDIENCE])) {
                                if (!($item['isForum'] ?? false)) {
                                        if ($item['post-reason'] == Item::PR_BCC) {
                                                Logger::info('Top level post via BCC from a non sharer, ignoring', ['uid' => $receiver, 'contact' => $item['contact-id'], 'url' => $item['uri']]);
@@ -1274,7 +1277,7 @@ class Processor
 
        public static function storeReceivers(int $uriid, array $receivers)
        {
-               foreach (['as:to' => Tag::TO, 'as:cc' => Tag::CC, 'as:bto' => Tag::BTO, 'as:bcc' => Tag::BCC] as $element => $type) {
+               foreach (['as:to' => Tag::TO, 'as:cc' => Tag::CC, 'as:bto' => Tag::BTO, 'as:bcc' => Tag::BCC, 'as:audience' => Tag::AUDIENCE, 'as:attributedTo' => Tag::ATTRIBUTED] as $element => $type) {
                        if (!empty($receivers[$element])) {
                                foreach ($receivers[$element] as $receiver) {
                                        if ($receiver == ActivityPub::PUBLIC_COLLECTION) {
index 4bba5f5da8914a73fe3dfbf3a492907753b4042e..204e631c9bf01196f81542d6cc7d986edfcf623d 100644 (file)
@@ -73,6 +73,7 @@ class Receiver
        const TARGET_FOLLOWER = 5;
        const TARGET_ANSWER = 6;
        const TARGET_GLOBAL = 7;
+       const TARGET_AUDIENCE = 8;
 
        const COMPLETION_NONE     = 0;
        const COMPLETION_ANNOUNCE = 1;
@@ -487,7 +488,7 @@ class Receiver
                        $object_data['object_type'] = $object_type;
                }
 
-               foreach (['as:to', 'as:cc', 'as:bto', 'as:bcc'] as $element) {
+               foreach (['as:to', 'as:cc', 'as:bto', 'as:bcc', 'as:audience', 'as:attributedTo'] as $element) {
                        if ((empty($object_data['receiver_urls'][$element]) || in_array($element, ['as:bto', 'as:bcc'])) && !empty($urls[$element])) {
                                $object_data['receiver_urls'][$element] = array_unique(array_merge($object_data['receiver_urls'][$element] ?? [], $urls[$element]));
                        }
@@ -1032,7 +1033,7 @@ class Receiver
        {
                $urls = [];
 
-               foreach (['as:to', 'as:cc', 'as:bto', 'as:bcc'] as $element) {
+               foreach (['as:to', 'as:cc', 'as:bto', 'as:bcc', 'as:audience', 'as:attributedTo'] as $element) {
                        $receiver_list = JsonLD::fetchElementArray($activity, $element, '@id');
                        if (empty($receiver_list)) {
                                continue;
@@ -1104,7 +1105,7 @@ class Receiver
                // We have to prevent false follower assumptions upon thread completions
                $follower_target = empty($activity['thread-completion']) ? self::TARGET_FOLLOWER : self::TARGET_UNKNOWN;
 
-               foreach (['as:to', 'as:cc', 'as:bto', 'as:bcc'] as $element) {
+               foreach (['as:to', 'as:cc', 'as:bto', 'as:bcc','as:audience'] as $element) {
                        $receiver_list = JsonLD::fetchElementArray($activity, $element, '@id');
                        if (empty($receiver_list)) {
                                continue;
@@ -1165,7 +1166,10 @@ class Receiver
                                                case 'as:bcc':
                                                        $type = self::TARGET_BCC;
                                                        break;
-                                       }
+                                               case 'as:audience':
+                                                       $type = self::TARGET_AUDIENCE;
+                                                       break;
+                                               }
 
                                        $receivers[$contact['uid']] = ['uid' => $contact['uid'], 'type' => $type];
                                }
index 7d21741b96f44442450b757bc89e4ef93b81dc3c..e016266561afa5b54662c9ffc0390d9df50c9c4d 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: 2023.03-rc\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2023-04-09 08:27-0400\n"
+"POT-Creation-Date: 2023-04-14 17:15+0000\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -1388,81 +1388,82 @@ msgstr ""
 
 #: src/Content/Conversation.php:865 src/Content/Conversation.php:868
 #: src/Content/Conversation.php:871 src/Content/Conversation.php:874
+#: src/Content/Conversation.php:877
 #, php-format
 msgid "You had been addressed (%s)."
 msgstr ""
 
-#: src/Content/Conversation.php:877
+#: src/Content/Conversation.php:880
 #, php-format
 msgid "You are following %s."
 msgstr ""
 
-#: src/Content/Conversation.php:880
+#: src/Content/Conversation.php:883
 msgid "You subscribed to one or more tags in this post."
 msgstr ""
 
-#: src/Content/Conversation.php:893
+#: src/Content/Conversation.php:896
 #, php-format
 msgid "%s reshared this."
 msgstr ""
 
-#: src/Content/Conversation.php:895
+#: src/Content/Conversation.php:898
 msgid "Reshared"
 msgstr ""
 
-#: src/Content/Conversation.php:895
+#: src/Content/Conversation.php:898
 #, php-format
 msgid "Reshared by %s <%s>"
 msgstr ""
 
-#: src/Content/Conversation.php:898
+#: src/Content/Conversation.php:901
 #, php-format
 msgid "%s is participating in this thread."
 msgstr ""
 
-#: src/Content/Conversation.php:901
+#: src/Content/Conversation.php:904
 msgid "Stored for general reasons"
 msgstr ""
 
-#: src/Content/Conversation.php:904
+#: src/Content/Conversation.php:907
 msgid "Global post"
 msgstr ""
 
-#: src/Content/Conversation.php:907
+#: src/Content/Conversation.php:910
 msgid "Sent via an relay server"
 msgstr ""
 
-#: src/Content/Conversation.php:907
+#: src/Content/Conversation.php:910
 #, php-format
 msgid "Sent via the relay server %s <%s>"
 msgstr ""
 
-#: src/Content/Conversation.php:910
+#: src/Content/Conversation.php:913
 msgid "Fetched"
 msgstr ""
 
-#: src/Content/Conversation.php:910
+#: src/Content/Conversation.php:913
 #, php-format
 msgid "Fetched because of %s <%s>"
 msgstr ""
 
-#: src/Content/Conversation.php:913
+#: src/Content/Conversation.php:916
 msgid "Stored because of a child post to complete this thread."
 msgstr ""
 
-#: src/Content/Conversation.php:916
+#: src/Content/Conversation.php:919
 msgid "Local delivery"
 msgstr ""
 
-#: src/Content/Conversation.php:919
+#: src/Content/Conversation.php:922
 msgid "Stored because of your activity (like, comment, star, ...)"
 msgstr ""
 
-#: src/Content/Conversation.php:922
+#: src/Content/Conversation.php:925
 msgid "Distributed"
 msgstr ""
 
-#: src/Content/Conversation.php:925
+#: src/Content/Conversation.php:928
 msgid "Pushed to us"
 msgstr ""
 
@@ -1596,7 +1597,7 @@ msgstr ""
 msgid "show more"
 msgstr ""
 
-#: src/Content/Item.php:326 src/Model/Item.php:2913
+#: src/Content/Item.php:326 src/Model/Item.php:2922
 msgid "event"
 msgstr ""
 
@@ -1604,7 +1605,7 @@ msgstr ""
 msgid "status"
 msgstr ""
 
-#: src/Content/Item.php:335 src/Model/Item.php:2915
+#: src/Content/Item.php:335 src/Model/Item.php:2924
 #: src/Module/Post/Tag/Add.php:123
 msgid "photo"
 msgstr ""
@@ -2010,8 +2011,8 @@ msgid ""
 "<a href=\"%1$s\" target=\"_blank\" rel=\"noopener noreferrer\">%2$s</a> %3$s"
 msgstr ""
 
-#: src/Content/Text/BBCode.php:956 src/Model/Item.php:3598
-#: src/Model/Item.php:3604 src/Model/Item.php:3605
+#: src/Content/Text/BBCode.php:956 src/Model/Item.php:3607
+#: src/Model/Item.php:3613 src/Model/Item.php:3614
 msgid "Link to source"
 msgstr ""
 
@@ -3180,81 +3181,81 @@ msgstr ""
 msgid "Edit groups"
 msgstr ""
 
-#: src/Model/Item.php:2014
+#: src/Model/Item.php:2023
 #, php-format
 msgid "Detected languages in this post:\\n%s"
 msgstr ""
 
-#: src/Model/Item.php:2917
+#: src/Model/Item.php:2926
 msgid "activity"
 msgstr ""
 
-#: src/Model/Item.php:2919
+#: src/Model/Item.php:2928
 msgid "comment"
 msgstr ""
 
-#: src/Model/Item.php:2922 src/Module/Post/Tag/Add.php:123
+#: src/Model/Item.php:2931 src/Module/Post/Tag/Add.php:123
 msgid "post"
 msgstr ""
 
-#: src/Model/Item.php:3084
+#: src/Model/Item.php:3093
 #, php-format
 msgid "%s is blocked"
 msgstr ""
 
-#: src/Model/Item.php:3086
+#: src/Model/Item.php:3095
 #, php-format
 msgid "%s is ignored"
 msgstr ""
 
-#: src/Model/Item.php:3088
+#: src/Model/Item.php:3097
 #, php-format
 msgid "Content from %s is collapsed"
 msgstr ""
 
-#: src/Model/Item.php:3092
+#: src/Model/Item.php:3101
 #, php-format
 msgid "Content warning: %s"
 msgstr ""
 
-#: src/Model/Item.php:3510
+#: src/Model/Item.php:3519
 msgid "bytes"
 msgstr ""
 
-#: src/Model/Item.php:3541
+#: src/Model/Item.php:3550
 #, php-format
 msgid "%2$s (%3$d%%, %1$d vote)"
 msgid_plural "%2$s (%3$d%%, %1$d votes)"
 msgstr[0] ""
 msgstr[1] ""
 
-#: src/Model/Item.php:3543
+#: src/Model/Item.php:3552
 #, php-format
 msgid "%2$s (%1$d vote)"
 msgid_plural "%2$s (%1$d votes)"
 msgstr[0] ""
 msgstr[1] ""
 
-#: src/Model/Item.php:3548
+#: src/Model/Item.php:3557
 #, php-format
 msgid "%d voter. Poll end: %s"
 msgid_plural "%d voters. Poll end: %s"
 msgstr[0] ""
 msgstr[1] ""
 
-#: src/Model/Item.php:3550
+#: src/Model/Item.php:3559
 #, php-format
 msgid "%d voter."
 msgid_plural "%d voters."
 msgstr[0] ""
 msgstr[1] ""
 
-#: src/Model/Item.php:3552
+#: src/Model/Item.php:3561
 #, php-format
 msgid "Poll end: %s"
 msgstr ""
 
-#: src/Model/Item.php:3586 src/Model/Item.php:3587
+#: src/Model/Item.php:3595 src/Model/Item.php:3596
 msgid "View on separate page"
 msgstr ""
 
@@ -8250,6 +8251,16 @@ msgstr ""
 msgid "<b>BCC:</b> %s<br>"
 msgstr ""
 
+#: src/Module/PermissionTooltip.php:240
+#, php-format
+msgid "<b>Audience:</b> %s<br>"
+msgstr ""
+
+#: src/Module/PermissionTooltip.php:243
+#, php-format
+msgid "<b>Attributed To:</b> %s<br>"
+msgstr ""
+
 #: src/Module/Photo.php:129
 msgid "The Photo is not available."
 msgstr ""