1
0
Fork 0
forked from mirror/pixelfed

Update custom emoji, add config_cache support

This commit is contained in:
Daniel Supernault 2024-03-11 22:42:26 -06:00
parent 8a89e3c963
commit 481314cd23
No known key found for this signature in database
GPG key ID: 23740873EE6F76A1
6 changed files with 13 additions and 12 deletions

View file

@ -424,7 +424,7 @@ class AdminController extends Controller
public function customEmojiHome(Request $request)
{
if(!config('federation.custom_emoji.enabled')) {
if(!(bool) config_cache('federation.custom_emoji.enabled')) {
return view('admin.custom-emoji.not-enabled');
}
$this->validate($request, [
@ -497,7 +497,7 @@ class AdminController extends Controller
public function customEmojiToggleActive(Request $request, $id)
{
abort_unless(config('federation.custom_emoji.enabled'), 404);
abort_unless((bool) config_cache('federation.custom_emoji.enabled'), 404);
$emoji = CustomEmoji::findOrFail($id);
$emoji->disabled = !$emoji->disabled;
$emoji->save();
@ -508,13 +508,13 @@ class AdminController extends Controller
public function customEmojiAdd(Request $request)
{
abort_unless(config('federation.custom_emoji.enabled'), 404);
abort_unless((bool) config_cache('federation.custom_emoji.enabled'), 404);
return view('admin.custom-emoji.add');
}
public function customEmojiStore(Request $request)
{
abort_unless(config('federation.custom_emoji.enabled'), 404);
abort_unless((bool) config_cache('federation.custom_emoji.enabled'), 404);
$this->validate($request, [
'shortcode' => [
'required',
@ -545,7 +545,7 @@ class AdminController extends Controller
public function customEmojiDelete(Request $request, $id)
{
abort_unless(config('federation.custom_emoji.enabled'), 404);
abort_unless((bool) config_cache('federation.custom_emoji.enabled'), 404);
$emoji = CustomEmoji::findOrFail($id);
Storage::delete("public/{$emoji->media_path}");
Cache::forget('pf:custom_emoji');
@ -555,7 +555,7 @@ class AdminController extends Controller
public function customEmojiShowDuplicates(Request $request, $id)
{
abort_unless(config('federation.custom_emoji.enabled'), 404);
abort_unless((bool) config_cache('federation.custom_emoji.enabled'), 404);
$emoji = CustomEmoji::orderBy('id')->whereDisabled(false)->whereShortcode($id)->firstOrFail();
$emojis = CustomEmoji::whereShortcode($id)->where('id', '!=', $emoji->id)->cursorPaginate(10);
return view('admin.custom-emoji.duplicates', compact('emoji', 'emojis'));

View file

@ -18,7 +18,7 @@ class CustomEmoji extends Model
public static function scan($text, $activitypub = false)
{
if(config('federation.custom_emoji.enabled') == false) {
if((bool) config_cache('federation.custom_emoji.enabled') == false) {
return [];
}

View file

@ -97,6 +97,7 @@ class ConfigCacheService
'captcha.active.register',
'captcha.triggers.login.enabled',
'captcha.triggers.login.attempts',
'federation.custom_emoji.enabled',
// 'system.user_mode'
];

View file

@ -13,7 +13,7 @@ class CustomEmojiService
{
public static function get($shortcode)
{
if(config('federation.custom_emoji.enabled') == false) {
if((bool) config_cache('federation.custom_emoji.enabled') == false) {
return;
}
@ -22,7 +22,7 @@ class CustomEmojiService
public static function import($url, $id = false)
{
if(config('federation.custom_emoji.enabled') == false) {
if((bool) config_cache('federation.custom_emoji.enabled') == false) {
return;
}

View file

@ -358,7 +358,7 @@
<tr>
<td><span class="badge badge-primary">FEDERATION</span></td>
<td><strong>PF_NETWORK_TIMELINE</strong></td>
<td><span>{{config_cache('federation.network_timeline') ? '✅ true' : '❌ false' }}</span></td>
<td><span>{{(bool) config_cache('federation.network_timeline') ? '✅ true' : '❌ false' }}</span></td>
</tr>
<tr>
<td><span class="badge badge-primary">FEDERATION</span></td>
@ -368,7 +368,7 @@
<tr>
<td><span class="badge badge-primary">FEDERATION</span></td>
<td><strong>CUSTOM_EMOJI</strong></td>
<td><span>{{config_cache('federation.custom_emoji.enabled') ? '✅ true' : '❌ false' }}</span></td>
<td><span>{{(bool) config_cache('federation.custom_emoji.enabled') ? '✅ true' : '❌ false' }}</span></td>
</tr>
<tr>
<td><span class="badge badge-primary">FEDERATION</span></td>

View file

@ -81,7 +81,7 @@
</div>
</div>
@if(config('captcha.enabled') || config('captcha.active.register'))
@if((bool) config_cache('captcha.enabled') && (bool) config_cache('captcha.active.register'))
<div class="d-flex justify-content-center my-3">
{!! Captcha::display() !!}
</div>