[COMPONENT][FreeNetwork] Mention and Group tags in notes are handled differently
This commit is contained in:
parent
7678e155d9
commit
c380cbd846
|
@ -500,11 +500,16 @@ class FreeNetwork extends Component
|
|||
return false;
|
||||
}
|
||||
|
||||
public static function mentionToName(string $nickname, string $uri): string
|
||||
public static function mentionTagToName(string $nickname, string $uri): string
|
||||
{
|
||||
return '@' . $nickname . '@' . parse_url($uri, \PHP_URL_HOST);
|
||||
}
|
||||
|
||||
public static function groupTagToName(string $nickname, string $uri): string
|
||||
{
|
||||
return '!' . $nickname . '@' . parse_url($uri, \PHP_URL_HOST);
|
||||
}
|
||||
|
||||
public function onPluginVersion(array &$versions): bool
|
||||
{
|
||||
$versions[] = [
|
||||
|
|
|
@ -390,11 +390,19 @@ class Note extends Model
|
|||
|
||||
// Mentions
|
||||
foreach ($object->getNotificationTargets() as $mention) {
|
||||
$attr['tag'][] = [
|
||||
'type' => 'Mention',
|
||||
'href' => ($href = $mention->getUri()),
|
||||
'name' => FreeNetwork::mentionToName($mention->getNickname(), $href),
|
||||
];
|
||||
if ($mention->isGroup()) {
|
||||
$attr['tag'][] = [
|
||||
'type' => 'Group',
|
||||
'href' => ($href = $mention->getUri()),
|
||||
'name' => FreeNetwork::groupTagToName($mention->getNickname(), $href),
|
||||
];
|
||||
} else {
|
||||
$attr['tag'][] = [
|
||||
'type' => 'Mention',
|
||||
'href' => ($href = $mention->getUri()),
|
||||
'name' => FreeNetwork::mentionTagToName($mention->getNickname(), $href),
|
||||
];
|
||||
}
|
||||
$attr['to'][] = $href;
|
||||
}
|
||||
|
||||
|
|
|
@ -199,10 +199,18 @@ class Runtime implements RuntimeExtensionInterface, EventSubscriberInterface
|
|||
|
||||
public function mention(Actor $actor): string
|
||||
{
|
||||
if ($actor->getIsLocal()) {
|
||||
return "@{$actor->getNickname()}";
|
||||
if ($actor->isGroup()) {
|
||||
if ($actor->getIsLocal()) {
|
||||
return "!{$actor->getNickname()}";
|
||||
} else {
|
||||
return FreeNetwork::groupTagToName($actor->getNickname(), $actor->getUri(type: Router::ABSOLUTE_URL));
|
||||
}
|
||||
} else {
|
||||
return FreeNetwork::mentionToName($actor->getNickname(), $actor->getUri(type: Router::ABSOLUTE_URL));
|
||||
if ($actor->getIsLocal()) {
|
||||
return "@{$actor->getNickname()}";
|
||||
} else {
|
||||
return FreeNetwork::mentionTagToName($actor->getNickname(), $actor->getUri(type: Router::ABSOLUTE_URL));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user