]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Item.php
spelling: maybe
[friendica.git] / src / Model / Item.php
index 93ad4fd8f0db787e7306b492185ad1f5fd2e0b80..81b019e9bb93ebf1bb866b187db8fe174b40d970 100644 (file)
@@ -201,8 +201,6 @@ class Item
                $notify_items = [];
 
                while ($item = DBA::fetch($items)) {
-                       Post\Media::deleteByURIId($item['uri-id'], [Post\Media::HTML]);
-
                        if (!empty($fields['body'])) {
                                if (!empty($item['quote-uri-id'])) {
                                        $fields['body'] = BBCode::removeSharedData($fields['body']);
@@ -589,7 +587,7 @@ class Item
        public static function isValid(array $item): bool
        {
                // When there is no content then we don't post it
-               if (($item['body'] . $item['title'] == '') && empty($item['quote-uri-id']) && (empty($item['uri-id']) || !Post\Media::existsByURIId($item['uri-id']))) {
+               if (($item['body'] . $item['title'] == '') && empty($item['quote-uri-id']) && empty($item['attachments']) && (empty($item['uri-id']) || !Post\Media::existsByURIId($item['uri-id']))) {
                        Logger::notice('No body, no title.');
                        return false;
                }
@@ -877,7 +875,7 @@ class Item
                /*
                 * Do we already have this item?
                 * We have to check several networks since Friendica posts could be repeated
-                * via OStatus (maybe Diasporsa as well)
+                * via OStatus (maybe Diaspora as well)
                 */
                $duplicate = self::getDuplicateID($item);
                if ($duplicate) {
@@ -894,6 +892,8 @@ class Item
                        $item['post-type'] = empty($item['title']) ? self::PT_NOTE : self::PT_ARTICLE;
                }
 
+               $defined_permissions = isset($item['allow_cid']) && isset($item['allow_gid']) && isset($item['deny_cid']) && isset($item['deny_gid']) && isset($item['private']);
+
                $item['wall']          = intval($item['wall'] ?? 0);
                $item['extid']         = trim($item['extid'] ?? '');
                $item['author-name']   = trim($item['author-name'] ?? '');
@@ -995,7 +995,7 @@ class Item
                        $item['wall']          = $toplevel_parent['wall'];
 
                        // Reshares have to keep their permissions to allow forums to work
-                       if (!$item['origin'] || ($item['verb'] != Activity::ANNOUNCE)) {
+                       if (!$defined_permissions && (!$item['origin'] || ($item['verb'] != Activity::ANNOUNCE))) {
                                $item['allow_cid']     = $toplevel_parent['allow_cid'];
                                $item['allow_gid']     = $toplevel_parent['allow_gid'];
                                $item['deny_cid']      = $toplevel_parent['deny_cid'];
@@ -1018,7 +1018,7 @@ class Item
                         * This differs from the above settings as it subtly allows comments from
                         * email correspondents to be private even if the overall thread is not.
                         */
-                       if ($toplevel_parent['private']) {
+                       if (!$defined_permissions && $toplevel_parent['private']) {
                                $item['private'] = $toplevel_parent['private'];
                        }
 
@@ -1065,7 +1065,7 @@ class Item
                }
 
                // ACL settings
-               if (!empty($item['allow_cid'] . $item['allow_gid'] . $item['deny_cid'] . $item['deny_gid'])) {
+               if (!$defined_permissions && !empty($item['allow_cid'] . $item['allow_gid'] . $item['deny_cid'] . $item['deny_gid'])) {
                        $item['private'] = self::PRIVATE;
                }
 
@@ -2501,12 +2501,12 @@ class Item
         */
        public static function enumeratePermissions(array $obj, bool $check_dead = false): array
        {
-               $aclFormater = DI::aclFormatter();
+               $aclFormatter = DI::aclFormatter();
 
-               $allow_people = $aclFormater->expand($obj['allow_cid']);
-               $allow_groups = Group::expand($obj['uid'], $aclFormater->expand($obj['allow_gid']), $check_dead);
-               $deny_people  = $aclFormater->expand($obj['deny_cid']);
-               $deny_groups  = Group::expand($obj['uid'], $aclFormater->expand($obj['deny_gid']), $check_dead);
+               $allow_people = $aclFormatter->expand($obj['allow_cid']);
+               $allow_groups = Group::expand($obj['uid'], $aclFormatter->expand($obj['allow_gid']), $check_dead);
+               $deny_people  = $aclFormatter->expand($obj['deny_cid']);
+               $deny_groups  = Group::expand($obj['uid'], $aclFormatter->expand($obj['deny_gid']), $check_dead);
                $recipients   = array_unique(array_merge($allow_people, $allow_groups));
                $deny         = array_unique(array_merge($deny_people, $deny_groups));
                $recipients   = array_diff($recipients, $deny);