about summary refs log tree commit diff
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-07-18 12:08:17 -0500
committermultiple creatures <dev@multiple-creature.party>2019-07-18 12:08:17 -0500
commit42618190b14c08a737a84041f9644eac1ddc2262 (patch)
tree68cbd3bbe58f913658abb5fee75fda586a7dcd7a
parent96050ff1d9604ec73ebba6e3189f5011eafe41fe (diff)
add `visibility:parent` bangtag to allow retroactive post visibility changes (currently only between `local` & `unlisted`)
-rw-r--r--app/lib/bangtags.rb19
1 files changed, 17 insertions, 2 deletions
diff --git a/app/lib/bangtags.rb b/app/lib/bangtags.rb
index 4254d4c99..409dddcac 100644
--- a/app/lib/bangtags.rb
+++ b/app/lib/bangtags.rb
@@ -492,8 +492,23 @@ class Bangtags
             'world'       => :public,
             'p'           => :public,
           }
-          v = cmd[1].downcase
-          status.visibility = visibilities[v] unless visibilities[v].nil?
+          allowed_visibility_changes = {
+            'unlisted'    => [:local],
+            'local'       => [:unlisted],
+          }
+          if cmd[1].downcase == 'parent'
+            next unless cmd[2].present? && @parent_status.present? && @parent_status.account_id == @account.id
+            v = visibilities[cmd[2].downcase]
+            o = @parent_status.visibility
+            next if v.nil? || allowed_visibility_changes[o].nil?
+            next unless allowed_visibility_changes[o].include?(v)
+            @parent_status.visibility = v
+            @parent_status.save
+            FanOutOnWriteService.new.call(@parent_status)
+          else
+            v = cmd[1].downcase
+            status.visibility = visibilities[v] unless visibilities[v].nil?
+          end
         when 'keysmash'
           keyboard = [
             'asdf', 'jkl;',