]> git.mxchange.org Git - friendica.git/commitdiff
Fix list of accounts
authorMichael <heluecht@pirati.ca>
Tue, 11 May 2021 23:39:08 +0000 (23:39 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 11 May 2021 23:39:08 +0000 (23:39 +0000)
src/Model/Post/Media.php
src/Module/Api/Mastodon/Lists/Accounts.php

index 6f78b09051a7de8f838db6e6ef4d14868f0778ad..c3f745fee64fc9b020f4ba7ce2c8eb5132ead5e9 100644 (file)
@@ -288,9 +288,13 @@ class Media
        public static function insertFromBody(int $uriid, string $body)
        {
                // Simplify image codes
-               $body = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $body);
+               $unshared_body = $body = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $body);
 
-               $unshared_body = preg_replace("/\s*\[share .*?\].*?\[\/share\]\s*/ism", '', $body);
+               // Only remove the shared data from "real" reshares
+               $shared = BBCode::fetchShareAttributes($body);
+               if (!empty($shared['guid'])) {
+                       $unshared_body = preg_replace("/\s*\[share .*?\].*?\[\/share\]\s*/ism", '', $body);
+               }
 
                $attachments = [];
                if (preg_match_all("#\[url=([^\]]+?)\]\s*\[img=([^\[\]]*)\]([^\[\]]*)\[\/img\]\s*\[/url\]#ism", $body, $pictures, PREG_SET_ORDER)) {
@@ -363,8 +367,12 @@ class Media
         */
        public static function insertFromRelevantUrl(int $uriid, string $body)
        {
-               // Don't look at the shared content
-               $body = preg_replace("/\s*\[share .*?\].*?\[\/share\]\s*/ism", '', $body);
+               // Only remove the shared data from "real" reshares
+               $shared = BBCode::fetchShareAttributes($body);
+               if (!empty($shared['guid'])) {
+                       // Don't look at the shared content
+                       $body = preg_replace("/\s*\[share .*?\].*?\[\/share\]\s*/ism", '', $body);
+               }
 
                // Remove all hashtags and mentions
                $body = preg_replace("/([#@!])\[url\=(.*?)\](.*?)\[\/url\]/ism", '', $body);
index 0b817cfc82abb8481e934ae2f778f645066bed4a..513ca21d71c16aa9efb9db7e7bc92ae7f88d09ff 100644 (file)
@@ -65,12 +65,18 @@ class Accounts extends BaseApi
                $max_id = (int)!isset($_REQUEST['max_id']) ? 0 : $_REQUEST['max_id'];
                // Return results newer than this id
                $since_id = (int)!isset($_REQUEST['since_id']) ? 0 : $_REQUEST['since_id'];
-               // Maximum number of results to return. Defaults to 20.
+               // Maximum number of results. Defaults to 40. Max 40.
+               // Set to 0 in order to get all accounts without pagination.
                $limit = (int)!isset($_REQUEST['limit']) ? 40 : $_REQUEST['limit'];
 
 
-               $params = ['order' => ['contact-id' => true], 'limit' => $limit];
+               $params = ['order' => ['contact-id' => true]];
 
+               if ($limit != 0) {
+                       $params['limit'] = $limit;
+
+               }
+       
                $condition = ['gid' => $id];
 
                if (!empty($max_id)) {
@@ -87,6 +93,8 @@ class Accounts extends BaseApi
                        $params['order'] = ['contact-id'];
                }
 
+               $accounts = [];
+
                $members = DBA::select('group_member', ['contact-id'], $condition, $params);
                while ($member = DBA::fetch($members)) {
                        $accounts[] = DI::mstdnAccount()->createFromContactId($member['contact-id'], $uid);