Merge pull request #3069 from pixelfed/staging

Staging
This commit is contained in:
daniel 2021-12-22 01:00:50 -07:00 committed by GitHub
commit bcba16f928
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 20 additions and 16 deletions

View file

@ -106,7 +106,7 @@ class PublicApiController extends Controller
return response()->json($res); return response()->json($res);
} }
public function statusState(Request $request, $username, int $postid) public function statusState(Request $request, $username, $postid)
{ {
$profile = Profile::whereUsername($username)->whereNull('status')->firstOrFail(); $profile = Profile::whereUsername($username)->whereNull('status')->firstOrFail();
$status = Status::whereProfileId($profile->id)->findOrFail($postid); $status = Status::whereProfileId($profile->id)->findOrFail($postid);
@ -294,6 +294,7 @@ class PublicApiController extends Controller
'local' 'local'
) )
->where('id', $dir, $id) ->where('id', $dir, $id)
->whereNull(['in_reply_to_id', 'reblog_of_id'])
->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album']) ->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])
->whereLocal(true) ->whereLocal(true)
->whereScope('public') ->whereScope('public')
@ -306,8 +307,9 @@ class PublicApiController extends Controller
return $status; return $status;
}) })
->filter(function($s) use($filtered) { ->filter(function($s) use($filtered) {
return in_array($s['account']['id'], $filtered) == false; return $s && in_array($s['account']['id'], $filtered) == false;
}); })
->values();
$res = $timeline->toArray(); $res = $timeline->toArray();
} else { } else {
$timeline = Status::select( $timeline = Status::select(
@ -330,6 +332,7 @@ class PublicApiController extends Controller
'reblogs_count', 'reblogs_count',
'updated_at' 'updated_at'
) )
->whereNull(['in_reply_to_id', 'reblog_of_id'])
->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album']) ->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])
->with('profile', 'hashtags', 'mentions') ->with('profile', 'hashtags', 'mentions')
->whereLocal(true) ->whereLocal(true)
@ -343,8 +346,9 @@ class PublicApiController extends Controller
return $status; return $status;
}) })
->filter(function($s) use($filtered) { ->filter(function($s) use($filtered) {
return in_array($s['account']['id'], $filtered) == false; return $s && in_array($s['account']['id'], $filtered) == false;
}); })
->values();
$res = $timeline->toArray(); $res = $timeline->toArray();
} }
@ -538,15 +542,7 @@ class PublicApiController extends Controller
$max = $request->input('max_id'); $max = $request->input('max_id');
$limit = $request->input('limit') ?? 3; $limit = $request->input('limit') ?? 3;
$user = $request->user(); $user = $request->user();
$amin = SnowflakeService::byDate(now()->subDays(90)); $amin = SnowflakeService::byDate(now()->subDays(490));
$key = 'user:last_active_at:id:'.$user->id;
$ttl = now()->addMinutes(5);
Cache::remember($key, $ttl, function() use($user) {
$user->last_active_at = now();
$user->save();
return;
});
$filtered = $user ? UserFilterService::filters($user->profile_id) : []; $filtered = $user ? UserFilterService::filters($user->profile_id) : [];
@ -561,6 +557,7 @@ class PublicApiController extends Controller
'created_at', 'created_at',
) )
->where('id', $dir, $id) ->where('id', $dir, $id)
->whereNull(['in_reply_to_id', 'reblog_of_id'])
->whereNotIn('profile_id', $filtered) ->whereNotIn('profile_id', $filtered)
->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album']) ->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])
->whereNotNull('uri') ->whereNotNull('uri')
@ -583,6 +580,7 @@ class PublicApiController extends Controller
'scope', 'scope',
'created_at', 'created_at',
) )
->whereNull(['in_reply_to_id', 'reblog_of_id'])
->whereNotIn('profile_id', $filtered) ->whereNotIn('profile_id', $filtered)
->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album']) ->whereIn('type', ['photo', 'photo:album', 'video', 'video:album', 'photo:video:album'])
->whereNotNull('uri') ->whereNotNull('uri')

BIN
public/js/spa.js vendored

Binary file not shown.

Binary file not shown.

View file

@ -1259,7 +1259,11 @@ export default {
axios.post('/api/compose/v0/publish', data) axios.post('/api/compose/v0/publish', data)
.then(res => { .then(res => {
let data = res.data; let data = res.data;
window.location.href = data; if(location.pathname === '/i/web/compose') {
location.href = '/i/web/post/' + data.split('/').at(-1);
} else {
location.href = data;
}
}).catch(err => { }).catch(err => {
let msg = err.response.data.message ? err.response.data.message : 'An unexpected error occured.' let msg = err.response.data.message ? err.response.data.message : 'An unexpected error occured.'
swal('Oops, something went wrong!', msg, 'error'); swal('Oops, something went wrong!', msg, 'error');

View file

@ -178,7 +178,7 @@
if(!this.recommendedLoading) { if(!this.recommendedLoading) {
return; return;
} }
axios.get('/api/pixelfed/v2/discover/posts') axios.get('/api/v1/discover/posts')
.then((res) => { .then((res) => {
this.posts = res.data.posts.filter(r => r != null); this.posts = res.data.posts.filter(r => r != null);
this.recommendedLoading = false; this.recommendedLoading = false;

View file

@ -208,6 +208,8 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
Route::get('blocks', 'AccountController@accountBlocksV2'); Route::get('blocks', 'AccountController@accountBlocksV2');
Route::get('filters', 'AccountController@accountFiltersV2'); Route::get('filters', 'AccountController@accountFiltersV2');
}); });
Route::get('discover/accounts/popular', 'Api\ApiV1Controller@discoverAccountsPopular');
}); });
Route::group(['prefix' => 'local'], function () { Route::group(['prefix' => 'local'], function () {