Skip to content
This repository has been archived by the owner on Aug 2, 2020. It is now read-only.

Commit

Permalink
Fix type for max_toot_chars and max_bio_chars in instance info (#163)
Browse files Browse the repository at this point in the history
* fix type of max_bio_chars and max_toot_chars

* treat max_{bio,toot}_chars as ints in admin settings
  • Loading branch information
1011X authored Aug 14, 2019
1 parent f54dd69 commit 93ab13a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions app/controllers/admin/settings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ class SettingsController < BaseController
preview_sensitive_media
profile_directory
).freeze

INTEGER_SETTINGS = %w(
max_bio_chars
max_toot_chars
).freeze

UPLOAD_SETTINGS = %w(
thumbnail
Expand Down
7 changes: 7 additions & 0 deletions app/models/form/admin_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ class Form::AdminSettings
preview_sensitive_media
profile_directory
).freeze

INTEGER_KEYS = %i(
max_bio_chars
max_toot_chars
).freeze

UPLOAD_KEYS = %i(
thumbnail
Expand Down Expand Up @@ -91,6 +96,8 @@ def initialize_attributes
def typecast_value(key, value)
if BOOLEAN_KEYS.include?(key)
value == '1'
elsif INTEGER_KEYS.include?(key)
value.to_i
else
value
end
Expand Down
4 changes: 2 additions & 2 deletions app/serializers/rest/instance_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ def thumbnail
end

def max_toot_chars
Setting.max_toot_chars
Setting.max_toot_chars.to_i
end

def max_bio_chars
Setting.max_bio_chars
Setting.max_bio_chars.to_i
end

def stats
Expand Down

0 comments on commit 93ab13a

Please sign in to comment.