add option for changing the monsterfork api exposure level, defaulting to `full` - if this gives your app indigestion change it to back to `basic` in preferences

master
multiple creatures 2020-01-10 23:04:14 -06:00
parent ce72d57487
commit 0f1532aee0
7 changed files with 27 additions and 6 deletions

View File

@ -51,6 +51,7 @@ class Settings::PreferencesController < Settings::BaseController
:filter_undescribed,
:invert_filters,
:filter_timelines_only,
:monsterpit_api,
chosen_languages: []
)
end

View File

@ -46,6 +46,7 @@
# media_only :boolean default(FALSE), not null
# filter_undescribed :boolean default(FALSE), not null
# filters_enabled :boolean default(FALSE), not null
# monsterfork_api :integer default("full"), not null
#
class User < ApplicationRecord
@ -81,6 +82,8 @@ class User < ApplicationRecord
include PamAuthenticable
include LdapAuthenticable
enum monsterfork_api: [:vanilla, :basic, :full]
belongs_to :account, inverse_of: :user
belongs_to :invite, counter_cache: :uses, optional: true
belongs_to :created_by_application, class_name: 'Doorkeeper::Application', optional: true

View File

@ -72,7 +72,7 @@ class REST::StatusSerializer < ActiveModel::Serializer
def visibility
if object.limited_visibility?
'private'
elsif object.local_visibility?
elsif current_user.monsterfork_api != 'full' && object.local_visibility?
'unlisted'
else
object.visibility

View File

@ -46,9 +46,6 @@
= f.input :setting_boost_interval_from, collection: [1, 2, 3, 4, 5, 6, 10, 15, 30, 60, 120, 180, 300, 360, 720, 1440], wrapper: :with_label, include_blank: false, label_method: lambda { |item| safe_join([t("simple_form.labels.boost_interval.#{item}")]) }, selected: current_user.boost_interval_from
= f.input :setting_boost_interval_to, collection: [1, 2, 3, 4, 5, 6, 10, 15, 30, 60, 120, 180, 300, 360, 720, 1440], wrapper: :with_label, include_blank: false, label_method: lambda { |item| safe_join([t("simple_form.labels.boost_interval.#{item}")]) }, selected: current_user.boost_interval_to
%hr#settings_other/
.fields-group
@ -70,6 +67,11 @@
%hr/
.fields-group
= f.input :monsterfork_api, collection: [:vanilla, :basic, :full], wrapper: :with_label, include_blank: false, label_method: lambda { |item| safe_join([t("simple_form.labels.monsterfork_api.#{item}")]) }, selected: current_user.monsterfork_api
%hr/
.fields-group
= f.input :setting_hide_network, as: :boolean, wrapper: :with_label
= f.input :setting_hide_interactions, as: :boolean, wrapper: :with_label

View File

@ -48,6 +48,7 @@ en:
phrase_html: "<strong>Examples</strong><br>Containing any terms: <code>this OR that</code><br>Containing all terms: <code>this that</code>, <code>this AND that</code><br>Containing an exact term: <code>&quot;this thing&quot;</code><br>Grouping: <code>this OR (&quot;this thing&quot; AND &quot;that thing&quot;)</code>"
media_only: Hides text-only posts
filters_enabled: Enables custom timeline filters which can be configured in the Filters tab.
monsterfork_api: How much of Monsterfork features should be exposed to clients. Set to Basic or Vanilla if your Mastodon app is having problems with Monsterfork.
featured_tag:
name: 'You might want to use one of these:'
imports:
@ -198,6 +199,11 @@ en:
filter_undescribed: Hide roars without media descriptions
media_only: Media gallery mode
filters_enabled: Enable custom filters
monsterfork_api: Monsterfork API exposure
monsterfork_api:
vanilla: Vanilla
basic: Basic
full: Full
boost_interval:
1: 1 minute
2: 2 minutes

View File

@ -0,0 +1,7 @@
class AddVisibilityCompatToggle < ActiveRecord::Migration[5.2]
def change
safety_assured do
add_column :users, :monsterfork_api, :smallint, null: false, default: 2
end
end
end

View File

@ -2398,7 +2398,8 @@ CREATE TABLE public.users (
filter_timelines_only boolean DEFAULT false NOT NULL,
media_only boolean DEFAULT false NOT NULL,
filter_undescribed boolean DEFAULT false NOT NULL,
filters_enabled boolean DEFAULT false NOT NULL
filters_enabled boolean DEFAULT false NOT NULL,
monsterfork_api smallint DEFAULT 2 NOT NULL
);
@ -5397,6 +5398,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20200110213720'),
('20200110214031'),
('20200110221801'),
('20200110221920');
('20200110221920'),
('20200111042543');