summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Godwin2022-12-04 20:22:24 -0700
committerAndrew Godwin2022-12-04 20:23:02 -0700
commit6291fa0f5c4d30139c23c2e2f2a1daa49852c105 (patch)
treee6b904f84fe42448839e4cc5dab3ad0aaccbcabe
parentd27be3f42619e9eaf3b8ac9333b2bf5bb290aae6 (diff)
downloadtakahe-6291fa0f5c4d30139c23c2e2f2a1daa49852c105.tar.gz
takahe-6291fa0f5c4d30139c23c2e2f2a1daa49852c105.tar.bz2
takahe-6291fa0f5c4d30139c23c2e2f2a1daa49852c105.zip
Fix mentions in replies/capitalisation
-rw-r--r--activities/models/post.py3
-rw-r--r--activities/views/compose.py7
-rw-r--r--docs/installation.rst22
-rw-r--r--tests/activities/models/test_post.py11
4 files changed, 31 insertions, 12 deletions
diff --git a/activities/models/post.py b/activities/models/post.py
index d3365e7..aa4be16 100644
--- a/activities/models/post.py
+++ b/activities/models/post.py
@@ -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:
diff --git a/activities/views/compose.py b/activities/views/compose.py
index 313fe74..b4ddcf5 100644
--- a/activities/views/compose.py
+++ b/activities/views/compose.py
@@ -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):
diff --git a/docs/installation.rst b/docs/installation.rst
index 7b5cd11..b268377 100644
--- a/docs/installation.rst
+++ b/docs/installation.rst
@@ -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
-----------
diff --git a/tests/activities/models/test_post.py b/tests/activities/models/test_post.py
index baeb55a..d215be0 100644
--- a/tests/activities/models/test_post.py
+++ b/tests/activities/models/test_post.py
@@ -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