kopia lustrzana https://github.com/friendica/friendica
Porównaj commity
17 Commity
f041701765
...
2c689f2b73
Autor | SHA1 | Data |
---|---|---|
Michael Vogel | 2c689f2b73 | |
Hypolite Petovan | aac5d41fd6 | |
Hypolite Petovan | 57187f26ae | |
Hypolite Petovan | 7446048d5d | |
Hypolite Petovan | d3ee4d589b | |
Michael | fda832cd83 | |
Michael | 30f31828ae | |
Tobias Diekershoff | cd7a663733 | |
Michael | 3b024450ff | |
Tobias Diekershoff | e22ef85386 | |
Tobias Diekershoff | e206175a50 | |
Michael | 76d469675e | |
Michael | 3496d3948a | |
Michael | 00b325d521 | |
Tobias Diekershoff | 2077e00eae | |
Michael | a1427a52b3 | |
Michael | 40a47b076d |
|
@ -27,6 +27,7 @@ use Friendica\Content\Post\Collection;
|
|||
use Friendica\Content\Post\Entity;
|
||||
use Friendica\Content\Post\Factory;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Util\Strings;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
|
@ -62,7 +63,7 @@ class PostMedia extends BaseRepository
|
|||
|
||||
public function selectByUriId(int $uriId): Collection\PostMedias
|
||||
{
|
||||
return $this->_select(['uri-id' => $uriId]);
|
||||
return $this->_select(["`uri-id` = ? AND `type` != ?", $uriId, Post\Media::UNKNOWN]);
|
||||
}
|
||||
|
||||
public function save(Entity\PostMedia $PostMedia): Entity\PostMedia
|
||||
|
|
|
@ -1245,6 +1245,42 @@ class BBCode
|
|||
return $match[1] . '[url=' . $data['url'] . ']' . $data['nick'] . '[/url]';
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace mention links
|
||||
*
|
||||
* @param string $body HTML/BBCode
|
||||
* @return string Body with replaced mentions
|
||||
*/
|
||||
public static function setMentionsToAddr(string $body): string
|
||||
{
|
||||
DI::profiler()->startRecording('rendering');
|
||||
$regexp = "/([@!])\[url\=([^\[\]]*)\].*?\[\/url\]/ism";
|
||||
$body = preg_replace_callback($regexp, [self::class, 'mentionToAddrCallback'], $body);
|
||||
DI::profiler()->stopRecording();
|
||||
return $body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback function to replace a Friendica style mention in a mention with the addr
|
||||
*
|
||||
* @param array $match Matching values for the callback
|
||||
* @return string Replaced mention or empty string
|
||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
private static function mentionToAddrCallback(array $match): string
|
||||
{
|
||||
if (empty($match[2])) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$data = Contact::getByURL($match[2], false, ['url', 'nick', 'addr']);
|
||||
if (empty($data['nick'])) {
|
||||
return $match[0];
|
||||
}
|
||||
|
||||
return $match[1] . ($data['addr'] ?: $data['nick']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize links to Youtube and Vimeo to a unified format.
|
||||
*
|
||||
|
|
|
@ -104,7 +104,7 @@ class VCard
|
|||
$mention_label = DI::l10n()->t('Post to group');
|
||||
$mention_link = 'compose/0?body=!' . $contact['addr'];
|
||||
}
|
||||
$showgroup_link = 'network/group/' . $id;
|
||||
$showgroup_link = 'contact/' . $id . '/conversations';
|
||||
} elseif (!$hide_mention) {
|
||||
$mention_label = DI::l10n()->t('Mention');
|
||||
$mention_link = 'compose/0?body=@' . $contact['addr'];
|
||||
|
|
|
@ -38,10 +38,14 @@ class StatusSource extends BaseFactory
|
|||
*/
|
||||
public function createFromUriId(int $uriId, int $uid): \Friendica\Object\Api\Mastodon\StatusSource
|
||||
{
|
||||
$post = Post::selectOriginal(['uri-id', 'raw-body', 'body', 'title'], ['uri-id' => $uriId, 'uid' => [0, $uid]]);
|
||||
$post = Post::selectOriginal(['uri-id', 'raw-body', 'body', 'title', 'content-warning'], ['uri-id' => $uriId, 'uid' => [0, $uid]]);
|
||||
|
||||
$spoiler_text = $post['title'] ?: BBCode::toPlaintext(BBCode::getAbstract($post['body'], Protocol::ACTIVITYPUB));
|
||||
$body = BBCode::toMarkdown(Post\Media::removeFromEndOfBody($post['body']));
|
||||
$spoiler_text = $post['title'] ?: $post['content-warning'] ?: BBCode::toPlaintext(BBCode::getAbstract($post['body'], Protocol::ACTIVITYPUB));
|
||||
|
||||
$body = Post\Media::removeFromEndOfBody($post['body']);
|
||||
$body = Post\Media::addHTMLLinkToBody($uriId, $body);
|
||||
$body = BBCode::setMentionsToAddr($body);
|
||||
$body = BBCode::toPlaintext($body);
|
||||
|
||||
return new \Friendica\Object\Api\Mastodon\StatusSource($post['uri-id'], $body, $spoiler_text);
|
||||
}
|
||||
|
|
|
@ -1205,13 +1205,12 @@ class Contact
|
|||
$mention_label = DI::l10n()->t('Post to group');
|
||||
$mention_url = 'compose/0?body=!' . $contact['addr'];
|
||||
$network_label = DI::l10n()->t('View group');
|
||||
$network_url = 'network/group/' . $contact['id'];
|
||||
} else {
|
||||
$mention_label = DI::l10n()->t('Mention');
|
||||
$mention_url = 'compose/0?body=@' . $contact['addr'];
|
||||
$network_label = DI::l10n()->t('Network Posts');
|
||||
$network_url = 'contact/' . $contact['id'] . '/conversations';
|
||||
}
|
||||
$network_url = 'contact/' . $contact['id'] . '/conversations';
|
||||
|
||||
$follow_link = '';
|
||||
$unfollow_link = '';
|
||||
|
|
|
@ -912,6 +912,8 @@ class Media
|
|||
$body .= "\n[audio]" . $media['url'] . "[/audio]\n";
|
||||
} elseif ($media['type'] == self::VIDEO) {
|
||||
$body .= "\n[video]" . $media['url'] . "[/video]\n";
|
||||
} else {
|
||||
$body .= "\n[url]" . $media['url'] . "[/url]\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -461,13 +461,12 @@ class Profile
|
|||
$mention_label = DI::l10n()->t('Post to group');
|
||||
$mention_url = 'compose/0?body=!' . $profile['addr'];
|
||||
$network_label = DI::l10n()->t('View group');
|
||||
$network_url = 'network/group/' . $cid;
|
||||
} else {
|
||||
$mention_label = DI::l10n()->t('Mention');
|
||||
$mention_url = 'compose/0?body=@' . $profile['addr'];
|
||||
$network_label = DI::l10n()->t('Network Posts');
|
||||
$network_url = 'contact/' . $cid . '/conversations';
|
||||
}
|
||||
$network_url = 'contact/' . $cid . '/conversations';
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('profile/vcard.tpl');
|
||||
$o .= Renderer::replaceMacros($tpl, [
|
||||
|
|
|
@ -82,7 +82,7 @@ class Markers extends BaseApi
|
|||
$values->{$marker['timeline']} = [
|
||||
'last_read_id' => $marker['last_read_id'],
|
||||
'version' => $marker['version'],
|
||||
'updated_at' => $marker['updated_at']
|
||||
'updated_at' => DateTimeFormat::utc($marker['updated_at'], DateTimeFormat::JSON)
|
||||
];
|
||||
}
|
||||
return $values;
|
||||
|
|
|
@ -348,10 +348,10 @@ class Profile extends BaseProfile
|
|||
$htmlhead .= '<meta content="noindex, noarchive" name="robots" />' . "\n";
|
||||
}
|
||||
|
||||
$htmlhead .= '<link rel="alternate" type="application/atom+xml" href="' . $this->baseUrl . '/dfrn_poll/' . $nickname . '" title="DFRN: ' . $this->t('%s\'s timeline', $profile['name']) . '"/>' . "\n";
|
||||
$htmlhead .= '<link rel="alternate" type="application/atom+xml" href="' . $this->baseUrl . '/feed/' . $nickname . '/" title="' . $this->t('%s\'s posts', $profile['name']) . '"/>' . "\n";
|
||||
$htmlhead .= '<link rel="alternate" type="application/atom+xml" href="' . $this->baseUrl . '/feed/' . $nickname . '/comments" title="' . $this->t('%s\'s comments', $profile['name']) . '"/>' . "\n";
|
||||
$htmlhead .= '<link rel="alternate" type="application/atom+xml" href="' . $this->baseUrl . '/feed/' . $nickname . '/activity" title="' . $this->t('%s\'s timeline', $profile['name']) . '"/>' . "\n";
|
||||
$htmlhead .= '<link rel="alternate" type="application/atom+xml" href="' . $this->baseUrl . '/dfrn_poll/' . $nickname . '" title="DFRN: ' . $this->t('%s\'s timeline', htmlspecialchars($profile['name'], ENT_COMPAT, 'UTF-8', true)) . '"/>' . "\n";
|
||||
$htmlhead .= '<link rel="alternate" type="application/atom+xml" href="' . $this->baseUrl . '/feed/' . $nickname . '/" title="' . $this->t('%s\'s posts', htmlspecialchars($profile['name'], ENT_COMPAT, 'UTF-8', true)) . '"/>' . "\n";
|
||||
$htmlhead .= '<link rel="alternate" type="application/atom+xml" href="' . $this->baseUrl . '/feed/' . $nickname . '/comments" title="' . $this->t('%s\'s comments', htmlspecialchars($profile['name'], ENT_COMPAT, 'UTF-8', true)) . '"/>' . "\n";
|
||||
$htmlhead .= '<link rel="alternate" type="application/atom+xml" href="' . $this->baseUrl . '/feed/' . $nickname . '/activity" title="' . $this->t('%s\'s timeline', htmlspecialchars($profile['name'], ENT_COMPAT, 'UTF-8', true)) . '"/>' . "\n";
|
||||
$uri = urlencode('acct:' . $profile['nickname'] . '@' . $this->baseUrl->getHost() . ($this->baseUrl->getPath() ? '/' . $this->baseUrl->getPath() : ''));
|
||||
$htmlhead .= '<link rel="lrdd" type="application/xrd+xml" href="' . $this->baseUrl . '/xrd/?uri=' . $uri . '" />' . "\n";
|
||||
header('Link: <' . $this->baseUrl . '/xrd/?uri=' . $uri . '>; rel="lrdd"; type="application/xrd+xml"', false);
|
||||
|
|
|
@ -851,6 +851,7 @@ class Processor
|
|||
}
|
||||
|
||||
$item['title'] = trim(BBCode::toPlaintext($item['title']));
|
||||
$item['content-warning'] = HTML::toBBCode($activity['summary'] ?? '');
|
||||
|
||||
if (!empty($activity['languages'])) {
|
||||
$item['language'] = self::processLanguages($activity['languages']);
|
||||
|
@ -897,7 +898,6 @@ class Processor
|
|||
}
|
||||
$content = self::removeImplicitMentionsFromBody($content, $parent);
|
||||
}
|
||||
$item['content-warning'] = HTML::toBBCode($activity['summary'] ?? '');
|
||||
$item['raw-body'] = $item['body'] = $content;
|
||||
}
|
||||
|
||||
|
@ -1611,15 +1611,15 @@ class Processor
|
|||
|
||||
if (empty($object) || !is_array($object)) {
|
||||
Logger::notice('Invalid JSON data', ['url' => $url, 'content-type' => $curlResult->getContentType()]);
|
||||
return '';
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!self::isValidObject($object, $url)) {
|
||||
return '';
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!HTTPSignature::isValidContentType($curlResult->getContentType(), $url)) {
|
||||
return '';
|
||||
return null;
|
||||
}
|
||||
|
||||
$ldobject = JsonLD::compact($object);
|
||||
|
|
|
@ -1164,6 +1164,7 @@ class Transmitter
|
|||
}
|
||||
|
||||
$mail['content-warning'] = '';
|
||||
$mail['sensitive'] = false;
|
||||
$mail['author-link'] = $mail['owner-link'] = $mail['from-url'];
|
||||
$mail['owner-id'] = $mail['author-id'];
|
||||
$mail['allow_cid'] = '<'.$mail['contact-id'].'>';
|
||||
|
|
|
@ -662,7 +662,6 @@ return [
|
|||
'/network' => [
|
||||
'[/{content}]' => [Module\Conversation\Network::class, [R::GET]],
|
||||
'/archive/{from:\d\d\d\d-\d\d-\d\d}[/{to:\d\d\d\d-\d\d-\d\d}]' => [Module\Conversation\Network::class, [R::GET]],
|
||||
'/group/{contact_id:\d+}' => [Module\Conversation\Network::class, [R::GET]],
|
||||
'/circle/{circle_id:\d+}' => [Module\Conversation\Network::class, [R::GET]],
|
||||
],
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue