Merge pull request #4342 from pixelfed/staging

Staging
This commit is contained in:
daniel 2023-05-02 23:35:34 -06:00 committed by GitHub
commit c316e488fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 95 additions and 16 deletions

View file

@ -6,9 +6,13 @@
- Add php 8.2 support. Bump laravel version, v9 => v10 ([fb4ac4eb](https://github.com/pixelfed/pixelfed/commit/fb4ac4eb)) - Add php 8.2 support. Bump laravel version, v9 => v10 ([fb4ac4eb](https://github.com/pixelfed/pixelfed/commit/fb4ac4eb))
- New media:fix-nonlocal-driver command. Fixes s3 media created with invalid FILESYSTEM_DRIVER=s3 configuration ([672cccd4](https://github.com/pixelfed/pixelfed/commit/672cccd4)) - New media:fix-nonlocal-driver command. Fixes s3 media created with invalid FILESYSTEM_DRIVER=s3 configuration ([672cccd4](https://github.com/pixelfed/pixelfed/commit/672cccd4))
- New landing page design ([09c0032b](https://github.com/pixelfed/pixelfed/commit/09c0032b)) - New landing page design ([09c0032b](https://github.com/pixelfed/pixelfed/commit/09c0032b))
- Add cloud ip bans to BouncerService ([50ab2e20](https://github.com/pixelfed/pixelfed/commit/50ab2e20)) - Add cloud ip bans to BouncerService (disabled by default) ([50ab2e20](https://github.com/pixelfed/pixelfed/commit/50ab2e20))
- Redesigned Admin Dashboard Reports/Moderation ([c6cc6327](https://github.com/pixelfed/pixelfed/commit/c6cc6327)) - Redesigned Admin Dashboard Reports/Moderation ([c6cc6327](https://github.com/pixelfed/pixelfed/commit/c6cc6327))
### Fixes
- Fixed `violates check constraint "statuses_visibility_check"` bug affecting postgres instances + various api endpoints ([79b6a17e](https://github.com/pixelfed/pixelfed/commit/79b6a17e))
- Fixed duplicate hashtags on postgres ([64059cb4](https://github.com/pixelfed/pixelfed/commit/64059cb4))
### Updates ### Updates
- Update ApiV1Controller, fix blocking remote accounts. Closes #4256 ([8e71e0c0](https://github.com/pixelfed/pixelfed/commit/8e71e0c0)) - Update ApiV1Controller, fix blocking remote accounts. Closes #4256 ([8e71e0c0](https://github.com/pixelfed/pixelfed/commit/8e71e0c0))
- Update ComposeController, fix postgres location search. Closes #4242 and #4239 ([64a4a006](https://github.com/pixelfed/pixelfed/commit/64a4a006)) - Update ComposeController, fix postgres location search. Closes #4242 and #4239 ([64a4a006](https://github.com/pixelfed/pixelfed/commit/64a4a006))
@ -37,6 +41,9 @@
- Update ForgotPasswordController, add captcha support, improve security and a new redesigned view ([f6e7ff64](https://github.com/pixelfed/pixelfed/commit/f6e7ff64)) - Update ForgotPasswordController, add captcha support, improve security and a new redesigned view ([f6e7ff64](https://github.com/pixelfed/pixelfed/commit/f6e7ff64))
- Update ResetPasswordController, add captcha support, improve security and a new redesigned view ([0ab5b96a](https://github.com/pixelfed/pixelfed/commit/0ab5b96a)) - Update ResetPasswordController, add captcha support, improve security and a new redesigned view ([0ab5b96a](https://github.com/pixelfed/pixelfed/commit/0ab5b96a))
- Update Inbox, remove handleCreateActivity logic that rejected posts from accounts without followers ([a93a3efd](https://github.com/pixelfed/pixelfed/commit/a93a3efd)) - Update Inbox, remove handleCreateActivity logic that rejected posts from accounts without followers ([a93a3efd](https://github.com/pixelfed/pixelfed/commit/a93a3efd))
- Update ApiV1Controller and DiscoverController, fix postgres hashtag search ([055aa6b3](https://github.com/pixelfed/pixelfed/commit/055aa6b3))
- Update StatusTagsPipeline, deduplicate hashtags on postgres ([867cbc75](https://github.com/pixelfed/pixelfed/commit/867cbc75))
- Update SearchApiV2Service, fix postgres hashtag search and prepend wildcard operator to improve results ([6e20d0a6](https://github.com/pixelfed/pixelfed/commit/6e20d0a6))
- ([](https://github.com/pixelfed/pixelfed/commit/)) - ([](https://github.com/pixelfed/pixelfed/commit/))
## [v0.11.5 (2023-03-25)](https://github.com/pixelfed/pixelfed/compare/v0.11.4...v0.11.5) ## [v0.11.5 (2023-03-25)](https://github.com/pixelfed/pixelfed/compare/v0.11.4...v0.11.5)

View file

@ -3245,9 +3245,15 @@ class ApiV1Controller extends Controller
'limit' => 'nullable|integer|max:100' 'limit' => 'nullable|integer|max:100'
]); ]);
if(config('database.default') === 'pgsql') {
$tag = Hashtag::where('name', 'ilike', $hashtag)
->orWhere('slug', 'ilike', $hashtag)
->first();
} else {
$tag = Hashtag::whereName($hashtag) $tag = Hashtag::whereName($hashtag)
->orWhere('slug', $hashtag) ->orWhere('slug', $hashtag)
->first(); ->first();
}
if(!$tag) { if(!$tag) {
return response()->json([]); return response()->json([]);

View file

@ -61,7 +61,12 @@ class DiscoverController extends Controller
$end = $page > 1 ? $page * 9 : 0; $end = $page > 1 ? $page * 9 : 0;
$tag = $request->input('hashtag'); $tag = $request->input('hashtag');
if(config('database.default') === 'pgsql') {
$hashtag = Hashtag::where('name', 'ilike', $tag)->firstOrFail();
} else {
$hashtag = Hashtag::whereName($tag)->firstOrFail(); $hashtag = Hashtag::whereName($tag)->firstOrFail();
}
if($hashtag->is_banned == true) { if($hashtag->is_banned == true) {
return []; return [];
} }

View file

@ -71,11 +71,24 @@ class StatusTagsPipeline implements ShouldQueue
} }
} }
if(config('database.default') === 'pgsql') {
$hashtag = Hashtag::where('name', 'ilike', $name)
->orWhere('slug', 'ilike', str_slug($name))
->first();
if(!$hashtag) {
$hashtag = new Hashtag;
$hashtag->name = $name;
$hashtag->slug = str_slug($name);
$hashtag->save();
}
} else {
$hashtag = Hashtag::firstOrCreate([ $hashtag = Hashtag::firstOrCreate([
'slug' => str_slug($name) 'slug' => str_slug($name)
], [ ], [
'name' => $name 'name' => $name
]); ]);
}
StatusHashtag::firstOrCreate([ StatusHashtag::firstOrCreate([
'status_id' => $status->id, 'status_id' => $status->id,

View file

@ -125,8 +125,10 @@ class SearchApiV2Service
$q = $this->query->input('q'); $q = $this->query->input('q');
$limit = $this->query->input('limit') ?? 20; $limit = $this->query->input('limit') ?? 20;
$offset = $this->query->input('offset') ?? 0; $offset = $this->query->input('offset') ?? 0;
$query = Str::startsWith($q, '#') ? substr($q, 1) . '%' : $q . '%'; $query = Str::startsWith($q, '#') ? '%' . substr($q, 1) . '%' : '%' . $q . '%';
return Hashtag::where('name', 'like', $query) $operator = config('database.default') === 'pgsql' ? 'ilike' : 'like';
return Hashtag::where('name', $operator, $query)
->orWhere('slug', $operator, $query)
->where(function($q) { ->where(function($q) {
return $q->where('can_search', true) return $q->where('can_search', true)
->orWhereNull('can_search'); ->orWhereNull('can_search');

View file

@ -261,10 +261,10 @@ return [
'enabled' => env('PF_BOUNCER_ENABLED', false), 'enabled' => env('PF_BOUNCER_ENABLED', false),
'cloud_ips' => [ 'cloud_ips' => [
'ban_logins' => env('PF_BOUNCER_BAN_CLOUD_LOGINS', true), 'ban_logins' => env('PF_BOUNCER_BAN_CLOUD_LOGINS', false),
'ban_signups' => env('PF_BOUNCER_BAN_CLOUD_SIGNUPS', true), 'ban_signups' => env('PF_BOUNCER_BAN_CLOUD_SIGNUPS', false),
'ban_api' => env('PF_BOUNCER_BAN_CLOUD_API', true), 'ban_api' => env('PF_BOUNCER_BAN_CLOUD_API', false),
'ban_api_strict_mode' => env('PF_BOUNCER_BAN_CLOUD_API_STRICT_MODE', true), 'ban_api_strict_mode' => env('PF_BOUNCER_BAN_CLOUD_API_STRICT_MODE', false),
], ],
], ],

View file

@ -0,0 +1,46 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use App\Hashtag;
use App\StatusHashtag;
use Illuminate\Support\Facades\Cache;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
$type = config('database.default');
if($type !== 'pgsql') {
return;
}
foreach(Hashtag::lazyById(50, 'id') as $tag) {
$dups = Hashtag::where('name', 'ilike', $tag->name)->orderBy('id')->get();
if($dups->count() === 1) {
continue;
}
$first = $dups->shift();
$dups->each(function($dup) use($first) {
StatusHashtag::whereHashtagId($dup->id)->update(['hashtag_id' => $first->id]);
$dup->delete();
});
}
Cache::clear();
}
/**
* Reverse the migrations.
*/
public function down(): void
{
//
}
};