Merge pull request #3635 from pixelfed/staging

Staging
This commit is contained in:
daniel 2022-08-29 20:08:44 -06:00 committed by GitHub
commit 204ff98dec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 47 additions and 11 deletions

View file

@ -63,6 +63,10 @@
- Add instance post/profile embed config setting ([7734dc03](https://github.com/pixelfed/pixelfed/commit/7734dc03))
- Remove remote posts from NetworkTimelineService when processing Tombstones ([2e4f2377](https://github.com/pixelfed/pixelfed/commit/2e4f2377))
- Limit NotificationService to 400 items ([f6ed560e](https://github.com/pixelfed/pixelfed/commit/f6ed560e))
- Refactor discover accounts endpoint, cache popular accounts and remove following check as most invocations are from new accounts ([016b11f3](https://github.com/pixelfed/pixelfed/commit/016b11f3))
- Fix cache invalidation in AdminSettingsController when updating rules ([fe6787f7](https://github.com/pixelfed/pixelfed/commit/fe6787f7))
- Update SearchApiService, improve account/webfinger results ([533f7165](https://github.com/pixelfed/pixelfed/commit/533f7165))
- Update NotificationService, fix account attribute ([949b7bb6](https://github.com/pixelfed/pixelfed/commit/949b7bb6))
- ([](https://github.com/pixelfed/pixelfed/commit/))
## [v0.11.3 (2022-05-09)](https://github.com/pixelfed/pixelfed/compare/v0.11.2...v0.11.3)

View file

@ -75,6 +75,8 @@ trait AdminSettingsController
unset($json[$index]);
$json = json_encode(array_values($json));
ConfigCacheService::put('app.rules', $json);
Cache::forget('api:v1:instance-data:rules');
Cache::forget('api:v1:instance-data-response-v1');
return 200;
}
@ -173,7 +175,7 @@ trait AdminSettingsController
ConfigCacheService::put('app.rules', json_encode(array_values($json)));
}
Cache::forget('api:v1:instance-data:rules');
Cache::forget('api:v1:instance-data-response');
Cache::forget('api:v1:instance-data-response-v1');
}
if($request->filled('account_autofollow_usernames')) {

View file

@ -107,7 +107,9 @@ class NotificationService {
foreach($ids as $id) {
$n = self::rewriteMastodonTypes(self::getNotification($id));
if($n != null && in_array($n['type'], self::MASTODON_TYPES)) {
if(isset($n['account'])) {
$n['account'] = AccountService::getMastodon($n['account']['id']);
}
if(isset($n['relationship'])) {
unset($n['relationship']);
@ -135,7 +137,9 @@ class NotificationService {
foreach($ids as $id) {
$n = self::rewriteMastodonTypes(self::getNotification($id));
if($n != null && in_array($n['type'], self::MASTODON_TYPES)) {
if(isset($n['account'])) {
$n['account'] = AccountService::getMastodon($n['account']['id']);
}
if(isset($n['relationship'])) {
unset($n['relationship']);

View file

@ -35,7 +35,7 @@ class SearchApiV2Service
if($query->has('resolve') &&
$query->resolve == true &&
( Str::startsWith($q, 'https://') ||
Str::substrCount($q, '@') == 2)
Str::substrCount($q, '@') >= 1)
) {
return $this->resolveQuery();
}
@ -81,13 +81,21 @@ class SearchApiV2Service
];
}
protected function accounts()
protected function accounts($initalQuery = false)
{
$mastodonMode = self::$mastodonMode;
$user = request()->user();
$limit = $this->query->input('limit') ?? 20;
$offset = $this->query->input('offset') ?? 0;
$query = '%' . $this->query->input('q') . '%';
$rawQuery = $initalQuery ? $initalQuery : $this->query->input('q');
$query = '%' . $rawQuery . '%';
if(Str::substrCount($rawQuery, '@') >= 1 && Str::contains($rawQuery, config('pixelfed.domain.app'))) {
$deliminatorCount = Str::substrCount($rawQuery, '@');
$query = explode('@', $rawQuery)[$deliminatorCount == 1 ? 0 : 1];
}
if(Str::substrCount($rawQuery, '@') == 1 && substr($rawQuery, 0, 1) == '@') {
$query = substr($rawQuery, 1) . '%';
}
$banned = InstanceService::getBannedDomains();
$results = Profile::select('profiles.*', 'followers.profile_id', 'followers.created_at')
->whereNull('status')
@ -173,8 +181,17 @@ class SearchApiV2Service
protected function resolveQuery()
{
$default = [
'accounts' => [],
'hashtags' => [],
'statuses' => [],
];
$mastodonMode = self::$mastodonMode;
$query = urldecode($this->query->input('q'));
if(substr($query, 0, 1) === '@' && !Str::contains($query, '.')) {
$default['accounts'] = $this->accounts(substr($query, 1));
return $default;
}
if(Helpers::validateLocalUrl($query)) {
if(Str::contains($query, '/p/')) {
return $this->resolveLocalStatus();
@ -182,15 +199,24 @@ class SearchApiV2Service
return $this->resolveLocalProfile();
}
} else {
$default = [
'accounts' => [],
'hashtags' => [],
'statuses' => [],
];
if(!Helpers::validateUrl($query) && strpos($query, '@') == -1) {
return $default;
}
if(Str::substrCount($query, '@') == 1 && strpos($query, '@') !== 0) {
try {
$res = WebfingerService::lookup('@' . $query, $mastodonMode);
} catch (\Exception $e) {
return $default;
}
if($res && isset($res['id'])) {
$default['accounts'][] = $res;
return $default;
} else {
return $default;
}
}
if(Str::substrCount($query, '@') == 2) {
try {
$res = WebfingerService::lookup($query, $mastodonMode);