From 980339b73e294e39b8fd650b5a4c25f39b31d00e Mon Sep 17 00:00:00 2001 From: Fire Demon Date: Thu, 23 Jul 2020 18:34:48 -0500 Subject: [Federation] Add backend support for ActivityPub object titles --- app/lib/command_tag/commands/status_tools.rb | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 app/lib/command_tag/commands/status_tools.rb (limited to 'app/lib/command_tag/commands/status_tools.rb') 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 -- cgit