mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-26 06:53:17 +00:00
Postgres fixes
This commit is contained in:
parent
9289792ad8
commit
1d2f76c8e5
7 changed files with 36 additions and 12 deletions
|
@ -3494,7 +3494,8 @@ class ApiV1Controller extends Controller
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = $request->filled('status') ? strip_tags($request->input('status')) : null;
|
$defaultCaption = config_cache('database.default') === 'mysql' ? null : "";
|
||||||
|
$content = $request->filled('status') ? strip_tags($request->input('status')) : $defaultCaption;
|
||||||
$cw = $user->profile->cw == true ? true : $request->boolean('sensitive', false);
|
$cw = $user->profile->cw == true ? true : $request->boolean('sensitive', false);
|
||||||
$spoilerText = $cw && $request->filled('spoiler_text') ? $request->input('spoiler_text') : null;
|
$spoilerText = $cw && $request->filled('spoiler_text') ? $request->input('spoiler_text') : null;
|
||||||
|
|
||||||
|
@ -3508,6 +3509,7 @@ class ApiV1Controller extends Controller
|
||||||
|
|
||||||
$status = new Status;
|
$status = new Status;
|
||||||
$status->caption = $content;
|
$status->caption = $content;
|
||||||
|
$status->rendered = $defaultCaption;
|
||||||
$status->scope = $visibility;
|
$status->scope = $visibility;
|
||||||
$status->visibility = $visibility;
|
$status->visibility = $visibility;
|
||||||
$status->profile_id = $user->profile_id;
|
$status->profile_id = $user->profile_id;
|
||||||
|
@ -3532,6 +3534,7 @@ class ApiV1Controller extends Controller
|
||||||
if (! $in_reply_to_id) {
|
if (! $in_reply_to_id) {
|
||||||
$status = new Status;
|
$status = new Status;
|
||||||
$status->caption = $content;
|
$status->caption = $content;
|
||||||
|
$status->rendered = $defaultCaption;
|
||||||
$status->profile_id = $user->profile_id;
|
$status->profile_id = $user->profile_id;
|
||||||
$status->is_nsfw = $cw;
|
$status->is_nsfw = $cw;
|
||||||
$status->cw_summary = $spoilerText;
|
$status->cw_summary = $spoilerText;
|
||||||
|
@ -3684,7 +3687,10 @@ class ApiV1Controller extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$defaultCaption = config_cache('database.default') === 'mysql' ? null : "";
|
||||||
$share = Status::firstOrCreate([
|
$share = Status::firstOrCreate([
|
||||||
|
'caption' => $defaultCaption,
|
||||||
|
'rendered' => $defaultCaption,
|
||||||
'profile_id' => $user->profile_id,
|
'profile_id' => $user->profile_id,
|
||||||
'reblog_of_id' => $status->id,
|
'reblog_of_id' => $status->id,
|
||||||
'type' => 'share',
|
'type' => 'share',
|
||||||
|
|
|
@ -1292,13 +1292,14 @@ class ApiV1Dot1Controller extends Controller
|
||||||
if ($user->last_active_at == null) {
|
if ($user->last_active_at == null) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
$defaultCaption = config_cache('database.default') === 'mysql' ? null : "";
|
||||||
$content = $request->filled('status') ? strip_tags(Purify::clean($request->input('status'))) : null;
|
$content = $request->filled('status') ? strip_tags(Purify::clean($request->input('status'))) : $defaultCaption;
|
||||||
$cw = $user->profile->cw == true ? true : $request->boolean('sensitive', false);
|
$cw = $user->profile->cw == true ? true : $request->boolean('sensitive', false);
|
||||||
$spoilerText = $cw && $request->filled('spoiler_text') ? $request->input('spoiler_text') : null;
|
$spoilerText = $cw && $request->filled('spoiler_text') ? $request->input('spoiler_text') : null;
|
||||||
|
|
||||||
$status = new Status;
|
$status = new Status;
|
||||||
$status->caption = $content;
|
$status->caption = $content;
|
||||||
|
$status->rendered = $defaultCaption;
|
||||||
$status->profile_id = $user->profile_id;
|
$status->profile_id = $user->profile_id;
|
||||||
$status->is_nsfw = $cw;
|
$status->is_nsfw = $cw;
|
||||||
$status->cw_summary = $spoilerText;
|
$status->cw_summary = $spoilerText;
|
||||||
|
|
|
@ -55,11 +55,14 @@ class CommentController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
$reply = DB::transaction(function () use ($comment, $status, $profile, $nsfw) {
|
$reply = DB::transaction(function () use ($comment, $status, $profile, $nsfw) {
|
||||||
|
$defaultCaption = config_cache('database.default') === 'mysql' ? null : "";
|
||||||
|
|
||||||
$scope = $profile->is_private == true ? 'private' : 'public';
|
$scope = $profile->is_private == true ? 'private' : 'public';
|
||||||
$reply = new Status;
|
$reply = new Status;
|
||||||
$reply->profile_id = $profile->id;
|
$reply->profile_id = $profile->id;
|
||||||
$reply->is_nsfw = $nsfw;
|
$reply->is_nsfw = $nsfw;
|
||||||
$reply->caption = Purify::clean($comment);
|
$reply->caption = Purify::clean($comment);
|
||||||
|
$reply->rendered = $defaultCaption;
|
||||||
$reply->in_reply_to_id = $status->id;
|
$reply->in_reply_to_id = $status->id;
|
||||||
$reply->in_reply_to_profile_id = $status->profile_id;
|
$reply->in_reply_to_profile_id = $status->profile_id;
|
||||||
$reply->scope = $scope;
|
$reply->scope = $scope;
|
||||||
|
|
|
@ -30,6 +30,7 @@ use App\Util\Media\License;
|
||||||
use Auth;
|
use Auth;
|
||||||
use Cache;
|
use Cache;
|
||||||
use DB;
|
use DB;
|
||||||
|
use Purify;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use League\Fractal;
|
use League\Fractal;
|
||||||
|
@ -569,7 +570,9 @@ class ComposeController extends Controller
|
||||||
$status->cw_summary = $request->input('spoiler_text');
|
$status->cw_summary = $request->input('spoiler_text');
|
||||||
}
|
}
|
||||||
|
|
||||||
$status->caption = strip_tags($request->caption);
|
$defaultCaption = config_cache('database.default') === 'mysql' ? null : "";
|
||||||
|
$status->caption = strip_tags($request->input('caption')) ?? $defaultCaption;
|
||||||
|
$status->rendered = $defaultCaption;
|
||||||
$status->scope = 'draft';
|
$status->scope = 'draft';
|
||||||
$status->visibility = 'draft';
|
$status->visibility = 'draft';
|
||||||
$status->profile_id = $profile->id;
|
$status->profile_id = $profile->id;
|
||||||
|
@ -673,6 +676,7 @@ class ComposeController extends Controller
|
||||||
$place = $request->input('place');
|
$place = $request->input('place');
|
||||||
$cw = $request->input('cw');
|
$cw = $request->input('cw');
|
||||||
$tagged = $request->input('tagged');
|
$tagged = $request->input('tagged');
|
||||||
|
$defaultCaption = config_cache('database.default') === 'mysql' ? null : "";
|
||||||
|
|
||||||
if ($place && is_array($place)) {
|
if ($place && is_array($place)) {
|
||||||
$status->place_id = $place['id'];
|
$status->place_id = $place['id'];
|
||||||
|
@ -682,7 +686,8 @@ class ComposeController extends Controller
|
||||||
$status->comments_disabled = (bool) $request->input('comments_disabled');
|
$status->comments_disabled = (bool) $request->input('comments_disabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
$status->caption = strip_tags($request->caption);
|
$status->caption = $request->filled('caption') ? strip_tags($request->caption) : $defaultCaption;
|
||||||
|
$status->rendered = $defaultCaption;
|
||||||
$status->profile_id = $profile->id;
|
$status->profile_id = $profile->id;
|
||||||
$entities = [];
|
$entities = [];
|
||||||
$visibility = $profile->unlisted == true && $visibility == 'public' ? 'unlisted' : $visibility;
|
$visibility = $profile->unlisted == true && $visibility == 'public' ? 'unlisted' : $visibility;
|
||||||
|
|
|
@ -309,7 +309,7 @@ class StatusController extends Controller
|
||||||
abort_if(! $statusAccount || isset($statusAccount['moved'], $statusAccount['moved']['id']), 422, 'Account moved');
|
abort_if(! $statusAccount || isset($statusAccount['moved'], $statusAccount['moved']['id']), 422, 'Account moved');
|
||||||
|
|
||||||
$count = $status->reblogs_count;
|
$count = $status->reblogs_count;
|
||||||
|
$defaultCaption = config_cache('database.default') === 'mysql' ? null : "";
|
||||||
$exists = Status::whereProfileId(Auth::user()->profile->id)
|
$exists = Status::whereProfileId(Auth::user()->profile->id)
|
||||||
->whereReblogOfId($status->id)
|
->whereReblogOfId($status->id)
|
||||||
->exists();
|
->exists();
|
||||||
|
@ -324,6 +324,8 @@ class StatusController extends Controller
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$share = new Status;
|
$share = new Status;
|
||||||
|
$share->caption = $defaultCaption;
|
||||||
|
$share->rendered = $defaultCaption;
|
||||||
$share->profile_id = $profile->id;
|
$share->profile_id = $profile->id;
|
||||||
$share->reblog_of_id = $status->id;
|
$share->reblog_of_id = $status->id;
|
||||||
$share->in_reply_to_profile_id = $status->profile_id;
|
$share->in_reply_to_profile_id = $status->profile_id;
|
||||||
|
|
|
@ -543,7 +543,7 @@ class Helpers
|
||||||
$scope = 'unlisted';
|
$scope = 'unlisted';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$defaultCaption = config_cache('database.default') === 'mysql' ? null : "";
|
||||||
$status = Status::updateOrCreate(
|
$status = Status::updateOrCreate(
|
||||||
[
|
[
|
||||||
'uri' => $url,
|
'uri' => $url,
|
||||||
|
@ -551,7 +551,8 @@ class Helpers
|
||||||
'profile_id' => $pid,
|
'profile_id' => $pid,
|
||||||
'url' => $url,
|
'url' => $url,
|
||||||
'object_url' => $id,
|
'object_url' => $id,
|
||||||
'caption' => isset($activity['content']) ? Purify::clean(strip_tags($activity['content'])) : null,
|
'caption' => isset($activity['content']) ? Purify::clean(strip_tags($activity['content'])) : $defaultCaption,
|
||||||
|
'rendered' => $defaultCaption,
|
||||||
'created_at' => Carbon::parse($ts)->tz('UTC'),
|
'created_at' => Carbon::parse($ts)->tz('UTC'),
|
||||||
'in_reply_to_id' => $reply_to,
|
'in_reply_to_id' => $reply_to,
|
||||||
'local' => false,
|
'local' => false,
|
||||||
|
@ -693,7 +694,8 @@ class Helpers
|
||||||
$status->url = isset($res['url']) ? $res['url'] : $url;
|
$status->url = isset($res['url']) ? $res['url'] : $url;
|
||||||
$status->uri = isset($res['url']) ? $res['url'] : $url;
|
$status->uri = isset($res['url']) ? $res['url'] : $url;
|
||||||
$status->object_url = $id;
|
$status->object_url = $id;
|
||||||
$status->caption = strip_tags(Purify::clean($res['content']));
|
$status->caption = strip_tags(Purify::clean($res['content'])) ?? "";
|
||||||
|
$status->rendered = "";
|
||||||
$status->created_at = Carbon::parse($ts)->tz('UTC');
|
$status->created_at = Carbon::parse($ts)->tz('UTC');
|
||||||
$status->in_reply_to_id = null;
|
$status->in_reply_to_id = null;
|
||||||
$status->local = false;
|
$status->local = false;
|
||||||
|
|
|
@ -71,9 +71,14 @@ class HttpSignature
|
||||||
public static function instanceActorSign($url, $body = false, $addlHeaders = [], $method = 'post')
|
public static function instanceActorSign($url, $body = false, $addlHeaders = [], $method = 'post')
|
||||||
{
|
{
|
||||||
$keyId = config('app.url').'/i/actor#main-key';
|
$keyId = config('app.url').'/i/actor#main-key';
|
||||||
$privateKey = Cache::rememberForever(InstanceActor::PKI_PRIVATE, function () {
|
if(config_cache('database.default') === 'mysql') {
|
||||||
return InstanceActor::first()->private_key;
|
$privateKey = Cache::rememberForever(InstanceActor::PKI_PRIVATE, function () {
|
||||||
});
|
return InstanceActor::first()->private_key;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$privateKey = InstanceActor::first()?->private_key;
|
||||||
|
}
|
||||||
|
abort_if(!$privateKey || empty($privateKey), 400, 'Missing instance actor key, please run php artisan instance:actor');
|
||||||
if ($body) {
|
if ($body) {
|
||||||
$digest = self::_digest($body);
|
$digest = self::_digest($body);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue