diff --git a/src/Content/Item.php b/src/Content/Item.php index 26df55fd06..1bf3e68726 100644 --- a/src/Content/Item.php +++ b/src/Content/Item.php @@ -859,7 +859,7 @@ class Item $user = User::getById($post['uid'], ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid']); if (!$user) { - throw new HTTPException\NotFoundException($this->l10n->t('Unable to locate original post.')); + throw new HTTPException\NotFoundException($this->l10n->t('Unable to fetch user.')); } $post['allow_cid'] = isset($request['contact_allow']) ? $this->aclFormatter->toString($request['contact_allow']) : $user['allow_cid'] ?? ''; @@ -957,10 +957,30 @@ class Item $post['origin'] = true; $post['wall'] = $post['wall'] ?? true; $post['guid'] = $post['guid'] ?? System::createUUID(); - $post['uri'] = $post['uri'] ?? ItemModel::newURI($post['guid']); $post['verb'] = $post['verb'] ?? Activity::POST; + + if (empty($post['uri'])) { + $post['thr-parent'] = $post['uri'] = ItemModel::newURI($post['guid']); + $post['gravity'] = ItemModel::GRAVITY_PARENT; + } + $owner = User::getOwnerDataById($post['uid']); + if (!isset($post['allow_cid']) || !isset($post['allow_gid']) || !isset($post['deny_cid']) || !isset($post['deny_gid'])) { + $post['allow_cid'] = $owner['allow_cid']; + $post['allow_gid'] = $owner['allow_gid']; + $post['deny_cid'] = $owner['deny_cid']; + $post['deny_gid'] = $owner['deny_gid']; + } + + if ($post['allow_gid'] || $post['allow_cid'] || $post['deny_gid'] || $post['deny_cid']) { + $post['private'] = ItemModel::PRIVATE; + } elseif ($this->pConfig->get($post['uid'], 'system', 'unlisted')) { + $post['private'] = ItemModel::UNLISTED; + } else { + $post['private'] = ItemModel::PUBLIC; + } + if (empty($post['contact-id'])) { $post['contact-id'] = $owner['id']; } diff --git a/src/Model/Item.php b/src/Model/Item.php index afa51461e8..fb638d6e93 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -1224,6 +1224,8 @@ class Item Post\Content::insert($item['uri-id'], $item); } + $item['parent'] = $parent_id; + // Create Diaspora signature if ($item['origin'] && empty($item['diaspora_signed_text']) && ($item['gravity'] != self::GRAVITY_PARENT)) { $signed = Diaspora::createCommentSignature($item); @@ -1741,16 +1743,16 @@ class Item $item['origin'] = 0; $item['wall'] = 0; - $item['contact-id'] = self::contactId($item); - $notify = false; if ($item['gravity'] == self::GRAVITY_PARENT) { $contact = DBA::selectFirst('contact', [], ['id' => $item['contact-id'], 'self' => false]); if (DBA::isResult($contact)) { $notify = self::isRemoteSelf($contact, $item); + $item['wall'] = (bool)$notify; } } + $item['contact-id'] = self::contactId($item); $distributed = self::insert($item, $notify); if (!$distributed) { diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index 0b005570b2..26d5376e4e 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -2079,6 +2079,7 @@ class DFRN // This is my contact on another system, but it's really me. // Turn this into a wall post. $notify = Item::isRemoteSelf($importer, $item); + $item['wall'] = (bool)$notify; $posted_id = Item::insert($item, $notify); diff --git a/src/Protocol/Feed.php b/src/Protocol/Feed.php index 63a9fbfbdc..ccbe35e712 100644 --- a/src/Protocol/Feed.php +++ b/src/Protocol/Feed.php @@ -624,6 +624,7 @@ class Feed Logger::info('Stored feed', ['item' => $item]); $notify = Item::isRemoteSelf($contact, $item); + $item['wall'] = (bool)$notify; // Distributed items should have a well-formatted URI. // Additionally, we have to avoid conflicts with identical URI between imported feeds and these items. diff --git a/view/lang/C/messages.po b/view/lang/C/messages.po index 38fe8606ff..b5922c8e74 100644 --- a/view/lang/C/messages.po +++ b/view/lang/C/messages.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 2023.03-dev\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-01-08 23:25+0000\n" +"POT-Creation-Date: 2023-01-09 16:24+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -19,7 +19,6 @@ msgstr "" #: mod/item.php:101 mod/item.php:104 mod/item.php:170 mod/item.php:173 -#: src/Content/Item.php:862 msgid "Unable to locate original post." msgstr "" @@ -1517,7 +1516,7 @@ msgstr "" msgid "show more" msgstr "" -#: src/Content/Item.php:326 src/Model/Item.php:2893 +#: src/Content/Item.php:326 src/Model/Item.php:2895 msgid "event" msgstr "" @@ -1526,7 +1525,7 @@ msgstr "" msgid "status" msgstr "" -#: src/Content/Item.php:335 src/Model/Item.php:2895 +#: src/Content/Item.php:335 src/Model/Item.php:2897 #: src/Module/Post/Tag/Add.php:123 msgid "photo" msgstr "" @@ -1599,6 +1598,10 @@ msgstr "" msgid "Connect/Follow" msgstr "" +#: src/Content/Item.php:862 +msgid "Unable to fetch user." +msgstr "" + #: src/Content/Nav.php:90 msgid "Nothing new here" msgstr "" @@ -1926,8 +1929,8 @@ msgid "" "%2$s %3$s" msgstr "" -#: src/Content/Text/BBCode.php:1257 src/Model/Item.php:3562 -#: src/Model/Item.php:3568 src/Model/Item.php:3569 +#: src/Content/Text/BBCode.php:1257 src/Model/Item.php:3564 +#: src/Model/Item.php:3570 src/Model/Item.php:3571 msgid "Link to source" msgstr "" @@ -3096,71 +3099,71 @@ msgstr "" msgid "Edit groups" msgstr "" -#: src/Model/Item.php:1994 +#: src/Model/Item.php:1996 #, php-format msgid "Detected languages in this post:\\n%s" msgstr "" -#: src/Model/Item.php:2897 +#: src/Model/Item.php:2899 msgid "activity" msgstr "" -#: src/Model/Item.php:2899 +#: src/Model/Item.php:2901 msgid "comment" msgstr "" -#: src/Model/Item.php:2902 +#: src/Model/Item.php:2904 msgid "post" msgstr "" -#: src/Model/Item.php:3052 +#: src/Model/Item.php:3054 #, php-format msgid "Content from %s is collapsed" msgstr "" -#: src/Model/Item.php:3056 +#: src/Model/Item.php:3058 #, php-format msgid "Content warning: %s" msgstr "" -#: src/Model/Item.php:3474 +#: src/Model/Item.php:3476 msgid "bytes" msgstr "" -#: src/Model/Item.php:3505 +#: src/Model/Item.php:3507 #, 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:3507 +#: src/Model/Item.php:3509 #, php-format msgid "%2$s (%1$d vote)" msgid_plural "%2$s (%1$d votes)" msgstr[0] "" msgstr[1] "" -#: src/Model/Item.php:3512 +#: src/Model/Item.php:3514 #, php-format msgid "%d voter. Poll end: %s" msgid_plural "%d voters. Poll end: %s" msgstr[0] "" msgstr[1] "" -#: src/Model/Item.php:3514 +#: src/Model/Item.php:3516 #, php-format msgid "%d voter." msgid_plural "%d voters." msgstr[0] "" msgstr[1] "" -#: src/Model/Item.php:3516 +#: src/Model/Item.php:3518 #, php-format msgid "Poll end: %s" msgstr "" -#: src/Model/Item.php:3550 src/Model/Item.php:3551 +#: src/Model/Item.php:3552 src/Model/Item.php:3553 msgid "View on separate page" msgstr "" @@ -8313,19 +8316,19 @@ msgstr "" #: src/Module/Profile/Profile.php:351 src/Module/Profile/Profile.php:354 #: src/Module/Profile/Status.php:106 src/Module/Profile/Status.php:109 -#: src/Protocol/Feed.php:1024 src/Protocol/OStatus.php:1045 +#: src/Protocol/Feed.php:1025 src/Protocol/OStatus.php:1045 #, php-format msgid "%s's timeline" msgstr "" #: src/Module/Profile/Profile.php:352 src/Module/Profile/Status.php:107 -#: src/Protocol/Feed.php:1028 src/Protocol/OStatus.php:1050 +#: src/Protocol/Feed.php:1029 src/Protocol/OStatus.php:1050 #, php-format msgid "%s's posts" msgstr "" #: src/Module/Profile/Profile.php:353 src/Module/Profile/Status.php:108 -#: src/Protocol/Feed.php:1031 src/Protocol/OStatus.php:1054 +#: src/Protocol/Feed.php:1032 src/Protocol/OStatus.php:1054 #, php-format msgid "%s's comments" msgstr ""