Merge pull request #10482 from annando/converturiid
Some more "convertForUriId" replacements
This commit is contained in:
commit
f6df07ec86
|
@ -1,6 +1,6 @@
|
||||||
-- ------------------------------------------
|
-- ------------------------------------------
|
||||||
-- Friendica 2021.09-dev (Siberian Iris)
|
-- Friendica 2021.09-dev (Siberian Iris)
|
||||||
-- DB_UPDATE_VERSION 1426
|
-- DB_UPDATE_VERSION 1427
|
||||||
-- ------------------------------------------
|
-- ------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
@ -2291,6 +2291,7 @@ CREATE VIEW `owner-view` AS SELECT
|
||||||
`contact`.`dfrn-id` AS `dfrn-id`,
|
`contact`.`dfrn-id` AS `dfrn-id`,
|
||||||
`contact`.`url` AS `url`,
|
`contact`.`url` AS `url`,
|
||||||
`contact`.`nurl` AS `nurl`,
|
`contact`.`nurl` AS `nurl`,
|
||||||
|
`contact`.`uri-id` AS `uri-id`,
|
||||||
`contact`.`addr` AS `addr`,
|
`contact`.`addr` AS `addr`,
|
||||||
`contact`.`alias` AS `alias`,
|
`contact`.`alias` AS `alias`,
|
||||||
`contact`.`pubkey` AS `pubkey`,
|
`contact`.`pubkey` AS `pubkey`,
|
||||||
|
|
|
@ -2525,12 +2525,12 @@ function api_format_messages($item, $recipient, $sender)
|
||||||
if (!empty($_GET['getText'])) {
|
if (!empty($_GET['getText'])) {
|
||||||
$ret['title'] = $item['title'];
|
$ret['title'] = $item['title'];
|
||||||
if ($_GET['getText'] == 'html') {
|
if ($_GET['getText'] == 'html') {
|
||||||
$ret['text'] = BBCode::convert($item['body'], false);
|
$ret['text'] = BBCode::convertForUriId($item['uri-id'], $item['body'], BBCode::API);
|
||||||
} elseif ($_GET['getText'] == 'plain') {
|
} elseif ($_GET['getText'] == 'plain') {
|
||||||
$ret['text'] = trim(HTML::toPlaintext(BBCode::convert(api_clean_plain_items($item['body']), false, BBCode::API, true), 0));
|
$ret['text'] = trim(HTML::toPlaintext(BBCode::convertForUriId($item['uri-id'], api_clean_plain_items($item['body']), BBCode::API), 0));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$ret['text'] = $item['title'] . "\n" . HTML::toPlaintext(BBCode::convert(api_clean_plain_items($item['body']), false, BBCode::API, true), 0);
|
$ret['text'] = $item['title'] . "\n" . HTML::toPlaintext(BBCode::convertForUriId($item['uri-id'], api_clean_plain_items($item['body']), BBCode::API), 0);
|
||||||
}
|
}
|
||||||
if (!empty($_GET['getUserObjects']) && $_GET['getUserObjects'] == 'false') {
|
if (!empty($_GET['getUserObjects']) && $_GET['getUserObjects'] == 'false') {
|
||||||
unset($ret['sender']);
|
unset($ret['sender']);
|
||||||
|
@ -2557,7 +2557,7 @@ function api_convert_item($item)
|
||||||
$attachments = api_get_attachments($body, $item['uri-id']);
|
$attachments = api_get_attachments($body, $item['uri-id']);
|
||||||
|
|
||||||
// Workaround for ostatus messages where the title is identically to the body
|
// Workaround for ostatus messages where the title is identically to the body
|
||||||
$html = BBCode::convert(api_clean_plain_items($body), false, BBCode::API, true);
|
$html = BBCode::convertForUriId($item['uri-id'], api_clean_plain_items($body), BBCode::API);
|
||||||
$statusbody = trim(HTML::toPlaintext($html, 0));
|
$statusbody = trim(HTML::toPlaintext($html, 0));
|
||||||
|
|
||||||
// handle data: images
|
// handle data: images
|
||||||
|
@ -2575,7 +2575,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(BBCode::removeAttachment($body), false, BBCode::API, true);
|
$statushtml = BBCode::convertForUriId($item['uri-id'], BBCode::removeAttachment($body), BBCode::API);
|
||||||
|
|
||||||
// Workaround for clients with limited HTML parser functionality
|
// Workaround for clients with limited HTML parser functionality
|
||||||
$search = ["<br>", "<blockquote>", "</blockquote>",
|
$search = ["<br>", "<blockquote>", "</blockquote>",
|
||||||
|
@ -2589,7 +2589,7 @@ function api_convert_item($item)
|
||||||
$statushtml = str_replace($search, $replace, $statushtml);
|
$statushtml = str_replace($search, $replace, $statushtml);
|
||||||
|
|
||||||
if ($item['title'] != "") {
|
if ($item['title'] != "") {
|
||||||
$statushtml = "<br><h4>" . BBCode::convert($item['title']) . "</h4><br>" . $statushtml;
|
$statushtml = "<br><h4>" . BBCode::convertForUriId($item['uri-id'], $item['title']) . "</h4><br>" . $statushtml;
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
@ -2607,7 +2607,7 @@ function api_convert_item($item)
|
||||||
|
|
||||||
// feeds without body should contain the link
|
// feeds without body should contain the link
|
||||||
if ((($item['network'] ?? Protocol::PHANTOM) == Protocol::FEED) && (strlen($item['body']) == 0)) {
|
if ((($item['network'] ?? Protocol::PHANTOM) == Protocol::FEED) && (strlen($item['body']) == 0)) {
|
||||||
$statushtml .= BBCode::convert($item['plink']);
|
$statushtml .= BBCode::convertForUriId($item['uri-id'], $item['plink']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
@ -3054,7 +3054,7 @@ function api_format_item($item, $type = "json", $status_user = null, $author_use
|
||||||
'external_url' => DI::baseUrl() . "/display/" . $item['guid'],
|
'external_url' => DI::baseUrl() . "/display/" . $item['guid'],
|
||||||
'friendica_activities' => api_format_items_activities($item, $type),
|
'friendica_activities' => api_format_items_activities($item, $type),
|
||||||
'friendica_title' => $item['title'],
|
'friendica_title' => $item['title'],
|
||||||
'friendica_html' => BBCode::convert($item['body'], false)
|
'friendica_html' => BBCode::convertForUriId($item['uri-id'], $item['body'], BBCode::EXTERNAL)
|
||||||
];
|
];
|
||||||
|
|
||||||
if (count($converted["attachments"]) > 0) {
|
if (count($converted["attachments"]) > 0) {
|
||||||
|
|
|
@ -47,91 +47,6 @@ use Friendica\Util\Strings;
|
||||||
use Friendica\Util\Temporal;
|
use Friendica\Util\Temporal;
|
||||||
use Friendica\Util\XML;
|
use Friendica\Util\XML;
|
||||||
|
|
||||||
function item_extract_images($body) {
|
|
||||||
|
|
||||||
$saved_image = [];
|
|
||||||
$orig_body = $body;
|
|
||||||
$new_body = '';
|
|
||||||
|
|
||||||
$cnt = 0;
|
|
||||||
$img_start = strpos($orig_body, '[img');
|
|
||||||
$img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
|
|
||||||
$img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
|
|
||||||
while (($img_st_close !== false) && ($img_end !== false)) {
|
|
||||||
|
|
||||||
$img_st_close++; // make it point to AFTER the closing bracket
|
|
||||||
$img_end += $img_start;
|
|
||||||
|
|
||||||
if (!strcmp(substr($orig_body, $img_start + $img_st_close, 5), 'data:')) {
|
|
||||||
// This is an embedded image
|
|
||||||
|
|
||||||
$saved_image[$cnt] = substr($orig_body, $img_start + $img_st_close, $img_end - ($img_start + $img_st_close));
|
|
||||||
$new_body = $new_body . substr($orig_body, 0, $img_start) . '[!#saved_image' . $cnt . '#!]';
|
|
||||||
|
|
||||||
$cnt++;
|
|
||||||
} else {
|
|
||||||
$new_body = $new_body . substr($orig_body, 0, $img_end + strlen('[/img]'));
|
|
||||||
}
|
|
||||||
|
|
||||||
$orig_body = substr($orig_body, $img_end + strlen('[/img]'));
|
|
||||||
|
|
||||||
if ($orig_body === false) {
|
|
||||||
// in case the body ends on a closing image tag
|
|
||||||
$orig_body = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$img_start = strpos($orig_body, '[img');
|
|
||||||
$img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
|
|
||||||
$img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
|
|
||||||
}
|
|
||||||
|
|
||||||
$new_body = $new_body . $orig_body;
|
|
||||||
|
|
||||||
return ['body' => $new_body, 'images' => $saved_image];
|
|
||||||
}
|
|
||||||
|
|
||||||
function item_redir_and_replace_images($body, $images, $cid) {
|
|
||||||
|
|
||||||
$origbody = $body;
|
|
||||||
$newbody = '';
|
|
||||||
|
|
||||||
$cnt = 1;
|
|
||||||
$pos = BBCode::getTagPosition($origbody, 'url', 0);
|
|
||||||
while ($pos !== false && $cnt < 1000) {
|
|
||||||
|
|
||||||
$search = '/\[url\=(.*?)\]\[!#saved_image([0-9]*)#!\]\[\/url\]' . '/is';
|
|
||||||
$replace = '[url=' . DI::baseUrl() . '/redir/' . $cid
|
|
||||||
. '?url=' . '$1' . '][!#saved_image' . '$2' .'#!][/url]';
|
|
||||||
|
|
||||||
$newbody .= substr($origbody, 0, $pos['start']['open']);
|
|
||||||
$subject = substr($origbody, $pos['start']['open'], $pos['end']['close'] - $pos['start']['open']);
|
|
||||||
$origbody = substr($origbody, $pos['end']['close']);
|
|
||||||
if ($origbody === false) {
|
|
||||||
$origbody = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$subject = preg_replace($search, $replace, $subject);
|
|
||||||
$newbody .= $subject;
|
|
||||||
|
|
||||||
$cnt++;
|
|
||||||
// Isn't this supposed to use $cnt value for $occurrences? - @MrPetovan
|
|
||||||
$pos = BBCode::getTagPosition($origbody, 'url', 0);
|
|
||||||
}
|
|
||||||
$newbody .= $origbody;
|
|
||||||
|
|
||||||
$cnt = 0;
|
|
||||||
foreach ($images as $image) {
|
|
||||||
/*
|
|
||||||
* We're depending on the property of 'foreach' (specified on the PHP website) that
|
|
||||||
* it loops over the array starting from the first element and going sequentially
|
|
||||||
* to the last element.
|
|
||||||
*/
|
|
||||||
$newbody = str_replace('[!#saved_image' . $cnt . '#!]', '[img]' . $image . '[/img]', $newbody);
|
|
||||||
$cnt++;
|
|
||||||
}
|
|
||||||
return $newbody;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render actions localized
|
* Render actions localized
|
||||||
*
|
*
|
||||||
|
@ -141,11 +56,6 @@ function item_redir_and_replace_images($body, $images, $cid) {
|
||||||
*/
|
*/
|
||||||
function localize_item(&$item)
|
function localize_item(&$item)
|
||||||
{
|
{
|
||||||
$extracted = item_extract_images($item['body']);
|
|
||||||
if ($extracted['images']) {
|
|
||||||
$item['body'] = item_redir_and_replace_images($extracted['body'], $extracted['images'], $item['contact-id']);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @todo The following functionality needs to be cleaned up.
|
/// @todo The following functionality needs to be cleaned up.
|
||||||
if (!empty($item['verb'])) {
|
if (!empty($item['verb'])) {
|
||||||
$activity = DI::activity();
|
$activity = DI::activity();
|
||||||
|
@ -260,13 +170,6 @@ function localize_item(&$item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// add zrl's to public images
|
|
||||||
$photo_pattern = "/\[url=(.*?)\/photos\/(.*?)\/image\/(.*?)\]\[img(.*?)\]h(.*?)\[\/img\]\[\/url\]/is";
|
|
||||||
if (preg_match($photo_pattern, $item['body'])) {
|
|
||||||
$photo_replace = '[url=' . Profile::zrl('$1' . '/photos/' . '$2' . '/image/' . '$3' , true) . '][img' . '$4' . ']h' . '$5' . '[/img][/url]';
|
|
||||||
$item['body'] = BBCode::pregReplaceInTag($photo_pattern, $photo_replace, 'url', $item['body']);
|
|
||||||
}
|
|
||||||
|
|
||||||
// add sparkle links to appropriate permalinks
|
// add sparkle links to appropriate permalinks
|
||||||
// Only create a redirection to a magic link when logged in
|
// Only create a redirection to a magic link when logged in
|
||||||
if (!empty($item['plink']) && Session::isAuthenticated()) {
|
if (!empty($item['plink']) && Session::isAuthenticated()) {
|
||||||
|
|
|
@ -474,7 +474,7 @@ function notification($params)
|
||||||
if ($show_in_notification_page) {
|
if ($show_in_notification_page) {
|
||||||
$fields = [
|
$fields = [
|
||||||
'name' => $params['source_name'] ?? '',
|
'name' => $params['source_name'] ?? '',
|
||||||
'name_cache' => substr(strip_tags(BBCode::convert($params['source_name'])), 0, 255),
|
'name_cache' => substr(strip_tags(BBCode::convertForUriId($uri_id, $params['source_name'])), 0, 255),
|
||||||
'url' => $params['source_link'] ?? '',
|
'url' => $params['source_link'] ?? '',
|
||||||
'photo' => $params['source_photo'] ?? '',
|
'photo' => $params['source_photo'] ?? '',
|
||||||
'link' => $itemlink ?? '',
|
'link' => $itemlink ?? '',
|
||||||
|
|
|
@ -314,14 +314,9 @@ function message_content(App $a)
|
||||||
$sparkle = ' sparkle';
|
$sparkle = ' sparkle';
|
||||||
}
|
}
|
||||||
|
|
||||||
$extracted = item_extract_images($message['body']);
|
|
||||||
if ($extracted['images']) {
|
|
||||||
$message['body'] = item_redir_and_replace_images($extracted['body'], $extracted['images'], $message['contact-id']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$from_name_e = $message['from-name'];
|
$from_name_e = $message['from-name'];
|
||||||
$subject_e = $message['title'];
|
$subject_e = $message['title'];
|
||||||
$body_e = BBCode::convert($message['body']);
|
$body_e = BBCode::convertForUriId($message['uri-id'], $message['body']);
|
||||||
$to_name_e = $message['name'];
|
$to_name_e = $message['name'];
|
||||||
|
|
||||||
$contact = Contact::getByURL($message['from-url'], false, ['thumb', 'addr', 'id', 'avatar']);
|
$contact = Contact::getByURL($message['from-url'], false, ['thumb', 'addr', 'id', 'avatar']);
|
||||||
|
|
|
@ -100,6 +100,9 @@ class PostUpdate
|
||||||
if (!self::update1426()) {
|
if (!self::update1426()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (!self::update1427()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -961,4 +964,51 @@ class PostUpdate
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* update the "uri-id" field in the event table
|
||||||
|
*
|
||||||
|
* @return bool "true" when the job is done
|
||||||
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
|
* @throws \ImagickException
|
||||||
|
*/
|
||||||
|
private static function update1427()
|
||||||
|
{
|
||||||
|
// Was the script completed?
|
||||||
|
if (DI::config()->get("system", "post_update_version") >= 1427) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$condition = ["`uri-id` IS NULL"];
|
||||||
|
Logger::info('Start', ['rest' => DBA::count('event', $condition)]);
|
||||||
|
|
||||||
|
$rows = 0;
|
||||||
|
$events = DBA::select('event', ['id', 'uri', 'guid'], $condition, ['limit' => 1000]);
|
||||||
|
|
||||||
|
if (DBA::errorNo() != 0) {
|
||||||
|
Logger::error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
while ($event = DBA::fetch($events)) {
|
||||||
|
if (!empty($event['guid'])) {
|
||||||
|
$uriid = ItemURI::insert(['uri' => $event['uri'], 'guid' => $event['guid']]);
|
||||||
|
} else {
|
||||||
|
$uriid = ItemURI::getIdByURI($event['uri']);
|
||||||
|
}
|
||||||
|
DBA::update('event', ['uri-id' => $uriid], ['id' => $event['id']]);
|
||||||
|
++$rows;
|
||||||
|
}
|
||||||
|
DBA::close($events);
|
||||||
|
|
||||||
|
Logger::info('Processed', ['rows' => $rows]);
|
||||||
|
|
||||||
|
if ($rows <= 100) {
|
||||||
|
DI::config()->set("system", "post_update_version", 1427);
|
||||||
|
Logger::info('Done');
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -589,10 +589,10 @@ class Event
|
||||||
$last_date = '';
|
$last_date = '';
|
||||||
$fmt = DI::l10n()->t('l, F j');
|
$fmt = DI::l10n()->t('l, F j');
|
||||||
foreach ($event_result as $event) {
|
foreach ($event_result as $event) {
|
||||||
$item = Post::selectFirst(['plink', 'author-name', 'author-avatar', 'author-link', 'private'], ['id' => $event['itemid']]);
|
$item = Post::selectFirst(['plink', 'author-name', 'author-avatar', 'author-link', 'private', 'uri-id'], ['id' => $event['itemid']]);
|
||||||
if (!DBA::isResult($item)) {
|
if (!DBA::isResult($item)) {
|
||||||
// Using default values when no item had been found
|
// Using default values when no item had been found
|
||||||
$item = ['plink' => '', 'author-name' => '', 'author-avatar' => '', 'author-link' => '', 'private' => Item::PUBLIC];
|
$item = ['plink' => '', 'author-name' => '', 'author-avatar' => '', 'author-link' => '', 'private' => Item::PUBLIC, 'uri-id' => ($event['uri-id'] ?? 0)];
|
||||||
}
|
}
|
||||||
|
|
||||||
$event = array_merge($event, $item);
|
$event = array_merge($event, $item);
|
||||||
|
|
|
@ -486,11 +486,11 @@ class Profile
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($p['about'])) {
|
if (isset($p['about'])) {
|
||||||
$p['about'] = BBCode::convert($p['about']);
|
$p['about'] = BBCode::convertForUriId($profile['uri-id'] ?? 0, $p['about']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($p['address'])) {
|
if (isset($p['address'])) {
|
||||||
$p['address'] = BBCode::convert($p['address']);
|
$p['address'] = BBCode::convertForUriId($profile['uri-id'] ?? 0, $p['address']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$p['photo'] = Contact::getAvatarUrlForId($cid, ProxyUtils::SIZE_SMALL);
|
$p['photo'] = Contact::getAvatarUrlForId($cid, ProxyUtils::SIZE_SMALL);
|
||||||
|
@ -670,13 +670,13 @@ class Profile
|
||||||
$istoday = true;
|
$istoday = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$title = strip_tags(html_entity_decode(BBCode::convert($rr['summary']), ENT_QUOTES, 'UTF-8'));
|
$title = strip_tags(html_entity_decode(BBCode::convertForUriId($rr['uri-id'], $rr['summary']), ENT_QUOTES, 'UTF-8'));
|
||||||
|
|
||||||
if (strlen($title) > 35) {
|
if (strlen($title) > 35) {
|
||||||
$title = substr($title, 0, 32) . '... ';
|
$title = substr($title, 0, 32) . '... ';
|
||||||
}
|
}
|
||||||
|
|
||||||
$description = substr(strip_tags(BBCode::convert($rr['desc'])), 0, 32) . '... ';
|
$description = substr(strip_tags(BBCode::convertForUriId($rr['uri-id'], $rr['desc'])), 0, 32) . '... ';
|
||||||
if (!$description) {
|
if (!$description) {
|
||||||
$description = DI::l10n()->t('[No description]');
|
$description = DI::l10n()->t('[No description]');
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ class Index extends BaseApi
|
||||||
'cid' => $event['cid'],
|
'cid' => $event['cid'],
|
||||||
'uri' => $event['uri'],
|
'uri' => $event['uri'],
|
||||||
'name' => $event['summary'],
|
'name' => $event['summary'],
|
||||||
'desc' => BBCode::convert($event['desc']),
|
'desc' => BBCode::convertForUriId($event['uri-id'], $event['desc']),
|
||||||
'startTime' => $event['start'],
|
'startTime' => $event['start'],
|
||||||
'endTime' => $event['finish'],
|
'endTime' => $event['finish'],
|
||||||
'type' => $event['type'],
|
'type' => $event['type'],
|
||||||
|
|
|
@ -169,7 +169,7 @@ class Profile extends BaseProfile
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($a->profile['about']) {
|
if ($a->profile['about']) {
|
||||||
$basic_fields += self::buildField('about', DI::l10n()->t('Description:'), BBCode::convert($a->profile['about']));
|
$basic_fields += self::buildField('about', DI::l10n()->t('Description:'), BBCode::convertForUriId($a->profile['uri-id'], $a->profile['about']));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($a->profile['xmpp']) {
|
if ($a->profile['xmpp']) {
|
||||||
|
@ -218,7 +218,7 @@ class Profile extends BaseProfile
|
||||||
$custom_fields += self::buildField(
|
$custom_fields += self::buildField(
|
||||||
'custom_' . $profile_field->order,
|
'custom_' . $profile_field->order,
|
||||||
$profile_field->label,
|
$profile_field->label,
|
||||||
BBCode::convert($profile_field->value),
|
BBCode::convertForUriId($a->profile['uri-id'], $profile_field->value),
|
||||||
'aprofile custom'
|
'aprofile custom'
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1345,8 +1345,7 @@ class Receiver
|
||||||
// Some AP software allow formatted text in post location, so we run all the text converters we have to boil
|
// Some AP software allow formatted text in post location, so we run all the text converters we have to boil
|
||||||
// down to HTML and then finally format to plaintext.
|
// down to HTML and then finally format to plaintext.
|
||||||
$location = Markdown::convert($location);
|
$location = Markdown::convert($location);
|
||||||
$location = BBCode::convert($location);
|
$location = BBCode::toPlaintext($location);
|
||||||
$location = HTML::toPlaintext($location);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$object_data['sc:identifier'] = JsonLD::fetchElement($object, 'sc:identifier', '@value');
|
$object_data['sc:identifier'] = JsonLD::fetchElement($object, 'sc:identifier', '@value');
|
||||||
|
|
|
@ -345,7 +345,7 @@ class Transmitter
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($owner['about'])) {
|
if (!empty($owner['about'])) {
|
||||||
$data['summary'] = BBCode::convert($owner['about'], false);
|
$data['summary'] = BBCode::convertForUriId($owner['uri-id'], $owner['about'], BBCode::EXTERNAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
$data['url'] = $owner['url'];
|
$data['url'] = $owner['url'];
|
||||||
|
|
|
@ -765,12 +765,13 @@ class DFRN
|
||||||
* @param DOMDocument $doc XML document
|
* @param DOMDocument $doc XML document
|
||||||
* @param string $element Element name for the activity
|
* @param string $element Element name for the activity
|
||||||
* @param string $activity activity value
|
* @param string $activity activity value
|
||||||
|
* @param int $uriid Uri-Id of the post
|
||||||
*
|
*
|
||||||
* @return \DOMElement XML activity object
|
* @return \DOMElement XML activity object
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||||
* @todo Find proper type-hints
|
* @todo Find proper type-hints
|
||||||
*/
|
*/
|
||||||
private static function createActivity(DOMDocument $doc, $element, $activity)
|
private static function createActivity(DOMDocument $doc, $element, $activity, $uriid)
|
||||||
{
|
{
|
||||||
if ($activity) {
|
if ($activity) {
|
||||||
$entry = $doc->createElement($element);
|
$entry = $doc->createElement($element);
|
||||||
|
@ -817,7 +818,7 @@ class DFRN
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($r->content) {
|
if ($r->content) {
|
||||||
XML::addElement($doc, $entry, "content", BBCode::convert($r->content), ["type" => "html"]);
|
XML::addElement($doc, $entry, "content", BBCode::convertForUriId($uriid, $r->content, BBCode::EXTERNAL), ["type" => "html"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $entry;
|
return $entry;
|
||||||
|
@ -918,7 +919,7 @@ class DFRN
|
||||||
$htmlbody = "[b]" . $item['title'] . "[/b]\n\n" . $htmlbody;
|
$htmlbody = "[b]" . $item['title'] . "[/b]\n\n" . $htmlbody;
|
||||||
}
|
}
|
||||||
|
|
||||||
$htmlbody = BBCode::convertForUriId($item['uri-id'], $htmlbody, BBCode::OSTATUS);
|
$htmlbody = BBCode::convertForUriId($item['uri-id'], $htmlbody, BBCode::ACTIVITYPUB);
|
||||||
}
|
}
|
||||||
|
|
||||||
$author = self::addEntryAuthor($doc, "author", $item["author-link"], $item);
|
$author = self::addEntryAuthor($doc, "author", $item["author-link"], $item);
|
||||||
|
@ -1033,12 +1034,12 @@ class DFRN
|
||||||
XML::addElement($doc, $entry, "activity:object-type", Activity\ObjectType::COMMENT);
|
XML::addElement($doc, $entry, "activity:object-type", Activity\ObjectType::COMMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
$actobj = self::createActivity($doc, "activity:object", $item['object']);
|
$actobj = self::createActivity($doc, "activity:object", $item['object'], $item['uri-id']);
|
||||||
if ($actobj) {
|
if ($actobj) {
|
||||||
$entry->appendChild($actobj);
|
$entry->appendChild($actobj);
|
||||||
}
|
}
|
||||||
|
|
||||||
$actarg = self::createActivity($doc, "activity:target", $item['target']);
|
$actarg = self::createActivity($doc, "activity:target", $item['target'], $item['uri-id']);
|
||||||
if ($actarg) {
|
if ($actarg) {
|
||||||
$entry->appendChild($actarg);
|
$entry->appendChild($actarg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1109,7 +1109,7 @@ class Feed
|
||||||
|
|
||||||
$body = OStatus::formatPicturePost($item['body'], $item['uri-id']);
|
$body = OStatus::formatPicturePost($item['body'], $item['uri-id']);
|
||||||
|
|
||||||
$body = BBCode::convertForUriId($item['uri-id'], $body, BBCode::OSTATUS, false);
|
$body = BBCode::convertForUriId($item['uri-id'], $body, BBCode::ACTIVITYPUB);
|
||||||
|
|
||||||
XML::addElement($doc, $entry, "content", $body, ["type" => "html"]);
|
XML::addElement($doc, $entry, "content", $body, ["type" => "html"]);
|
||||||
|
|
||||||
|
@ -1186,7 +1186,7 @@ class Feed
|
||||||
private static function getTitle(array $item)
|
private static function getTitle(array $item)
|
||||||
{
|
{
|
||||||
if ($item['title'] != '') {
|
if ($item['title'] != '') {
|
||||||
return BBCode::convertForUriId($item['uri-id'], $item['title'], BBCode::OSTATUS);
|
return BBCode::convertForUriId($item['uri-id'], $item['title'], BBCode::ACTIVITYPUB);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch information about the post
|
// Fetch information about the post
|
||||||
|
|
|
@ -1418,7 +1418,7 @@ class OStatus
|
||||||
XML::addElement($doc, $author, "name", $owner["nick"]);
|
XML::addElement($doc, $author, "name", $owner["nick"]);
|
||||||
XML::addElement($doc, $author, "email", $owner["addr"]);
|
XML::addElement($doc, $author, "email", $owner["addr"]);
|
||||||
if ($show_profile) {
|
if ($show_profile) {
|
||||||
XML::addElement($doc, $author, "summary", BBCode::convert($owner["about"], false, BBCode::OSTATUS));
|
XML::addElement($doc, $author, "summary", BBCode::convertForUriId($owner['uri-id'], $owner["about"], BBCode::OSTATUS));
|
||||||
}
|
}
|
||||||
|
|
||||||
$attributes = ["rel" => "alternate", "type" => "text/html", "href" => $owner["url"]];
|
$attributes = ["rel" => "alternate", "type" => "text/html", "href" => $owner["url"]];
|
||||||
|
@ -1445,7 +1445,7 @@ class OStatus
|
||||||
XML::addElement($doc, $author, "poco:preferredUsername", $owner["nick"]);
|
XML::addElement($doc, $author, "poco:preferredUsername", $owner["nick"]);
|
||||||
XML::addElement($doc, $author, "poco:displayName", $owner["name"]);
|
XML::addElement($doc, $author, "poco:displayName", $owner["name"]);
|
||||||
if ($show_profile) {
|
if ($show_profile) {
|
||||||
XML::addElement($doc, $author, "poco:note", BBCode::convert($owner["about"], false, BBCode::OSTATUS));
|
XML::addElement($doc, $author, "poco:note", BBCode::convertForUriId($owner['uri-id'], $owner["about"], BBCode::OSTATUS));
|
||||||
|
|
||||||
if (trim($owner["location"]) != "") {
|
if (trim($owner["location"]) != "") {
|
||||||
$element = $doc->createElement("poco:address");
|
$element = $doc->createElement("poco:address");
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
|
|
||||||
if (!defined('DB_UPDATE_VERSION')) {
|
if (!defined('DB_UPDATE_VERSION')) {
|
||||||
define('DB_UPDATE_VERSION', 1426);
|
define('DB_UPDATE_VERSION', 1427);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
|
@ -729,6 +729,7 @@
|
||||||
"dfrn-id" => ["contact", "dfrn-id"],
|
"dfrn-id" => ["contact", "dfrn-id"],
|
||||||
"url" => ["contact", "url"],
|
"url" => ["contact", "url"],
|
||||||
"nurl" => ["contact", "nurl"],
|
"nurl" => ["contact", "nurl"],
|
||||||
|
"uri-id" => ["contact", "uri-id"],
|
||||||
"addr" => ["contact", "addr"],
|
"addr" => ["contact", "addr"],
|
||||||
"alias" => ["contact", "alias"],
|
"alias" => ["contact", "alias"],
|
||||||
"pubkey" => ["contact", "pubkey"],
|
"pubkey" => ["contact", "pubkey"],
|
||||||
|
|
|
@ -2192,9 +2192,9 @@ class ApiTest extends FixtureTest
|
||||||
public function testApiFormatMessages()
|
public function testApiFormatMessages()
|
||||||
{
|
{
|
||||||
$result = api_format_messages(
|
$result = api_format_messages(
|
||||||
['id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
|
['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
|
||||||
['id' => 2, 'screen_name' => 'recipient_name'],
|
['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
|
||||||
['id' => 3, 'screen_name' => 'sender_name']
|
['id' => 3, 'uri-id' => 2, 'screen_name' => 'sender_name']
|
||||||
);
|
);
|
||||||
self::assertEquals('item_title' . "\n" . 'item_body', $result['text']);
|
self::assertEquals('item_title' . "\n" . 'item_body', $result['text']);
|
||||||
self::assertEquals(1, $result['id']);
|
self::assertEquals(1, $result['id']);
|
||||||
|
@ -2213,9 +2213,9 @@ class ApiTest extends FixtureTest
|
||||||
{
|
{
|
||||||
$_GET['getText'] = 'html';
|
$_GET['getText'] = 'html';
|
||||||
$result = api_format_messages(
|
$result = api_format_messages(
|
||||||
['id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
|
['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
|
||||||
['id' => 2, 'screen_name' => 'recipient_name'],
|
['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
|
||||||
['id' => 3, 'screen_name' => 'sender_name']
|
['id' => 3, 'uri-id' => 3, 'screen_name' => 'sender_name']
|
||||||
);
|
);
|
||||||
self::assertEquals('item_title', $result['title']);
|
self::assertEquals('item_title', $result['title']);
|
||||||
self::assertEquals('<strong>item_body</strong>', $result['text']);
|
self::assertEquals('<strong>item_body</strong>', $result['text']);
|
||||||
|
@ -2230,9 +2230,9 @@ class ApiTest extends FixtureTest
|
||||||
{
|
{
|
||||||
$_GET['getText'] = 'plain';
|
$_GET['getText'] = 'plain';
|
||||||
$result = api_format_messages(
|
$result = api_format_messages(
|
||||||
['id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
|
['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
|
||||||
['id' => 2, 'screen_name' => 'recipient_name'],
|
['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
|
||||||
['id' => 3, 'screen_name' => 'sender_name']
|
['id' => 3, 'uri-id' => 3, 'screen_name' => 'sender_name']
|
||||||
);
|
);
|
||||||
self::assertEquals('item_title', $result['title']);
|
self::assertEquals('item_title', $result['title']);
|
||||||
self::assertEquals('item_body', $result['text']);
|
self::assertEquals('item_body', $result['text']);
|
||||||
|
@ -2247,9 +2247,9 @@ class ApiTest extends FixtureTest
|
||||||
{
|
{
|
||||||
$_GET['getUserObjects'] = 'false';
|
$_GET['getUserObjects'] = 'false';
|
||||||
$result = api_format_messages(
|
$result = api_format_messages(
|
||||||
['id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
|
['id' => 1, 'uri-id' => 1, 'title' => 'item_title', 'body' => '[b]item_body[/b]'],
|
||||||
['id' => 2, 'screen_name' => 'recipient_name'],
|
['id' => 2, 'uri-id' => 2, 'screen_name' => 'recipient_name'],
|
||||||
['id' => 3, 'screen_name' => 'sender_name']
|
['id' => 3, 'uri-id' => 3, 'screen_name' => 'sender_name']
|
||||||
);
|
);
|
||||||
self::assertTrue(!isset($result['sender']));
|
self::assertTrue(!isset($result['sender']));
|
||||||
self::assertTrue(!isset($result['recipient']));
|
self::assertTrue(!isset($result['recipient']));
|
||||||
|
|
Loading…
Reference in a new issue