mirror of
https://github.com/jointakahe/takahe.git
synced 2024-11-25 16:51:00 +00:00
Fix mentions at the start of posts
This commit is contained in:
parent
1d37dce012
commit
63ab492439
2 changed files with 12 additions and 1 deletions
|
@ -166,7 +166,7 @@ class Post(StatorModel):
|
|||
### Content cleanup and extraction ###
|
||||
|
||||
mention_regex = re.compile(
|
||||
r"([^\w\d\-_])@([\w\d\-_]+(?:@[\w\d\-_]+\.[\w\d\-_\.]+)?)"
|
||||
r"(^|[^\w\d\-_])@([\w\d\-_]+(?:@[\w\d\-_]+\.[\w\d\-_\.]+)?)"
|
||||
)
|
||||
|
||||
def linkify_mentions(self, content, local=False):
|
||||
|
|
|
@ -94,6 +94,17 @@ def test_linkify_mentions_local(identity, remote_identity):
|
|||
post.safe_content_local()
|
||||
== '<p><a href="/@test@example.com/">@test@example.com</a>, welcome!</p>'
|
||||
)
|
||||
# Test a full username (remote) with no <p>
|
||||
post = Post.objects.create(
|
||||
content="@test@remote.test hello!",
|
||||
author=identity,
|
||||
local=True,
|
||||
)
|
||||
post.mentions.add(remote_identity)
|
||||
assert (
|
||||
post.safe_content_local()
|
||||
== '<a href="/@test@remote.test/">@test@remote.test</a> hello!'
|
||||
)
|
||||
# Test that they don't get touched without a mention
|
||||
post = Post.objects.create(
|
||||
content="<p>@test@example.com, welcome!</p>",
|
||||
|
|
Loading…
Reference in a new issue