about summary refs log tree commit diff
path: root/app/lib/command_tag/commands
diff options
context:
space:
mode:
authorFire Demon <firedemon@creature.cafe>2020-07-23 18:34:48 -0500
committerFire Demon <firedemon@creature.cafe>2020-08-30 05:45:15 -0500
commit980339b73e294e39b8fd650b5a4c25f39b31d00e (patch)
treee1040f17abf27e4adb05c7bb678f91aefeb09dbc /app/lib/command_tag/commands
parent47584d20c5c91189f0791b4b63ace361a25b614f (diff)
[Federation] Add backend support for ActivityPub object titles
Diffstat (limited to 'app/lib/command_tag/commands')
-rw-r--r--app/lib/command_tag/commands/status_tools.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/app/lib/command_tag/commands/status_tools.rb b/app/lib/command_tag/commands/status_tools.rb
new file mode 100644
index 000000000..f8b8f8ae0
--- /dev/null
+++ b/app/lib/command_tag/commands/status_tools.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+# rubocop:disable Layout/ExtraSpacing
+module CommandTag::Commands::StatusTools
+  def handle_title_before_save(args)
+    return unless author_of_status? && !@status.published?
+
+    @status.title = args[0]
+  end
+
+  def handle_visibility_before_save(args)
+    return unless author_of_status? && !@status.published? && args[0].present?
+
+    args[0] = 'public' if %w(p pu all world).include?(args[0])
+    args[0] = 'unlisted' if %w(u ul).include?(args[0])
+    args[0] = 'private' if %w(f followers followers-only packmates packmates-only).include?(args[0])
+    args[0] = 'limited' if %w(l limit).include?(args[0])
+    args[0] = 'direct' if %w(d dm pm directmessage).include?(args[0])
+
+    return unless %w(public unlisted private limited direct).include?(args[0])
+
+    @status.visibility = args[0].to_sym
+  end
+
+  alias handle_v_before_save                      handle_visibility_before_save
+  alias handle_privacy_before_save                handle_visibility_before_save
+end
+# rubocop:enable Layout/ExtraSpacing