mirror of https://github.com/pixelfed/pixelfed
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
632 B
PHP
27 lines
632 B
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use App\Profile;
|
|
use Cache;
|
|
use Purify;
|
|
|
|
class AutolinkService
|
|
{
|
|
const CACHE_KEY = 'pf:services:autolink:mue:';
|
|
|
|
public static function mentionedUsernameExists($username)
|
|
{
|
|
if (str_starts_with($username, '@')) {
|
|
if (substr_count($username, '@') === 1) {
|
|
$username = substr($username, 1);
|
|
}
|
|
}
|
|
$name = Purify::clean(strtolower($username));
|
|
|
|
return Cache::remember(self::CACHE_KEY.base64_encode($name), 7200, function () use ($name) {
|
|
return Profile::where('username', $name)->exists();
|
|
});
|
|
}
|
|
}
|