]> git.mxchange.org Git - friendica.git/commitdiff
Store personal copy of public item upon commenting
authorMichael <heluecht@pirati.ca>
Tue, 21 Jul 2020 23:26:01 +0000 (23:26 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 21 Jul 2020 23:26:01 +0000 (23:26 +0000)
mod/item.php
src/Model/Item.php

index e2d47ae2fab08c03ad02763df4699662850bbbd7..c4d7231c22934d7d21ef447834c93612ff7a5130 100644 (file)
@@ -136,6 +136,16 @@ function item_post(App $a) {
                        throw new HTTPException\NotFoundException(DI::l10n()->t('Unable to locate original post.'));
                }
 
+               // When commenting on a public post then store the post for the current user
+               // This enables interaction like starring and saving into folders
+               if ($toplevel_item['uid'] == 0) {
+                       $stored = Item::storeForUser($toplevel_item, local_user());
+                       Logger::info('Public item stored for user', ['uri-id' => $toplevel_item['uri-id'], 'uid' => $uid, 'stored' => $stored]);
+                       if ($stored) {
+                               $toplevel_item = Item::selectFirst([], ['id' => $stored]);
+                       }
+               }
+
                $toplevel_item_id = $toplevel_item['id'];
                $parent_user = $toplevel_item['uid'];
 
index 860d9d73c9f7fb52e8493a7f7ebef97b42376602..afecc411620af7b2d6f85a02a8b18d8a129f169c 100644 (file)
@@ -2174,7 +2174,7 @@ class Item
         * @return integer stored item id
         * @throws \Exception
         */
-       private static function storeForUser(array $item, int $uid)
+       public static function storeForUser(array $item, int $uid)
        {
                if (self::exists(['uri-id' => $item['uri-id'], 'uid' => $uid])) {
                        Logger::info('Item already exists', ['uri-id' => $item['uri-id'], 'uid' => $uid]);