mirror of
https://github.com/pixelfed/pixelfed.git
synced 2025-01-26 22:40:45 +00:00
Update InternalApiController, add media tags
This commit is contained in:
parent
b3b220b9b3
commit
ee93f4598c
1 changed files with 20 additions and 1 deletions
|
@ -10,6 +10,7 @@ use App\{
|
||||||
Follower,
|
Follower,
|
||||||
Like,
|
Like,
|
||||||
Media,
|
Media,
|
||||||
|
MediaTag,
|
||||||
Notification,
|
Notification,
|
||||||
Profile,
|
Profile,
|
||||||
StatusHashtag,
|
StatusHashtag,
|
||||||
|
@ -30,6 +31,7 @@ use League\Fractal\Serializer\ArraySerializer;
|
||||||
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
|
use App\Services\MediaTagService;
|
||||||
use App\Services\ModLogService;
|
use App\Services\ModLogService;
|
||||||
use App\Services\PublicTimelineService;
|
use App\Services\PublicTimelineService;
|
||||||
|
|
||||||
|
@ -258,7 +260,8 @@ class InternalApiController extends Controller
|
||||||
'cw' => 'nullable|boolean',
|
'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',
|
'place' => 'nullable',
|
||||||
'comments_disabled' => 'nullable'
|
'comments_disabled' => 'nullable',
|
||||||
|
'tagged' => 'nullable'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if(config('costar.enabled') == true) {
|
if(config('costar.enabled') == true) {
|
||||||
|
@ -282,6 +285,7 @@ class InternalApiController extends Controller
|
||||||
$mimes = [];
|
$mimes = [];
|
||||||
$place = $request->input('place');
|
$place = $request->input('place');
|
||||||
$cw = $request->input('cw');
|
$cw = $request->input('cw');
|
||||||
|
$tagged = $request->input('tagged');
|
||||||
|
|
||||||
foreach($medias as $k => $media) {
|
foreach($medias as $k => $media) {
|
||||||
if($k + 1 > config('pixelfed.max_album_length')) {
|
if($k + 1 > config('pixelfed.max_album_length')) {
|
||||||
|
@ -328,6 +332,21 @@ class InternalApiController extends Controller
|
||||||
$media->save();
|
$media->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach($tagged as $tg) {
|
||||||
|
$mt = new MediaTag;
|
||||||
|
$mt->status_id = $status->id;
|
||||||
|
$mt->media_id = $status->media->first()->id;
|
||||||
|
$mt->profile_id = $tg['id'];
|
||||||
|
$mt->tagged_username = $tg['name'];
|
||||||
|
$mt->is_public = true; // (bool) $tg['privacy'] ?? 1;
|
||||||
|
$mt->metadata = json_encode([
|
||||||
|
'_v' => 1,
|
||||||
|
]);
|
||||||
|
$mt->save();
|
||||||
|
MediaTagService::set($mt->status_id, $mt->profile_id);
|
||||||
|
MediaTagService::sendNotification($mt);
|
||||||
|
}
|
||||||
|
|
||||||
$visibility = $profile->unlisted == true && $visibility == 'public' ? 'unlisted' : $visibility;
|
$visibility = $profile->unlisted == true && $visibility == 'public' ? 'unlisted' : $visibility;
|
||||||
$cw = $profile->cw == true ? true : $cw;
|
$cw = $profile->cw == true ? true : $cw;
|
||||||
$status->is_nsfw = $cw;
|
$status->is_nsfw = $cw;
|
||||||
|
|
Loading…
Reference in a new issue