about summary refs log tree commit diff
path: root/app/lib
diff options
context:
space:
mode:
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/bangtags.rb55
-rw-r--r--app/lib/user_settings_decorator.rb5
2 files changed, 60 insertions, 0 deletions
diff --git a/app/lib/bangtags.rb b/app/lib/bangtags.rb
index e1ad79be6..3ed56806a 100644
--- a/app/lib/bangtags.rb
+++ b/app/lib/bangtags.rb
@@ -22,6 +22,22 @@ class Bangtags
       ['media', 'stop'] => ['var', 'end'],
       ['media', 'endall'] => ['var', 'endall'],
       ['media', 'stopall'] => ['var', 'endall'],
+
+      ['admin', 'end'] => ['var', 'end'],
+      ['admin', 'stop'] => ['var', 'end'],
+      ['admin', 'endall'] => ['var', 'endall'],
+      ['admin', 'stopall'] => ['var', 'endall'],
+
+      ['parent', 'visibility'] => ['visibility', 'parent'],
+      ['parent', 'v'] => ['visibility', 'parent'],
+
+      ['parent', 'live'] => ['live', 'parent'],
+      ['parent', 'lifespan'] => ['lifespan', 'parent'],
+      ['parent', 'delete_in'] => ['delete_in', 'parent'],
+
+      ['all', 'live'] => ['live', 'all'],
+      ['all', 'lifespan'] => ['lifespan', 'all'],
+      ['all', 'delete_in'] => ['delete_in', 'all'],
     }
 
     # sections of the final status text
@@ -525,6 +541,45 @@ class Bangtags
               status.local_only = true
             end
           end
+        when 'live', 'lifespan', 'l', 'delete_in'
+          chunk = nil
+          next if cmd[1].nil?
+          case cmd[1].downcase
+          when 'parent'
+            next unless @parent_status.present? && @parent_status.account_id == @account.id
+            s = @parent_status
+            i = cmd[2].to_i
+            unit = cmd[3].present? ? cmd[3].downcase : 'minutes'
+          when 'all'
+            s = :all
+            i = cmd[2].to_i
+            unit = cmd[3].present? ? cmd[3].downcase : 'minutes'
+          else
+            s = @status
+            i = cmd[1].to_i
+            unit = cmd[2].present? ? cmd[2].downcase : 'minutes'
+          end
+          delete_after = case unit
+                         when 's', 'second', 'seconds'
+                           [60, i].max.seconds
+                         when 'm', 'minute', 'minutes'
+                           i.minutes
+                         when 'h', 'hour', 'hours'
+                           i.hours
+                         when 'd', 'day', 'days'
+                           i.days
+                         when 'w', 'week', 'weeks'
+                           i.weeks
+                         when 'm', 'month', 'months'
+                           i.months
+                         when 'y', 'year', 'years'
+                           i.years
+                         end
+          if s == :all
+            @account.statuses.find_each { |s| s.delete_after = delete_after }
+          else
+            s.delete_after = delete_after
+          end
         when 'keysmash'
           keyboard = [
             'asdf', 'jkl;',
diff --git a/app/lib/user_settings_decorator.rb b/app/lib/user_settings_decorator.rb
index 4616142f8..50632ec44 100644
--- a/app/lib/user_settings_decorator.rb
+++ b/app/lib/user_settings_decorator.rb
@@ -37,6 +37,7 @@ class UserSettingsDecorator
     user.settings['hide_public_outbox']  = hide_public_outbox_preference if change?('setting_hide_public_outbox')
     user.settings['larger_emoji']        = larger_emoji_preference if change?('setting_larger_emoji')
     user.settings['max_public_history']  = max_public_history_preference if change?('setting_max_public_history')
+    user.settings['roar_lifespan']       = roar_lifespan_preference if change?('setting_roar_lifespan')
 
     user.settings['notification_emails'] = merged_notification_emails if change?('notification_emails')
     user.settings['interactions']        = merged_interactions if change?('interactions')
@@ -130,6 +131,10 @@ class UserSettingsDecorator
     settings['setting_max_public_history']
   end
 
+  def roar_lifespan_preference
+    settings['setting_roar_lifespan']
+  end
+
   def merged_notification_emails
     user.settings['notification_emails'].merge coerced_settings('notification_emails').to_h
   end