[COMPONENT][ACTOR CIRCLE] mention self tag circle with @#self_tag
This commit is contained in:
parent
f9bc1c790f
commit
01d5e84a08
|
@ -47,6 +47,7 @@ use Doctrine\ORM\QueryBuilder;
|
||||||
use Functional as F;
|
use Functional as F;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use App\Util\Nickname;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component responsible for extracting tags from posted notes, as well as normalizing them
|
* Component responsible for extracting tags from posted notes, as well as normalizing them
|
||||||
|
@ -57,9 +58,10 @@ use Symfony\Component\HttpFoundation\Request;
|
||||||
*/
|
*/
|
||||||
class Tag extends Component
|
class Tag extends Component
|
||||||
{
|
{
|
||||||
public const MAX_TAG_LENGTH = 64;
|
public const MAX_TAG_LENGTH = 64;
|
||||||
public const TAG_REGEX = '/(^|\\s)(#[\\pL\\pN_\\-]{1,64})/u'; // Brion Vibber 2011-02-23 v2:classes/Notice.php:367 function saveTags
|
public const TAG_REGEX = '/(^|\\s)(#[\\pL\\pN_\\-]{1,64})/u'; // Brion Vibber 2011-02-23 v2:classes/Notice.php:367 function saveTags
|
||||||
public const TAG_SLUG_REGEX = '[A-Za-z0-9]{1,64}';
|
public const TAG_CIRCLE_REGEX = '/' . Nickname::BEFORE_MENTIONS . '@#([\pL\pN_\-\.]{1,64})/';
|
||||||
|
public const TAG_SLUG_REGEX = '[A-Za-z0-9]{1,64}';
|
||||||
|
|
||||||
public function onAddRoute($r): bool
|
public function onAddRoute($r): bool
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,6 +24,7 @@ namespace App\Entity;
|
||||||
use App\Core\Cache;
|
use App\Core\Cache;
|
||||||
use App\Core\DB\DB;
|
use App\Core\DB\DB;
|
||||||
use App\Core\Entity;
|
use App\Core\Entity;
|
||||||
|
use App\Core\Router\Router;
|
||||||
use DateTimeInterface;
|
use DateTimeInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -185,6 +186,10 @@ class ActorCircle extends Entity
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getUrl(int $type = Router::ABSOLUTE_PATH): string {
|
||||||
|
return Router::url('actor_circle', ['actor_id' => $this->getTagger(), 'tag' => $this->getTag()]);
|
||||||
|
}
|
||||||
|
|
||||||
public static function schemaDef(): array
|
public static function schemaDef(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|
|
@ -60,6 +60,10 @@ abstract class Main
|
||||||
$r->connect('panel', '/panel', [C\AdminPanel::class, 'site']);
|
$r->connect('panel', '/panel', [C\AdminPanel::class, 'site']);
|
||||||
$r->connect('panel_site', '/panel/site', [C\AdminPanel::class, 'site']);
|
$r->connect('panel_site', '/panel/site', [C\AdminPanel::class, 'site']);
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: don't do
|
||||||
|
$r->connect('actor_circle', '/', RedirectController::class, ['defaults' => ['route' => 'feed_public']]);
|
||||||
|
|
||||||
// FAQ static pages
|
// FAQ static pages
|
||||||
foreach (['faq', 'contact', 'tags', 'groups', 'openid'] as $s) {
|
foreach (['faq', 'contact', 'tags', 'groups', 'openid'] as $s) {
|
||||||
$r->connect('doc_' . $s, '/doc/' . $s, C\TemplateController::class, ['template' => 'doc/faq/' . $s . '.html.twig']);
|
$r->connect('doc_' . $s, '/doc/' . $s, C\TemplateController::class, ['template' => 'doc/faq/' . $s . '.html.twig']);
|
||||||
|
|
|
@ -39,9 +39,12 @@ use App\Entity\Note;
|
||||||
use App\Util\Exception\NicknameException;
|
use App\Util\Exception\NicknameException;
|
||||||
use App\Util\Exception\ServerException;
|
use App\Util\Exception\ServerException;
|
||||||
use Component\Group\Entity\LocalGroup;
|
use Component\Group\Entity\LocalGroup;
|
||||||
|
use Component\Tag\Tag;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Functional as F;
|
use Functional as F;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
|
use App\Core\DB\DB;
|
||||||
|
use App\Entity\ActorCircle;
|
||||||
|
|
||||||
abstract class Formatting
|
abstract class Formatting
|
||||||
{
|
{
|
||||||
|
@ -327,33 +330,43 @@ abstract class Formatting
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@#/tag
|
||||||
// TODO Tag subscriptions
|
// TODO Tag subscriptions
|
||||||
// @#tag => mention of all subscriptions tagged 'tag'
|
// @#tag => mention of all subscriptions tagged 'tag'
|
||||||
// $tag_matches = [];
|
$tag_matches = [];
|
||||||
// preg_match_all(
|
preg_match_all(
|
||||||
// '/' . Nickname::BEFORE_MENTIONS . '@#([\pL\pN_\-\.]{1,64})/',
|
Tag::TAG_CIRCLE_REGEX,
|
||||||
// $text,
|
$text,
|
||||||
// $tag_matches,
|
$tag_matches,
|
||||||
// PREG_OFFSET_CAPTURE
|
PREG_OFFSET_CAPTURE
|
||||||
// );
|
);
|
||||||
// foreach ($tag_matches[1] as $tag_match) {
|
foreach ($tag_matches[1] as $tag_match) {
|
||||||
// $tag = self::canonicalTag($tag_match[0]);
|
$tag = Tag::ensureValid($tag_match[0]);
|
||||||
// $plist = Profile_list::getByTaggerAndTag($actor->getID(), $tag);
|
$ac = DB::findOneBy(ActorCircle::class, [
|
||||||
// if (!$plist instanceof Profile_list || $plist->private) {
|
'or' => [
|
||||||
// continue;
|
'tagger' => $actor->getID(),
|
||||||
// }
|
'and' => [
|
||||||
// $tagged = $actor->getTaggedSubscribers($tag);
|
'tagger' => null,
|
||||||
// $url = common_local_url(
|
'tagged' => $actor->getID(),
|
||||||
// 'showprofiletag',
|
]
|
||||||
// ['nickname' => $actor->getNickname(), 'tag' => $tag]
|
],
|
||||||
// );
|
'tag' => $tag,
|
||||||
// $mentions[] = ['mentioned' => $tagged,
|
], return_null: true);
|
||||||
// 'type' => 'list',
|
|
||||||
// 'text' => $tag_match[0],
|
if (\is_null($ac) || $ac->getPrivate()) {
|
||||||
// 'position' => $tag_match[1],
|
continue;
|
||||||
// 'length' => mb_strlen($tag_match[0]),
|
}
|
||||||
// 'url' => $url, ];
|
$tagged = $ac->getSubscribedActors();
|
||||||
// }
|
$url = $ac->getUrl();
|
||||||
|
$mentions[] = [
|
||||||
|
'mentioned' => $tagged,
|
||||||
|
'type' => 'list',
|
||||||
|
'text' => $tag_match[0],
|
||||||
|
'position' => $tag_match[1],
|
||||||
|
'length' => mb_strlen($tag_match[0]),
|
||||||
|
'url' => $url,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
// Group mentions
|
// Group mentions
|
||||||
$group_matches = self::findMentionsRaw($text, '!');
|
$group_matches = self::findMentionsRaw($text, '!');
|
||||||
|
|
Loading…
Reference in New Issue
Block a user