Merge pull request #3661 from pixelfed/staging

Staging
This commit is contained in:
daniel 2022-09-19 03:51:36 -06:00 committed by GitHub
commit d036b032c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 108 additions and 22 deletions

View file

@ -81,6 +81,8 @@
- Update PronounService, fix json_decode null parameter ([d72cd819](https://github.com/pixelfed/pixelfed/commit/d72cd819))
- Update ApiV1Controller, normalize profile id comparison ([374bfdae](https://github.com/pixelfed/pixelfed/commit/374bfdae))
- Update ApiV1Controller, fix pagination header. Fixes #3354 ([4fe07e6f](https://github.com/pixelfed/pixelfed/commit/4fe07e6f))
- Update ApiV1Controller, add optional place_id parameter to POST /api/v1/statuses endpoint ([ef0d1f84](https://github.com/pixelfed/pixelfed/commit/ef0d1f84))
- Update SettingsController, fix double json encoding and cache settings for 7 days ([4514ab1d](https://github.com/pixelfed/pixelfed/commit/4514ab1d))
- ([](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

@ -2477,6 +2477,7 @@ class ApiV1Controller extends Controller
'sensitive' => 'nullable',
'visibility' => 'string|in:private,unlisted,public',
'spoiler_text' => 'sometimes|max:140',
'place_id' => 'sometimes|integer|min:1|max:128769'
]);
if(config('costar.enabled') == true) {
@ -2566,6 +2567,9 @@ class ApiV1Controller extends Controller
$status->scope = 'draft';
$status->is_nsfw = $cw;
$status->cw_summary = $spoilerText;
if($request->has('place_id')) {
$status->place_id = $request->input('place_id');
}
$status->save();
}

View file

@ -12,6 +12,8 @@ use App\Status;
use App\Report;
use App\Profile;
use App\Services\AccountService;
use App\Services\StatusService;
use App\Services\ProfileStatusService;
class ApiV1Dot1Controller extends Controller
{
@ -166,4 +168,40 @@ class ApiV1Dot1Controller extends Controller
return AccountService::get($user->profile_id);
}
/**
* GET /api/v1.1/accounts/{id}/posts
*
* @return \App\Transformer\Api\StatusTransformer
*/
public function accountPosts(Request $request, $id)
{
$user = $request->user();
abort_if(!$user, 403);
abort_if($user->status != null, 403);
$account = AccountService::get($id);
if(!$account || $account['username'] !== $request->input('username')) {
return $this->json([]);
}
$posts = ProfileStatusService::get($id);
if(!$posts) {
return $this->json([]);
}
$res = collect($posts)
->map(function($id) {
return StatusService::get($id);
})
->filter(function($post) {
return $post && isset($post['account']);
})
->toArray();
return $this->json($res);
}
}

View file

@ -303,7 +303,7 @@ class SettingsController extends Controller
}
if($changed) {
$setting->compose_settings = json_encode($compose);
$setting->compose_settings = $compose;
$setting->save();
Cache::forget('profile:compose:settings:' . $request->user()->id);
}

View file

@ -74,27 +74,29 @@ class AccountService
public static function settings($id)
{
$settings = UserSetting::whereUserId($id)->first();
if(!$settings) {
return self::defaultSettings();
}
return collect($settings)
->filter(function($item, $key) {
return in_array($key, array_keys(self::defaultSettings())) == true;
})
->map(function($item, $key) {
if($key == 'compose_settings') {
$cs = self::defaultSettings()['compose_settings'];
$ms = is_array($item) ? $item : [];
return array_merge($cs, $ms);
return Cache::remember('profile:compose:settings:' . $id, 604800, function() use($id) {
$settings = UserSetting::whereUserId($id)->first();
if(!$settings) {
return self::defaultSettings();
}
return collect($settings)
->filter(function($item, $key) {
return in_array($key, array_keys(self::defaultSettings())) == true;
})
->map(function($item, $key) {
if($key == 'compose_settings') {
$cs = self::defaultSettings()['compose_settings'];
$ms = is_array($item) ? $item : [];
return array_merge($cs, $ms);
}
if($key == 'other') {
$other = self::defaultSettings()['other'];
$mo = is_array($item) ? $item : [];
return array_merge($other, $mo);
}
return $item;
if($key == 'other') {
$other = self::defaultSettings()['other'];
$mo = is_array($item) ? $item : [];
return array_merge($other, $mo);
}
return $item;
});
});
}

View file

@ -0,0 +1,38 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use App\UserSetting;
class FixDoubleJsonEncodedSettingsInUsersettingsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
UserSetting::whereNotNull('compose_settings')
->chunk(50, function($settings) {
foreach($settings as $userSetting) {
if(is_array($userSetting->compose_settings)) {
continue;
}
$userSetting->compose_settings = json_decode($userSetting->compose_settings);
$userSetting->save();
}
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
}
}

View file

@ -100,6 +100,7 @@ Route::group(['prefix' => 'api'], function() use($middleware) {
Route::group(['prefix' => 'v1.1'], function() use($middleware) {
Route::post('report', 'Api\ApiV1Dot1Controller@report')->middleware($middleware);
Route::delete('accounts/avatar', 'Api\ApiV1Dot1Controller@deleteAvatar')->middleware($middleware);
Route::get('accounts/{id}/posts', 'Api\ApiV1Dot1Controller@accountPosts')->middleware($middleware);
Route::group(['prefix' => 'direct'], function () use($middleware) {
Route::get('thread', 'DirectMessageController@thread')->middleware($middleware);
@ -116,8 +117,9 @@ Route::group(['prefix' => 'api'], function() use($middleware) {
Route::get('recent', 'StoryController@recent')->middleware($middleware);
});
Route::group(['prefix' => 'compose/v0'], function () use($middleware) {
Route::get('/search/location', 'ComposeController@searchLocation')->middleware($middleware);
Route::group(['prefix' => 'compose'], function () use($middleware) {
Route::get('search/location', 'ComposeController@searchLocation')->middleware($middleware);
Route::get('settings', 'ComposeController@composeSettings')->middleware($middleware);
});
Route::group(['prefix' => 'discover'], function () use($middleware) {