Merge pull request #7893 from annando/api-attachments
API: Improve attachment removal functionality for the status text
This commit is contained in:
commit
9c9b4d1967
2 changed files with 2 additions and 43 deletions
|
@ -2498,7 +2498,7 @@ function api_convert_item($item)
|
||||||
$statustext = mb_substr($statustext, 0, 1000) . "... \n" . ($item['plink'] ?? '');
|
$statustext = mb_substr($statustext, 0, 1000) . "... \n" . ($item['plink'] ?? '');
|
||||||
}
|
}
|
||||||
|
|
||||||
$statushtml = BBCode::convert(api_clean_attachments($body), false);
|
$statushtml = BBCode::convert(BBCode::removeAttachment($body), false);
|
||||||
|
|
||||||
// Workaround for clients with limited HTML parser functionality
|
// Workaround for clients with limited HTML parser functionality
|
||||||
$search = ["<br>", "<blockquote>", "</blockquote>",
|
$search = ["<br>", "<blockquote>", "</blockquote>",
|
||||||
|
@ -5409,42 +5409,11 @@ function api_clean_plain_items($text)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simplify "attachment" element
|
// Simplify "attachment" element
|
||||||
$text = api_clean_attachments($text);
|
$text = BBCode::removeAttachment($text);
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Removes most sharing information for API text export
|
|
||||||
*
|
|
||||||
* @param string $body The original body
|
|
||||||
*
|
|
||||||
* @return string Cleaned body
|
|
||||||
* @throws InternalServerErrorException
|
|
||||||
*/
|
|
||||||
function api_clean_attachments($body)
|
|
||||||
{
|
|
||||||
$data = BBCode::getAttachmentData($body);
|
|
||||||
|
|
||||||
if (empty($data)) {
|
|
||||||
return $body;
|
|
||||||
}
|
|
||||||
$body = "";
|
|
||||||
|
|
||||||
if (isset($data["text"])) {
|
|
||||||
$body = $data["text"];
|
|
||||||
}
|
|
||||||
if (($body == "") && isset($data["title"])) {
|
|
||||||
$body = $data["title"];
|
|
||||||
}
|
|
||||||
if (isset($data["url"])) {
|
|
||||||
$body .= "\n".$data["url"];
|
|
||||||
}
|
|
||||||
$body .= $data["after"];
|
|
||||||
|
|
||||||
return $body;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param array $contacts
|
* @param array $contacts
|
||||||
|
|
|
@ -3775,16 +3775,6 @@ class ApiTest extends DatabaseTest
|
||||||
$this->assertEquals('some_text [url="some_url"]"some_url"[/url]', $result);
|
$this->assertEquals('some_text [url="some_url"]"some_url"[/url]', $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Test the api_clean_attachments() function.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function testApiCleanAttachments()
|
|
||||||
{
|
|
||||||
$this->markTestIncomplete();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the api_best_nickname() function.
|
* Test the api_best_nickname() function.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue