forked from mirror/pixelfed
commit
8fad40ed26
|
@ -37,6 +37,7 @@
|
|||
- Updated InstanceActorController, fix content-type header. ([21792246](https://github.com/pixelfed/pixelfed/commit/21792246))
|
||||
- Updated Exception handler to report validation message bag errors. ([74905ba1](https://github.com/pixelfed/pixelfed/commit/74905ba1))
|
||||
- Updated ApiV1Controller, add validation messages to update_credentials endpoint. ([cd785601](https://github.com/pixelfed/pixelfed/commit/cd785601))
|
||||
- Updated ComposeController, improve location search results ordering by use frequency. ([29c4bd25](https://github.com/pixelfed/pixelfed/commit/29c4bd25))
|
||||
- ([](https://github.com/pixelfed/pixelfed/commit/))
|
||||
|
||||
## [v0.11.2 (2022-01-09)](https://github.com/pixelfed/pixelfed/compare/v0.11.1...v0.11.2)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Auth, Cache, Storage, URL;
|
||||
use Auth, Cache, DB, Storage, URL;
|
||||
use Carbon\Carbon;
|
||||
use App\{
|
||||
Avatar,
|
||||
|
@ -45,10 +45,12 @@ use App\Services\MediaBlocklistService;
|
|||
use App\Services\MediaStorageService;
|
||||
use App\Services\MediaTagService;
|
||||
use App\Services\StatusService;
|
||||
use App\Services\SnowflakeService;
|
||||
use Illuminate\Support\Str;
|
||||
use App\Util\Lexer\Autolink;
|
||||
use App\Util\Lexer\Extractor;
|
||||
use App\Util\Media\License;
|
||||
use Image;
|
||||
|
||||
class ComposeController extends Controller
|
||||
{
|
||||
|
@ -74,7 +76,7 @@ class ComposeController extends Controller
|
|||
'file.*' => function() {
|
||||
return [
|
||||
'required',
|
||||
'mimes:' . config_cache('pixelfed.media_types'),
|
||||
'mimetypes:' . config_cache('pixelfed.media_types'),
|
||||
'max:' . config_cache('pixelfed.max_photo_size'),
|
||||
];
|
||||
},
|
||||
|
@ -169,7 +171,7 @@ class ComposeController extends Controller
|
|||
'file' => function() {
|
||||
return [
|
||||
'required',
|
||||
'mimes:' . config_cache('pixelfed.media_types'),
|
||||
'mimetypes:' . config_cache('pixelfed.media_types'),
|
||||
'max:' . config_cache('pixelfed.max_photo_size'),
|
||||
];
|
||||
},
|
||||
|
@ -313,22 +315,56 @@ class ComposeController extends Controller
|
|||
$this->validate($request, [
|
||||
'q' => 'required|string|max:100'
|
||||
]);
|
||||
$pid = $request->user()->profile_id;
|
||||
abort_if(!$pid, 400);
|
||||
$q = filter_var($request->input('q'), FILTER_SANITIZE_STRING);
|
||||
$hash = hash('sha256', $q);
|
||||
$key = 'search:location:id:' . $hash;
|
||||
$places = Cache::remember($key, now()->addMinutes(15), function() use($q) {
|
||||
$key = 'pf:search:location:v1:id:' . $hash;
|
||||
$popular = Cache::remember('pf:search:location:v1:popular', 86400, function() {
|
||||
if(config('database.default') != 'mysql') {
|
||||
return [];
|
||||
}
|
||||
$minId = SnowflakeService::byDate(now()->subDays(290));
|
||||
return Status::selectRaw('id, place_id, count(place_id) as pc')
|
||||
->whereNotNull('place_id')
|
||||
->where('id', '>', $minId)
|
||||
->groupBy('place_id')
|
||||
->orderByDesc('pc')
|
||||
->limit(400)
|
||||
->get()
|
||||
->filter(function($post) {
|
||||
return $post;
|
||||
})
|
||||
->map(function($place) {
|
||||
return [
|
||||
'id' => $place->place_id,
|
||||
'count' => $place->pc
|
||||
];
|
||||
});
|
||||
});
|
||||
$places = Cache::remember($key, 900, function() use($q, $popular) {
|
||||
$q = '%' . $q . '%';
|
||||
return Place::where('name', 'like', $q)
|
||||
->take(80)
|
||||
return DB::table('places')
|
||||
->where('name', 'like', $q)
|
||||
->limit((strlen($q) > 5 ? 360 : 180))
|
||||
->get()
|
||||
->sortByDesc(function($place, $key) use($popular) {
|
||||
return $popular->filter(function($p) use($place) {
|
||||
return $p['id'] == $place->id;
|
||||
})->map(function($p) use($place) {
|
||||
return in_array($place->country, ['Canada', 'USA', 'France', 'Germany', 'United Kingdom']) ? $p['count'] : 1;
|
||||
})->values();
|
||||
})
|
||||
->map(function($r) {
|
||||
return [
|
||||
'id' => $r->id,
|
||||
'name' => $r->name,
|
||||
'country' => $r->country,
|
||||
'url' => $r->url()
|
||||
'url' => url('/discover/places/' . $r->id . '/' . $r->slug)
|
||||
];
|
||||
});
|
||||
})
|
||||
->values()
|
||||
->all();
|
||||
});
|
||||
return $places;
|
||||
}
|
||||
|
|
|
@ -257,7 +257,9 @@ class SettingsController extends Controller
|
|||
public function mediaSettings(Request $request)
|
||||
{
|
||||
$setting = UserSetting::whereUserId($request->user()->id)->firstOrFail();
|
||||
$compose = $setting->compose_settings ? json_decode($setting->compose_settings, true) : [
|
||||
$compose = $setting->compose_settings ? (
|
||||
is_string($setting->compose_settings) ? json_decode($setting->compose_settings, true) : $setting->compose_settings
|
||||
) : [
|
||||
'default_license' => null,
|
||||
'media_descriptions' => false
|
||||
];
|
||||
|
@ -278,7 +280,7 @@ class SettingsController extends Controller
|
|||
$uid = $request->user()->id;
|
||||
|
||||
$setting = UserSetting::whereUserId($uid)->firstOrFail();
|
||||
$compose = json_decode($setting->compose_settings, true);
|
||||
$compose = is_string($setting->compose_settings) ? json_decode($setting->compose_settings, true) : $setting->compose_settings;
|
||||
$changed = false;
|
||||
|
||||
if($sync) {
|
||||
|
|
Loading…
Reference in New Issue