mirror of
https://github.com/friendica/friendica
synced 2025-04-22 01:50:11 +00:00
Merge branch 'develop' into notifications-summary
This commit is contained in:
commit
843502badc
140 changed files with 1030 additions and 1508 deletions
|
@ -37,9 +37,9 @@ class Config extends BaseApi
|
|||
$config = [
|
||||
'site' => [
|
||||
'name' => DI::config()->get('config', 'sitename'),
|
||||
'server' => DI::baseUrl()->getHostname(),
|
||||
'server' => DI::baseUrl()->getHost(),
|
||||
'theme' => DI::config()->get('system', 'theme'),
|
||||
'path' => DI::baseUrl()->getUrlPath(),
|
||||
'path' => DI::baseUrl()->getPath(),
|
||||
'logo' => DI::baseUrl() . '/images/friendica-64.png',
|
||||
'fancy' => true,
|
||||
'language' => DI::config()->get('system', 'language'),
|
||||
|
@ -52,7 +52,7 @@ class Config extends BaseApi
|
|||
'private' => (bool)DI::config()->get('system', 'block_public'),
|
||||
'textlimit' => (string) DI::config()->get('config', 'api_import_size', DI::config()->get('config', 'max_import_size')),
|
||||
'sslserver' => null,
|
||||
'ssl' => DI::config()->get('system', 'ssl_policy') == App\BaseURL::SSL_POLICY_FULL ? 'always' : '0',
|
||||
'ssl' => DI::baseUrl()->getScheme() === 'https' ? 'always' : '0',
|
||||
'friendica' => [
|
||||
'FRIENDICA_PLATFORM' => App::PLATFORM,
|
||||
'FRIENDICA_VERSION' => App::VERSION,
|
||||
|
|
|
@ -107,6 +107,7 @@ class Statuses extends BaseApi
|
|||
'visibility' => '', // Visibility of the posted status. One of: "public", "unlisted", "private" or "direct".
|
||||
'scheduled_at' => '', // ISO 8601 Datetime at which to schedule a status. Providing this paramter will cause ScheduledStatus to be returned instead of Status. Must be at least 5 minutes in the future.
|
||||
'language' => '', // ISO 639 language code for this status.
|
||||
'friendica' => [], // Friendica extensions to the standard Mastodon API spec
|
||||
], $request);
|
||||
|
||||
$owner = User::getOwnerDataById($uid);
|
||||
|
@ -208,8 +209,10 @@ class Statuses extends BaseApi
|
|||
$item['quote-uri-id'] = $request['quote_id'];
|
||||
}
|
||||
|
||||
$item['title'] = $request['friendica']['title'] ?? '';
|
||||
|
||||
if (!empty($request['spoiler_text'])) {
|
||||
if (!$request['in_reply_to_id'] && DI::pConfig()->get($uid, 'system', 'api_spoiler_title', true)) {
|
||||
if (!isset($request['friendica']['title']) && !$request['in_reply_to_id'] && DI::pConfig()->get($uid, 'system', 'api_spoiler_title', true)) {
|
||||
$item['title'] = $request['spoiler_text'];
|
||||
} else {
|
||||
$item['body'] = '[abstract=' . Protocol::ACTIVITYPUB . ']' . $request['spoiler_text'] . "[/abstract]\n" . $item['body'];
|
||||
|
|
|
@ -65,6 +65,13 @@ class Direct extends BaseApi
|
|||
$params['order'] = ['uri-id'];
|
||||
}
|
||||
|
||||
if (!empty($uid)) {
|
||||
$condition = DBA::mergeConditions(
|
||||
$condition,
|
||||
["NOT `parent-author-id` IN (SELECT `cid` FROM `user-contact` WHERE `uid` = ? AND (`blocked` OR `ignored`) AND `cid` = `parent-author-id`)", $uid]
|
||||
);
|
||||
}
|
||||
|
||||
$mails = DBA::select('mail', ['id', 'uri-id'], $condition, $params);
|
||||
|
||||
$statuses = [];
|
||||
|
|
|
@ -90,11 +90,6 @@ class PublicTimeline extends BaseApi
|
|||
$condition = DBA::mergeConditions($condition, ['gravity' => Item::GRAVITY_PARENT]);
|
||||
}
|
||||
|
||||
if (!empty($uid)) {
|
||||
$condition = DBA::mergeConditions($condition,
|
||||
["NOT `parent-author-id` IN (SELECT `cid` FROM `user-contact` WHERE `uid` = ? AND (`blocked` OR `ignored`) AND `cid` = `parent-author-id`)", $uid]);
|
||||
}
|
||||
|
||||
$items = Post::selectPostsForUser($uid, ['uri-id'], $condition, $params);
|
||||
|
||||
$display_quotes = self::appSupportsQuotes();
|
||||
|
|
|
@ -104,6 +104,13 @@ class Tag extends BaseApi
|
|||
$params['order'] = ['uri-id'];
|
||||
}
|
||||
|
||||
if (!empty($uid)) {
|
||||
$condition = DBA::mergeConditions(
|
||||
$condition,
|
||||
["NOT `parent-author-id` IN (SELECT `cid` FROM `user-contact` WHERE `uid` = ? AND (`blocked` OR `ignored`) AND `cid` = `parent-author-id`)", $uid]
|
||||
);
|
||||
}
|
||||
|
||||
$items = DBA::select('tag-search-view', ['uri-id'], $condition, $params);
|
||||
|
||||
$display_quotes = self::appSupportsQuotes();
|
||||
|
|
|
@ -41,6 +41,7 @@ class Links extends BaseApi
|
|||
{
|
||||
$request = $this->getRequest([
|
||||
'limit' => 10, // Maximum number of results to return. Defaults to 10.
|
||||
'offset' => 0, // Offset in set, Defaults to 0.
|
||||
], $request);
|
||||
|
||||
$condition = ["EXISTS(SELECT `id` FROM `post-media` WHERE `post-media`.`uri-id` = `post-thread-view`.`uri-id` AND `type` = ? AND NOT `name` IS NULL AND NOT `description` IS NULL) AND NOT `private` AND `commented` > ? AND `created` > ?",
|
||||
|
@ -48,13 +49,17 @@ class Links extends BaseApi
|
|||
$condition = DBA::mergeConditions($condition, ['network' => Protocol::FEDERATED]);
|
||||
|
||||
$trending = [];
|
||||
$statuses = Post::selectPostThread(['uri-id', 'total-comments', 'total-actors'], $condition, ['limit' => $request['limit'], 'order' => ['total-actors' => true]]);
|
||||
$statuses = Post::selectPostThread(['uri-id', 'total-comments', 'total-actors'], $condition, ['limit' => [$request['offset'], $request['limit']], 'offset' => $request['offset'], 'order' => ['total-actors' => true]]);
|
||||
while ($status = Post::fetch($statuses)) {
|
||||
$history = [['day' => (string)time(), 'uses' => (string)$status['total-comments'], 'accounts' => (string)$status['total-actors']]];
|
||||
$trending[] = DI::mstdnCard()->createFromUriId($status['uri-id'], $history)->toArray();
|
||||
}
|
||||
DBA::close($statuses);
|
||||
|
||||
if (!empty($trending)) {
|
||||
self::setLinkHeaderByOffsetLimit($request['offset'], $request['limit']);
|
||||
}
|
||||
|
||||
System::jsonExit($trending);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ class Statuses extends BaseApi
|
|||
|
||||
$request = $this->getRequest([
|
||||
'limit' => 10, // Maximum number of results to return. Defaults to 10.
|
||||
'offset' => 0, // Offset in set, Defaults to 0.
|
||||
], $request);
|
||||
|
||||
$condition = ["NOT `private` AND `commented` > ? AND `created` > ?", DateTimeFormat::utc('now -1 day'), DateTimeFormat::utc('now -1 week')];
|
||||
|
@ -52,7 +53,7 @@ class Statuses extends BaseApi
|
|||
$display_quotes = self::appSupportsQuotes();
|
||||
|
||||
$trending = [];
|
||||
$statuses = Post::selectPostThread(['uri-id'], $condition, ['limit' => $request['limit'], 'order' => ['total-actors' => true]]);
|
||||
$statuses = Post::selectPostThread(['uri-id'], $condition, ['limit' => [$request['offset'], $request['limit']], 'order' => ['total-actors' => true]]);
|
||||
while ($status = Post::fetch($statuses)) {
|
||||
try {
|
||||
$trending[] = DI::mstdnStatus()->createFromUriId($status['uri-id'], $uid, $display_quotes);
|
||||
|
@ -62,6 +63,10 @@ class Statuses extends BaseApi
|
|||
}
|
||||
DBA::close($statuses);
|
||||
|
||||
if (!empty($trending)) {
|
||||
self::setLinkHeaderByOffsetLimit($request['offset'], $request['limit']);
|
||||
}
|
||||
|
||||
System::jsonExit($trending);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,11 +37,18 @@ class Tags extends BaseApi
|
|||
protected function rawContent(array $request = [])
|
||||
{
|
||||
$request = $this->getRequest([
|
||||
'limit' => 20, // Maximum number of results to return. Defaults to 10.
|
||||
'limit' => 20, // Maximum number of results to return. Defaults to 20.
|
||||
'offset' => 0, // Offset in set. Defaults to 0.
|
||||
'friendica_local' => false, // Whether to return local tag trends instead of global, defaults to false
|
||||
], $request);
|
||||
|
||||
$trending = [];
|
||||
$tags = Tag::getGlobalTrendingHashtags(24, 20);
|
||||
if ($request['friendica_local']) {
|
||||
$tags = Tag::getLocalTrendingHashtags(24, $request['limit'], $request['offset']);
|
||||
} else {
|
||||
$tags = Tag::getGlobalTrendingHashtags(24, $request['limit'], $request['offset']);
|
||||
}
|
||||
|
||||
foreach ($tags as $tag) {
|
||||
$tag['name'] = $tag['term'];
|
||||
$history = [['day' => (string)time(), 'uses' => (string)$tag['score'], 'accounts' => (string)$tag['authors']]];
|
||||
|
@ -49,6 +56,10 @@ class Tags extends BaseApi
|
|||
$trending[] = $hashtag->toArray();
|
||||
}
|
||||
|
||||
System::jsonExit(array_slice($trending, 0, $request['limit']));
|
||||
if (!empty($trending)) {
|
||||
self::setLinkHeaderByOffsetLimit($request['offset'], $request['limit']);
|
||||
}
|
||||
|
||||
System::jsonExit($trending);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ abstract class ContactEndpoint extends BaseApi
|
|||
if (!$screen_name) {
|
||||
$contact = Contact::getById($contact_id, ['nick', 'url']);
|
||||
// We don't have the followers of remote accounts so we check for locality
|
||||
if (empty($contact) || !Strings::startsWith($contact['url'], DI::baseUrl()->get())) {
|
||||
if (empty($contact) || !Strings::startsWith($contact['url'], DI::baseUrl())) {
|
||||
throw new HTTPException\NotFoundException(DI::l10n()->t('Contact not found'));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue