Fix mentions in replies/capitalisation
This commit is contained in:
parent
d27be3f426
commit
6291fa0f5c
@ -276,7 +276,7 @@ class Post(StatorModel):
|
|||||||
|
|
||||||
def replacer(match):
|
def replacer(match):
|
||||||
precursor = match.group(1)
|
precursor = match.group(1)
|
||||||
handle = match.group(2)
|
handle = match.group(2).lower()
|
||||||
if handle in possible_matches:
|
if handle in possible_matches:
|
||||||
return f'{precursor}<a href="{possible_matches[handle]}">@{handle}</a>'
|
return f'{precursor}<a href="{possible_matches[handle]}">@{handle}</a>'
|
||||||
else:
|
else:
|
||||||
@ -383,6 +383,7 @@ class Post(StatorModel):
|
|||||||
mention_hits = cls.mention_regex.findall(content)
|
mention_hits = cls.mention_regex.findall(content)
|
||||||
mentions = set()
|
mentions = set()
|
||||||
for precursor, handle in mention_hits:
|
for precursor, handle in mention_hits:
|
||||||
|
handle = handle.lower()
|
||||||
if "@" in handle:
|
if "@" in handle:
|
||||||
username, domain = handle.split("@", 1)
|
username, domain = handle.split("@", 1)
|
||||||
else:
|
else:
|
||||||
|
@ -84,7 +84,12 @@ class Compose(FormView):
|
|||||||
initial["visibility"] = Post.Visibilities.unlisted
|
initial["visibility"] = Post.Visibilities.unlisted
|
||||||
else:
|
else:
|
||||||
initial["visibility"] = self.reply_to.visibility
|
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
|
return initial
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
Installation
|
Installation
|
||||||
============
|
============
|
||||||
|
|
||||||
We recommend running using the Docker/OCI image; this contains all of the
|
We've tried to make installing and running Takahē as easy as possible, but
|
||||||
necessary dependencies and static file handling preconfigured for you.
|
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
|
Note that getting the technology running is arguably the easiest piece of
|
||||||
the web interface.
|
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
|
Prerequisites
|
||||||
@ -22,17 +25,16 @@ Prerequisites
|
|||||||
* Writable local directory (must be accessible by all running copies!)
|
* Writable local directory (must be accessible by all running copies!)
|
||||||
|
|
||||||
Note that ActivityPub is a chatty protocol that has a lot of background
|
Note that ActivityPub is a chatty protocol that has a lot of background
|
||||||
activity, so you will need to run *background tasks*, in
|
activity, so you will need to run *background tasks*, in order to fetch
|
||||||
order to fetch profiles, retry delivery of posts, and more.
|
profiles, retry delivery of posts, and more - see "Preparation", below.
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
The flagship Takahē instance, `takahe.social <https://takahe.social>`_, runs
|
The flagship Takahē instance, `takahe.social <https://takahe.social>`_, runs
|
||||||
inside of Kubernetes, with one Deployment for the webserver and one for the
|
inside of Kubernetes, with one Deployment for the webserver and one for the
|
||||||
Stator runner.
|
Stator runner.
|
||||||
|
|
||||||
|
All configuration is done via either environment variables, or online through
|
||||||
|
the web interface.
|
||||||
|
|
||||||
|
|
||||||
Preparation
|
Preparation
|
||||||
-----------
|
-----------
|
||||||
|
@ -68,6 +68,17 @@ def test_linkify_mentions_remote(identity, remote_identity):
|
|||||||
local=True,
|
local=True,
|
||||||
)
|
)
|
||||||
assert post.safe_content_remote() == "<p>@test@example.com, welcome!</p>"
|
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
|
@pytest.mark.django_db
|
||||||
|
Reference in New Issue
Block a user