summaryrefslogtreecommitdiffstats
path: root/activities
diff options
context:
space:
mode:
authorMichael Manfre2022-11-26 12:09:31 -0500
committerGitHub2022-11-26 10:09:31 -0700
commit849c221aeeee89bdb61a88b4e6080481ecfeb934 (patch)
tree323b5a720adf214f4bbbbdaadbcd30249bcdcec5 /activities
parentc7588583927e004e10599912f6d7b76413d52730 (diff)
downloadtakahe-849c221aeeee89bdb61a88b4e6080481ecfeb934.tar.gz
takahe-849c221aeeee89bdb61a88b4e6080481ecfeb934.tar.bz2
takahe-849c221aeeee89bdb61a88b4e6080481ecfeb934.zip
Local-only posting
Diffstat (limited to 'activities')
-rw-r--r--activities/migrations/0001_initial.py1
-rw-r--r--activities/models/post.py11
-rw-r--r--activities/views/posts.py3
3 files changed, 11 insertions, 4 deletions
diff --git a/activities/migrations/0001_initial.py b/activities/migrations/0001_initial.py
index 82a9085..f7961df 100644
--- a/activities/migrations/0001_initial.py
+++ b/activities/migrations/0001_initial.py
@@ -60,6 +60,7 @@ class Migration(migrations.Migration):
models.IntegerField(
choices=[
(0, "Public"),
+ (4, "Local Only"),
(1, "Unlisted"),
(2, "Followers"),
(3, "Mentioned"),
diff --git a/activities/models/post.py b/activities/models/post.py
index dd82bcf..f75c526 100644
--- a/activities/models/post.py
+++ b/activities/models/post.py
@@ -64,6 +64,7 @@ class Post(StatorModel):
class Visibilities(models.IntegerChoices):
public = 0
+ local_only = 4
unlisted = 1
followers = 2
mentioned = 3
@@ -261,6 +262,9 @@ class Post(StatorModel):
mentions.add(identity)
if reply_to:
mentions.add(reply_to.author)
+ # Maintain local-only for replies
+ if reply_to.visibility == reply_to.Visibilities.local_only:
+ visibility = reply_to.Visibilities.local_only
# Strip all HTML and apply linebreaks filter
content = linebreaks_filter(strip_html(content))
# Make the Post object
@@ -361,11 +365,12 @@ class Post(StatorModel):
reply_post = await self.ain_reply_to_post()
if reply_post:
targets.add(reply_post.author)
- # If this is a remote post, filter to only include local identities
- if not self.local:
+ # If this is a remote post or local-only, filter to only include
+ # local identities
+ if not self.local or self.visibility == Post.Visibilities.local_only:
targets = {target for target in targets if target.local}
# If it's a local post, include the author
- else:
+ if self.local:
targets.add(self.author)
return targets
diff --git a/activities/views/posts.py b/activities/views/posts.py
index 8cd91a1..e1609cc 100644
--- a/activities/views/posts.py
+++ b/activities/views/posts.py
@@ -172,6 +172,7 @@ class Compose(FormView):
visibility = forms.ChoiceField(
choices=[
(Post.Visibilities.public, "Public"),
+ (Post.Visibilities.local_only, "Local Only"),
(Post.Visibilities.unlisted, "Unlisted"),
(Post.Visibilities.followers, "Followers & Mentioned Only"),
(Post.Visibilities.mentioned, "Mentioned Only"),
@@ -207,7 +208,7 @@ class Compose(FormView):
] = self.request.identity.config_identity.default_post_visibility
if self.reply_to:
initial["reply_to"] = self.reply_to.pk
- initial["visibility"] = Post.Visibilities.unlisted
+ initial["visibility"] = self.reply_to.visibility
initial["text"] = f"@{self.reply_to.author.handle} "
return initial