matchAll(self::SCAN_RE) ->map(function ($match) use ($activitypub) { $tag = Cache::remember(self::CACHE_KEY.$match, 14400, function () use ($match) { $emoji = self::orderBy('id')->whereDisabled(false)->whereShortcode(':'.$match.':')->first(); if (! $emoji) { return null; } return [ 'id' => $emoji->id, 'shortcode' => $emoji->shortcode, 'media_path' => $emoji->media_path, 'updated_at' => optional($emoji->updated_at)->toAtomString(), 'disabled' => $emoji->disabled, ]; }); if ($tag) { $url = url('/storage/'.$tag['media_path']); if ($activitypub == true) { $mediaType = Str::endsWith($url, '.png') ? 'image/png' : 'image/jpg'; return [ 'id' => url('emojis/'.$tag['id']), 'type' => 'Emoji', 'name' => $tag['shortcode'], 'updated' => $tag['updated_at'], 'icon' => [ 'type' => 'Image', 'mediaType' => $mediaType, 'url' => $url, ], ]; } else { return [ 'shortcode' => $match, 'url' => $url, 'static_url' => $url, 'visible_in_picker' => $tag['disabled'] == false, ]; } } }) ->filter(function ($tag) use ($activitypub) { if ($activitypub == true) { return $tag && isset($tag['icon']); } else { return $tag && isset($tag['static_url']); } }) ->values() ->toArray(); } }