Merge pull request #1626 from pixelfed/staging

Fix queue bug
This commit is contained in:
daniel 2019-08-20 22:22:57 -06:00 committed by GitHub
commit 2a16e64659
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 145 additions and 3 deletions

View file

@ -42,6 +42,7 @@ class CatchUnoptimizedMedia extends Command
{
DB::transaction(function() {
Media::whereNull('processed_at')
->whereNull('remote_url')
->whereNotNull('status_id')
->whereNotNull('media_path')
->whereIn('mime', [

View file

@ -0,0 +1,116 @@
<?php
namespace App\Http\Controllers\Api;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Jobs\StatusPipeline\StatusDelete;
use Auth, Cache;
use Carbon\Carbon;
use App\{
Like,
Media,
Profile,
Status
};
use App\Services\NotificationService;
class AdminApiController extends Controller
{
public function __construct()
{
$this->middleware(['auth', 'admin']);
}
public function activity(Request $request)
{
$activity = [];
$limit = request()->input('limit', 20);
$activity['captions'] = Status::select(
'id',
'caption',
'rendered',
'uri',
'profile_id',
'type',
'in_reply_to_id',
'reblog_of_id',
'is_nsfw',
'scope',
'created_at'
)->whereNull('in_reply_to_id')
->whereNull('reblog_of_id')
->orderByDesc('created_at')
->paginate($limit);
$activity['comments'] = Status::select(
'id',
'caption',
'rendered',
'uri',
'profile_id',
'type',
'in_reply_to_id',
'reblog_of_id',
'is_nsfw',
'scope',
'created_at'
)->whereNotNull('in_reply_to_id')
->whereNull('reblog_of_id')
->orderByDesc('created_at')
->paginate($limit);
return response()->json($activity, 200, [], JSON_PRETTY_PRINT);
}
public function moderateStatus(Request $request)
{
$this->validate($request, [
'type' => 'required|string|in:status,profile',
'id' => 'required|integer|min:1',
'action' => 'required|string|in:cw,unlink,unlist,suspend,delete'
]);
$type = $request->input('type');
$id = $request->input('id');
$action = $request->input('action');
if ($type == 'status') {
$status = Status::findOrFail($id);
switch ($action) {
case 'cw':
$status->is_nsfw = true;
$status->save();
break;
case 'unlink':
$status->rendered = $status->caption;
$status->save();
break;
case 'unlist':
$status->scope = 'unlisted';
$status->visibility = 'unlisted';
$status->save();
break;
default:
break;
}
} else if ($type == 'profile') {
$profile = Profile::findOrFail($id);
switch ($action) {
case 'delete':
StatusDelete::dispatch($status);
break;
default:
break;
}
}
}
}

View file

@ -227,7 +227,7 @@ class BaseApiController extends Controller
}
$monthHash = hash('sha1', date('Y').date('m'));
$userHash = hash('sha1', $user->id.(string) $user->created_at);
$userHash = hash('sha1', $user->id . (string) $user->created_at);
$photo = $request->file('file');

View file

@ -6,6 +6,7 @@ use App\Http\Controllers\Api\BaseApiController;
use App\{
Follower,
Like,
Place,
Profile,
UserFilter
};
@ -78,4 +79,24 @@ class ApiController extends BaseApiController
return response()->json($res->all());
}
public function composeLocationSearch(Request $request)
{
$this->validate($request, [
'q' => 'required|string'
]);
$places = Place::where('name', 'like', '%' . $request->input('q') . '%')
->take(25)
->get()
->map(function($r) {
return [
'id' => $r->id,
'name' => $r->name,
'country' => $r->country,
'url' => $r->url()
];
});
return $places;
}
}

View file

@ -239,7 +239,8 @@ class InternalApiController extends Controller
'media.*.filter_class' => 'nullable|alpha_dash|max:30',
'media.*.license' => 'nullable|string|max:80',
'cw' => 'nullable|boolean',
'visibility' => 'required|string|in:public,private,unlisted|min:2|max:10'
'visibility' => 'required|string|in:public,private,unlisted|min:2|max:10',
'place' => 'nullable'
]);
if(config('costar.enabled') == true) {
@ -283,6 +284,9 @@ class InternalApiController extends Controller
array_push($mimes, $m->mime);
}
if($request->filled('place')) {
$status->place_id = $request->input('place')['id'];
}
$status->caption = strip_tags($request->caption);
$status->scope = 'draft';
$status->profile_id = $profile->id;

View file

@ -47,7 +47,7 @@ class StatusTransformer extends Fractal\TransformerAbstract
'thread' => false,
'replies' => [],
'parent' => [],
//'place' => $status->place
'place' => $status->place
];
}