mirror of
https://github.com/friendica/friendica
synced 2024-12-23 00:00:21 +00:00
Merge pull request #14423 from annando/remove-custom-emojis
Remove custom emojis from contact names
This commit is contained in:
commit
37faff6d98
1 changed files with 15 additions and 0 deletions
|
@ -245,6 +245,8 @@ class APContact
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$apcontact['name'] = self::removeCustomEmojis($apcontact['name'], JsonLD::fetchElementArray($compacted, 'as:tag') ?? []);
|
||||||
|
|
||||||
$apcontact['photo'] = JsonLD::fetchElement($compacted, 'as:icon', '@id');
|
$apcontact['photo'] = JsonLD::fetchElement($compacted, 'as:icon', '@id');
|
||||||
if (is_array($apcontact['photo']) || !empty($compacted['as:icon']['as:url']['@id'])) {
|
if (is_array($apcontact['photo']) || !empty($compacted['as:icon']['as:url']['@id'])) {
|
||||||
$apcontact['photo'] = JsonLD::fetchElement($compacted['as:icon'], 'as:url', '@id');
|
$apcontact['photo'] = JsonLD::fetchElement($compacted['as:icon'], 'as:url', '@id');
|
||||||
|
@ -484,6 +486,19 @@ class APContact
|
||||||
return DBA::selectFirst('apcontact', [], ['url' => $apcontact['url']]) ?: [];
|
return DBA::selectFirst('apcontact', [], ['url' => $apcontact['url']]) ?: [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function removeCustomEmojis(string $name, array $tags): string
|
||||||
|
{
|
||||||
|
$original = $name;
|
||||||
|
foreach ($tags as $tag) {
|
||||||
|
if ($tag['@type'] != 'toot:Emoji') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$name = trim(str_replace($tag['as:name'], '', $name));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $name ?: $original;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch the number of statuses for the given owner
|
* Fetch the number of statuses for the given owner
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue