Fix mentions in replies/capitalisation
This commit is contained in:
parent
d27be3f426
commit
6291fa0f5c
|
@ -276,7 +276,7 @@ class Post(StatorModel):
|
|||
|
||||
def replacer(match):
|
||||
precursor = match.group(1)
|
||||
handle = match.group(2)
|
||||
handle = match.group(2).lower()
|
||||
if handle in possible_matches:
|
||||
return f'{precursor}<a href="{possible_matches[handle]}">@{handle}</a>'
|
||||
else:
|
||||
|
@ -383,6 +383,7 @@ class Post(StatorModel):
|
|||
mention_hits = cls.mention_regex.findall(content)
|
||||
mentions = set()
|
||||
for precursor, handle in mention_hits:
|
||||
handle = handle.lower()
|
||||
if "@" in handle:
|
||||
username, domain = handle.split("@", 1)
|
||||
else:
|
||||
|
|
|
@ -84,7 +84,12 @@ class Compose(FormView):
|
|||
initial["visibility"] = Post.Visibilities.unlisted
|
||||
else:
|
||||
initial["visibility"] = self.reply_to.visibility
|
||||
initial["text"] = f"@{self.reply_to.author.handle} "
|
||||
# Build a set of mentions for the content to start as
|
||||
mentioned = {self.reply_to.author}
|
||||
mentioned.update(self.reply_to.mentions.all())
|
||||
initial["text"] = "".join(
|
||||
f"@{identity.handle} " for identity in mentioned
|
||||
)
|
||||
return initial
|
||||
|
||||
def form_valid(self, form):
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
Installation
|
||||
============
|
||||
|
||||
We recommend running using the Docker/OCI image; this contains all of the
|
||||
necessary dependencies and static file handling preconfigured for you.
|
||||
We've tried to make installing and running Takahē as easy as possible, but
|
||||
an ActivityPub server does have a minimum level of complexity, so you should
|
||||
be experienced deploying software in order to run it.
|
||||
|
||||
All configuration is done via either environment variables, or online through
|
||||
the web interface.
|
||||
Note that getting the technology running is arguably the easiest piece of
|
||||
running a server - you must also be prepared to support your users, moderate,
|
||||
defederate, keep on top of security risks, and know how you will
|
||||
handle illegal content.
|
||||
|
||||
|
||||
Prerequisites
|
||||
|
@ -22,17 +25,16 @@ Prerequisites
|
|||
* Writable local directory (must be accessible by all running copies!)
|
||||
|
||||
Note that ActivityPub is a chatty protocol that has a lot of background
|
||||
activity, so you will need to run *background tasks*, in
|
||||
order to fetch profiles, retry delivery of posts, and more.
|
||||
|
||||
Ideally, you would choose a platform where you can run our worker process in
|
||||
the background continuously, but for small installations we have a URL you can
|
||||
call periodically instead - see "What To Run", below.
|
||||
activity, so you will need to run *background tasks*, in order to fetch
|
||||
profiles, retry delivery of posts, and more - see "Preparation", below.
|
||||
|
||||
The flagship Takahē instance, `takahe.social <https://takahe.social>`_, runs
|
||||
inside of Kubernetes, with one Deployment for the webserver and one for the
|
||||
Stator runner.
|
||||
|
||||
All configuration is done via either environment variables, or online through
|
||||
the web interface.
|
||||
|
||||
|
||||
Preparation
|
||||
-----------
|
||||
|
|
|
@ -68,6 +68,17 @@ def test_linkify_mentions_remote(identity, remote_identity):
|
|||
local=True,
|
||||
)
|
||||
assert post.safe_content_remote() == "<p>@test@example.com, welcome!</p>"
|
||||
# Test case insensitivity (remote)
|
||||
post = Post.objects.create(
|
||||
content="<p>Hey @TeSt</p>",
|
||||
author=identity,
|
||||
local=True,
|
||||
)
|
||||
post.mentions.add(remote_identity)
|
||||
assert (
|
||||
post.safe_content_remote()
|
||||
== '<p>Hey <a href="https://remote.test/@test/">@test</a></p>'
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
|
|
Loading…
Reference in New Issue