diff options
Diffstat (limited to 'app/controllers')
52 files changed, 101 insertions, 83 deletions
diff --git a/app/controllers/api/base_controller.rb b/app/controllers/api/base_controller.rb index eca558f42..dd81b09e5 100644 --- a/app/controllers/api/base_controller.rb +++ b/app/controllers/api/base_controller.rb @@ -94,4 +94,20 @@ class Api::BaseController < ApplicationController def set_cache_headers response.headers['Cache-Control'] = 'no-cache, no-store, max-age=0, must-revalidate' end + + def monsterfork_api + @monsterfork_api ||= _monsterfork_api + end + + private + + def _monsterfork_api + return :full if current_user.nil? + return current_user.monsterfork_api.to_sym unless doorkeeper_token && doorkeeper_token.application.present? + app = doorkeeper_token.application.name.downcase.strip.gsub(/ +/, '_') + return :vanilla if ENV.fetch('MONSTERFORK_API_FORCE_VANILLA', '').downcase.split.include?(app) + return :basic if ENV.fetch('MONSTERFORK_API_FORCE_BASIC', '').downcase.split.include?(app) + return :full if ENV.fetch('MONSTERFORK_API_FORCE_FULL', '').downcase.split.include?(app) + current_user.monsterfork_api.to_sym + end end diff --git a/app/controllers/api/oembed_controller.rb b/app/controllers/api/oembed_controller.rb index 37a163cd3..25c877ecd 100644 --- a/app/controllers/api/oembed_controller.rb +++ b/app/controllers/api/oembed_controller.rb @@ -5,7 +5,7 @@ class Api::OEmbedController < Api::BaseController def show @status = status_finder.status - render json: @status, serializer: OEmbedSerializer, width: maxwidth_or_default, height: maxheight_or_default + render json: @status, serializer: OEmbedSerializer, width: maxwidth_or_default, height: maxheight_or_default, monsterfork_api: monsterfork_api end private diff --git a/app/controllers/api/proofs_controller.rb b/app/controllers/api/proofs_controller.rb index a84ad2014..3e7443641 100644 --- a/app/controllers/api/proofs_controller.rb +++ b/app/controllers/api/proofs_controller.rb @@ -7,7 +7,7 @@ class Api::ProofsController < Api::BaseController before_action :check_account_suspension def index - render json: @account, serializer: @provider.serializer_class + render json: @account, serializer: @provider.serializer_class, monsterfork_api: monsterfork_api end private diff --git a/app/controllers/api/v1/accounts/credentials_controller.rb b/app/controllers/api/v1/accounts/credentials_controller.rb index e77f57910..7cbea0ab9 100644 --- a/app/controllers/api/v1/accounts/credentials_controller.rb +++ b/app/controllers/api/v1/accounts/credentials_controller.rb @@ -7,7 +7,7 @@ class Api::V1::Accounts::CredentialsController < Api::BaseController def show @account = current_account - render json: @account, serializer: REST::CredentialAccountSerializer + render json: @account, serializer: REST::CredentialAccountSerializer, monsterfork_api: monsterfork_api end def update @@ -15,7 +15,7 @@ class Api::V1::Accounts::CredentialsController < Api::BaseController UpdateAccountService.new.call(@account, account_params, raise_error: true) UserSettingsDecorator.new(current_user).update(user_settings_params) if user_settings_params ActivityPub::UpdateDistributionWorker.perform_async(@account.id) - render json: @account, serializer: REST::CredentialAccountSerializer + render json: @account, serializer: REST::CredentialAccountSerializer, monsterfork_api: monsterfork_api end private diff --git a/app/controllers/api/v1/accounts/follower_accounts_controller.rb b/app/controllers/api/v1/accounts/follower_accounts_controller.rb index 166d64495..a86b5bb51 100644 --- a/app/controllers/api/v1/accounts/follower_accounts_controller.rb +++ b/app/controllers/api/v1/accounts/follower_accounts_controller.rb @@ -9,7 +9,7 @@ class Api::V1::Accounts::FollowerAccountsController < Api::BaseController def index @accounts = load_accounts - render json: @accounts, each_serializer: REST::AccountSerializer + render json: @accounts, each_serializer: REST::AccountSerializer, monsterfork_api: monsterfork_api end private diff --git a/app/controllers/api/v1/accounts/following_accounts_controller.rb b/app/controllers/api/v1/accounts/following_accounts_controller.rb index 8fa523463..45feababf 100644 --- a/app/controllers/api/v1/accounts/following_accounts_controller.rb +++ b/app/controllers/api/v1/accounts/following_accounts_controller.rb @@ -9,7 +9,7 @@ class Api::V1::Accounts::FollowingAccountsController < Api::BaseController def index @accounts = load_accounts - render json: @accounts, each_serializer: REST::AccountSerializer + render json: @accounts, each_serializer: REST::AccountSerializer, monsterfork_api: monsterfork_api end private diff --git a/app/controllers/api/v1/accounts/identity_proofs_controller.rb b/app/controllers/api/v1/accounts/identity_proofs_controller.rb index bea51ae11..286df7a41 100644 --- a/app/controllers/api/v1/accounts/identity_proofs_controller.rb +++ b/app/controllers/api/v1/accounts/identity_proofs_controller.rb @@ -8,7 +8,7 @@ class Api::V1::Accounts::IdentityProofsController < Api::BaseController def index @proofs = @account.identity_proofs.active - render json: @proofs, each_serializer: REST::IdentityProofSerializer + render json: @proofs, each_serializer: REST::IdentityProofSerializer, monsterfork_api: monsterfork_api end private diff --git a/app/controllers/api/v1/accounts/lists_controller.rb b/app/controllers/api/v1/accounts/lists_controller.rb index 72392453c..dd6402b34 100644 --- a/app/controllers/api/v1/accounts/lists_controller.rb +++ b/app/controllers/api/v1/accounts/lists_controller.rb @@ -9,7 +9,7 @@ class Api::V1::Accounts::ListsController < Api::BaseController def index @lists = @account.lists.where(account: current_account) - render json: @lists, each_serializer: REST::ListSerializer + render json: @lists, each_serializer: REST::ListSerializer, monsterfork_api: monsterfork_api end private diff --git a/app/controllers/api/v1/accounts/pins_controller.rb b/app/controllers/api/v1/accounts/pins_controller.rb index 0a0239c42..c37c0d0d0 100644 --- a/app/controllers/api/v1/accounts/pins_controller.rb +++ b/app/controllers/api/v1/accounts/pins_controller.rb @@ -11,13 +11,13 @@ class Api::V1::Accounts::PinsController < Api::BaseController def create AccountPin.create!(account: current_account, target_account: @account) - render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships_presenter + render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships_presenter, monsterfork_api: monsterfork_api end def destroy pin = AccountPin.find_by(account: current_account, target_account: @account) pin&.destroy! - render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships_presenter + render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships_presenter, monsterfork_api: monsterfork_api end private diff --git a/app/controllers/api/v1/accounts/relationships_controller.rb b/app/controllers/api/v1/accounts/relationships_controller.rb index e8e777ae8..a146596d5 100644 --- a/app/controllers/api/v1/accounts/relationships_controller.rb +++ b/app/controllers/api/v1/accounts/relationships_controller.rb @@ -15,7 +15,7 @@ class Api::V1::Accounts::RelationshipsController < Api::BaseController else @accounts = Account.none end - render json: @accounts, each_serializer: REST::RelationshipSerializer, relationships: relationships + render json: @accounts, each_serializer: REST::RelationshipSerializer, relationships: relationships, monsterfork_api: monsterfork_api end private diff --git a/app/controllers/api/v1/accounts/search_controller.rb b/app/controllers/api/v1/accounts/search_controller.rb index b15268923..47477f164 100644 --- a/app/controllers/api/v1/accounts/search_controller.rb +++ b/app/controllers/api/v1/accounts/search_controller.rb @@ -8,7 +8,7 @@ class Api::V1::Accounts::SearchController < Api::BaseController def show @accounts = account_search - render json: @accounts, each_serializer: REST::AccountSerializer + render json: @accounts, each_serializer: REST::AccountSerializer, monsterfork_api: monsterfork_api end private diff --git a/app/controllers/api/v1/accounts/statuses_controller.rb b/app/controllers/api/v1/accounts/statuses_controller.rb index 35fcce2dd..bd0fbd686 100644 --- a/app/controllers/api/v1/accounts/statuses_controller.rb +++ b/app/controllers/api/v1/accounts/statuses_controller.rb @@ -9,7 +9,7 @@ class Api::V1::Accounts::StatusesController < Api::BaseController def index @statuses = load_statuses - render json: @statuses, each_serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new(@statuses, current_user&.account_id) + render json: @statuses, each_serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new(@statuses, current_user&.account_id), monsterfork_api: monsterfork_api end private diff --git a/app/controllers/api/v1/accounts_controller.rb b/app/controllers/api/v1/accounts_controller.rb index e452bd0f5..5fc3d9606 100644 --- a/app/controllers/api/v1/accounts_controller.rb +++ b/app/controllers/api/v1/accounts_controller.rb @@ -15,7 +15,7 @@ class Api::V1::AccountsController < Api::BaseController respond_to :json def show - render json: @account, serializer: REST::AccountSerializer + render json: @account, serializer: REST::AccountSerializer, monsterfork_api: monsterfork_api end def create @@ -33,32 +33,32 @@ class Api::V1::AccountsController < Api::BaseController options = @account.locked? ? {} : { following_map: { @account.id => { reblogs: truthy_param?(:reblogs) } }, requested_map: { @account.id => false } } - render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships(options) + render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships(options), monsterfork_api: monsterfork_api end def block BlockService.new.call(current_user.account, @account) - render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships + render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships, monsterfork_api: monsterfork_api end def mute MuteService.new.call(current_user.account, @account, notifications: truthy_param?(:notifications), timelines_only: truthy_param?(:timelines_only)) - render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships + render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships, monsterfork_api: monsterfork_api end def unfollow UnfollowService.new.call(current_user.account, @account) - render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships + render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships, monsterfork_api: monsterfork_api end def unblock UnblockService.new.call(current_user.account, @account) - render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships + render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships, monsterfork_api: monsterfork_api end def unmute UnmuteService.new.call(current_user.account, @account) - render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships + render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships, monsterfork_api: monsterfork_api end private diff --git a/app/controllers/api/v1/apps/credentials_controller.rb b/app/controllers/api/v1/apps/credentials_controller.rb index 8b63d0490..8219d95f3 100644 --- a/app/controllers/api/v1/apps/credentials_controller.rb +++ b/app/controllers/api/v1/apps/credentials_controller.rb @@ -6,6 +6,6 @@ class Api::V1::Apps::CredentialsController < Api::BaseController respond_to :json def show - render json: doorkeeper_token.application, serializer: REST::ApplicationSerializer, fields: %i(name website vapid_key) + render json: doorkeeper_token.application, serializer: REST::ApplicationSerializer, fields: %i(name website vapid_key), monsterfork_api: monsterfork_api end end diff --git a/app/controllers/api/v1/apps_controller.rb b/app/controllers/api/v1/apps_controller.rb index e9f7a7291..eb163f38f 100644 --- a/app/controllers/api/v1/apps_controller.rb +++ b/app/controllers/api/v1/apps_controller.rb @@ -3,7 +3,7 @@ class Api::V1::AppsController < Api::BaseController def create @app = Doorkeeper::Application.create!(application_options) - render json: @app, serializer: REST::ApplicationSerializer + render json: @app, serializer: REST::ApplicationSerializer, monsterfork_api: monsterfork_api end private diff --git a/app/controllers/api/v1/blocks_controller.rb b/app/controllers/api/v1/blocks_controller.rb index 4cff04cad..84ce56e16 100644 --- a/app/controllers/api/v1/blocks_controller.rb +++ b/app/controllers/api/v1/blocks_controller.rb @@ -9,7 +9,7 @@ class Api::V1::BlocksController < Api::BaseController def index @accounts = load_accounts - render json: @accounts, each_serializer: REST::AccountSerializer + render json: @accounts, each_serializer: REST::AccountSerializer, monsterfork_api: monsterfork_api end private diff --git a/app/controllers/api/v1/bookmarks_controller.rb b/app/controllers/api/v1/bookmarks_controller.rb index 1cab3c372..d8a83d0ea 100644 --- a/app/controllers/api/v1/bookmarks_controller.rb +++ b/app/controllers/api/v1/bookmarks_controller.rb @@ -9,7 +9,7 @@ class Api::V1::BookmarksController < Api::BaseController def index @statuses = load_statuses - render json: @statuses, each_serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new(@statuses, current_user&.account_id) + render json: @statuses, each_serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new(@statuses, current_user&.account_id), monsterfork_api: monsterfork_api end private diff --git a/app/controllers/api/v1/conversations_controller.rb b/app/controllers/api/v1/conversations_controller.rb index b19f27ebf..5606ca4e3 100644 --- a/app/controllers/api/v1/conversations_controller.rb +++ b/app/controllers/api/v1/conversations_controller.rb @@ -13,12 +13,12 @@ class Api::V1::ConversationsController < Api::BaseController def index @conversations = paginated_conversations - render json: @conversations, each_serializer: REST::ConversationSerializer + render json: @conversations, each_serializer: REST::ConversationSerializer, monsterfork_api: monsterfork_api end def read @conversation.update!(unread: false) - render json: @conversation, serializer: REST::ConversationSerializer + render json: @conversation, serializer: REST::ConversationSerializer, monsterfork_api: monsterfork_api end def destroy diff --git a/app/controllers/api/v1/endorsements_controller.rb b/app/controllers/api/v1/endorsements_controller.rb index 2770c7aef..5b0ce4e3c 100644 --- a/app/controllers/api/v1/endorsements_controller.rb +++ b/app/controllers/api/v1/endorsements_controller.rb @@ -9,7 +9,7 @@ class Api::V1::EndorsementsController < Api::BaseController def index @accounts = load_accounts - render json: @accounts, each_serializer: REST::AccountSerializer + render json: @accounts, each_serializer: REST::AccountSerializer, monsterfork_api: monsterfork_api end private diff --git a/app/controllers/api/v1/favourites_controller.rb b/app/controllers/api/v1/favourites_controller.rb index db827f9d4..d80a11e32 100644 --- a/app/controllers/api/v1/favourites_controller.rb +++ b/app/controllers/api/v1/favourites_controller.rb @@ -9,7 +9,7 @@ class Api::V1::FavouritesController < Api::BaseController def index @statuses = load_statuses - render json: @statuses, each_serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new(@statuses, current_user&.account_id) + render json: @statuses, each_serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new(@statuses, current_user&.account_id), monsterfork_api: monsterfork_api end private diff --git a/app/controllers/api/v1/filters_controller.rb b/app/controllers/api/v1/filters_controller.rb index ffef0b920..cd1b78922 100644 --- a/app/controllers/api/v1/filters_controller.rb +++ b/app/controllers/api/v1/filters_controller.rb @@ -10,23 +10,23 @@ class Api::V1::FiltersController < Api::BaseController respond_to :json def index - render json: @filters, each_serializer: REST::FilterSerializer + render json: @filters, each_serializer: REST::FilterSerializer, monsterfork_api: monsterfork_api end def create @filter = current_account.custom_filters.create!(resource_params) toggle_filters - render json: @filter, serializer: REST::FilterSerializer + render json: @filter, serializer: REST::FilterSerializer, monsterfork_api: monsterfork_api end def show - render json: @filter, serializer: REST::FilterSerializer + render json: @filter, serializer: REST::FilterSerializer, monsterfork_api: monsterfork_api end def update @filter.update!(resource_params) toggle_filters - render json: @filter, serializer: REST::FilterSerializer + render json: @filter, serializer: REST::FilterSerializer, monsterfork_api: monsterfork_api end def destroy diff --git a/app/controllers/api/v1/follow_requests_controller.rb b/app/controllers/api/v1/follow_requests_controller.rb index e6888154e..289455981 100644 --- a/app/controllers/api/v1/follow_requests_controller.rb +++ b/app/controllers/api/v1/follow_requests_controller.rb @@ -8,7 +8,7 @@ class Api::V1::FollowRequestsController < Api::BaseController def index @accounts = load_accounts - render json: @accounts, each_serializer: REST::AccountSerializer + render json: @accounts, each_serializer: REST::AccountSerializer, monsterfork_api: monsterfork_api end def authorize diff --git a/app/controllers/api/v1/follows_controller.rb b/app/controllers/api/v1/follows_controller.rb index 5420c0533..94e377622 100644 --- a/app/controllers/api/v1/follows_controller.rb +++ b/app/controllers/api/v1/follows_controller.rb @@ -16,7 +16,7 @@ class Api::V1::FollowsController < Api::BaseController @account = Account.find_remote!(username, domain) end - render json: @account, serializer: REST::AccountSerializer + render json: @account, serializer: REST::AccountSerializer, monsterfork_api: monsterfork_api end private diff --git a/app/controllers/api/v1/lists/accounts_controller.rb b/app/controllers/api/v1/lists/accounts_controller.rb index 23078263e..b7f5a36f3 100644 --- a/app/controllers/api/v1/lists/accounts_controller.rb +++ b/app/controllers/api/v1/lists/accounts_controller.rb @@ -11,7 +11,7 @@ class Api::V1::Lists::AccountsController < Api::BaseController def show @accounts = load_accounts - render json: @accounts, each_serializer: REST::AccountSerializer + render json: @accounts, each_serializer: REST::AccountSerializer, monsterfork_api: monsterfork_api end def create diff --git a/app/controllers/api/v1/lists_controller.rb b/app/controllers/api/v1/lists_controller.rb index 4ff3f8505..230811908 100644 --- a/app/controllers/api/v1/lists_controller.rb +++ b/app/controllers/api/v1/lists_controller.rb @@ -9,21 +9,21 @@ class Api::V1::ListsController < Api::BaseController def index @lists = List.where(account: current_account).all - render json: @lists, each_serializer: REST::ListSerializer + render json: @lists, each_serializer: REST::ListSerializer, monsterfork_api: monsterfork_api end def show - render json: @list, serializer: REST::ListSerializer + render json: @list, serializer: REST::ListSerializer, monsterfork_api: monsterfork_api end def create @list = List.create!(list_params.merge(account: current_account)) - render json: @list, serializer: REST::ListSerializer + render json: @list, serializer: REST::ListSerializer, monsterfork_api: monsterfork_api end def update @list.update!(list_params) - render json: @list, serializer: REST::ListSerializer + render json: @list, serializer: REST::ListSerializer, monsterfork_api: monsterfork_api end def destroy diff --git a/app/controllers/api/v1/media_controller.rb b/app/controllers/api/v1/media_controller.rb index aaa93b615..97b213cae 100644 --- a/app/controllers/api/v1/media_controller.rb +++ b/app/controllers/api/v1/media_controller.rb @@ -11,7 +11,7 @@ class Api::V1::MediaController < Api::BaseController def create @media = current_account.media_attachments.create!(media_params) - render json: @media, serializer: REST::MediaAttachmentSerializer + render json: @media, serializer: REST::MediaAttachmentSerializer, monsterfork_api: monsterfork_api rescue Paperclip::Errors::NotIdentifiedByImageMagickError render json: file_type_error, status: 422 rescue Paperclip::Error @@ -21,7 +21,7 @@ class Api::V1::MediaController < Api::BaseController def update @media = current_account.media_attachments.where(status_id: nil).find(params[:id]) @media.update!(media_params) - render json: @media, serializer: REST::MediaAttachmentSerializer + render json: @media, serializer: REST::MediaAttachmentSerializer, monsterfork_api: monsterfork_api end private diff --git a/app/controllers/api/v1/mutes_controller.rb b/app/controllers/api/v1/mutes_controller.rb index 3b3a39943..fd40e54e8 100644 --- a/app/controllers/api/v1/mutes_controller.rb +++ b/app/controllers/api/v1/mutes_controller.rb @@ -9,13 +9,13 @@ class Api::V1::MutesController < Api::BaseController def index @data = @accounts = load_accounts - render json: @accounts, each_serializer: REST::AccountSerializer + render json: @accounts, each_serializer: REST::AccountSerializer, monsterfork_api: monsterfork_api end def details @data = @mutes = load_mutes - render json: @mutes, each_serializer: REST::MuteSerializer - end + render json: @mutes, each_serializer: REST::MuteSerializer, monsterfork_api: monsterfork_api + end private diff --git a/app/controllers/api/v1/notifications_controller.rb b/app/controllers/api/v1/notifications_controller.rb index c91753ae7..5b90bef5c 100644 --- a/app/controllers/api/v1/notifications_controller.rb +++ b/app/controllers/api/v1/notifications_controller.rb @@ -12,12 +12,12 @@ class Api::V1::NotificationsController < Api::BaseController def index @notifications = load_notifications - render json: @notifications, each_serializer: REST::NotificationSerializer, relationships: StatusRelationshipsPresenter.new(target_statuses_from_notifications, current_user&.account_id) + render json: @notifications, each_serializer: REST::NotificationSerializer, relationships: StatusRelationshipsPresenter.new(target_statuses_from_notifications, current_user&.account_id), monsterfork_api: monsterfork_api end def show @notification = current_account.notifications.find(params[:id]) - render json: @notification, serializer: REST::NotificationSerializer + render json: @notification, serializer: REST::NotificationSerializer, monsterfork_api: monsterfork_api end def clear diff --git a/app/controllers/api/v1/polls/votes_controller.rb b/app/controllers/api/v1/polls/votes_controller.rb index 3fa0b6a76..186194ba0 100644 --- a/app/controllers/api/v1/polls/votes_controller.rb +++ b/app/controllers/api/v1/polls/votes_controller.rb @@ -11,7 +11,7 @@ class Api::V1::Polls::VotesController < Api::BaseController def create VoteService.new.call(current_account, @poll, vote_params[:choices]) - render json: @poll, serializer: REST::PollSerializer + render json: @poll, serializer: REST::PollSerializer, monsterfork_api: monsterfork_api end private diff --git a/app/controllers/api/v1/polls_controller.rb b/app/controllers/api/v1/polls_controller.rb index 031e6d42d..d545ea1b3 100644 --- a/app/controllers/api/v1/polls_controller.rb +++ b/app/controllers/api/v1/polls_controller.rb @@ -10,7 +10,7 @@ class Api::V1::PollsController < Api::BaseController respond_to :json def show - render json: @poll, serializer: REST::PollSerializer, include_results: true + render json: @poll, serializer: REST::PollSerializer, include_results: true, monsterfork_api: monsterfork_api end private diff --git a/app/controllers/api/v1/preferences_controller.rb b/app/controllers/api/v1/preferences_controller.rb index 077d39f5d..68db91463 100644 --- a/app/controllers/api/v1/preferences_controller.rb +++ b/app/controllers/api/v1/preferences_controller.rb @@ -7,6 +7,6 @@ class Api::V1::PreferencesController < Api::BaseController respond_to :json def index - render json: current_account, serializer: REST::PreferencesSerializer + render json: current_account, serializer: REST::PreferencesSerializer, monsterfork_api: monsterfork_api end end diff --git a/app/controllers/api/v1/push/subscriptions_controller.rb b/app/controllers/api/v1/push/subscriptions_controller.rb index 1b658f870..f49611c0e 100644 --- a/app/controllers/api/v1/push/subscriptions_controller.rb +++ b/app/controllers/api/v1/push/subscriptions_controller.rb @@ -17,13 +17,13 @@ class Api::V1::Push::SubscriptionsController < Api::BaseController access_token_id: doorkeeper_token.id ) - render json: @web_subscription, serializer: REST::WebPushSubscriptionSerializer + render json: @web_subscription, serializer: REST::WebPushSubscriptionSerializer, monsterfork_api: monsterfork_api end def show raise ActiveRecord::RecordNotFound if @web_subscription.nil? - render json: @web_subscription, serializer: REST::WebPushSubscriptionSerializer + render json: @web_subscription, serializer: REST::WebPushSubscriptionSerializer, monsterfork_api: monsterfork_api end def update @@ -31,7 +31,7 @@ class Api::V1::Push::SubscriptionsController < Api::BaseController @web_subscription.update!(data: data_params) - render json: @web_subscription, serializer: REST::WebPushSubscriptionSerializer + render json: @web_subscription, serializer: REST::WebPushSubscriptionSerializer, monsterfork_api: monsterfork_api end def destroy diff --git a/app/controllers/api/v1/reports_controller.rb b/app/controllers/api/v1/reports_controller.rb index e182a9c6c..f266f5828 100644 --- a/app/controllers/api/v1/reports_controller.rb +++ b/app/controllers/api/v1/reports_controller.rb @@ -15,7 +15,7 @@ class Api::V1::ReportsController < Api::BaseController forward: report_params[:forward] ) - render json: @report, serializer: REST::ReportSerializer + render json: @report, serializer: REST::ReportSerializer, monsterfork_api: monsterfork_api end private diff --git a/app/controllers/api/v1/scheduled_statuses_controller.rb b/app/controllers/api/v1/scheduled_statuses_controller.rb index 9950296f3..bd3a5ff52 100644 --- a/app/controllers/api/v1/scheduled_statuses_controller.rb +++ b/app/controllers/api/v1/scheduled_statuses_controller.rb @@ -12,16 +12,16 @@ class Api::V1::ScheduledStatusesController < Api::BaseController after_action :insert_pagination_headers, only: :index def index - render json: @statuses, each_serializer: REST::ScheduledStatusSerializer + render json: @statuses, each_serializer: REST::ScheduledStatusSerializer, monsterfork_api: monsterfork_api end def show - render json: @status, serializer: REST::ScheduledStatusSerializer + render json: @status, serializer: REST::ScheduledStatusSerializer, monsterfork_api: monsterfork_api end def update @status.update!(scheduled_status_params) - render json: @status, serializer: REST::ScheduledStatusSerializer + render json: @status, serializer: REST::ScheduledStatusSerializer, monsterfork_api: monsterfork_api end def destroy diff --git a/app/controllers/api/v1/search_controller.rb b/app/controllers/api/v1/search_controller.rb index c62ca15c6..b42ed99dd 100644 --- a/app/controllers/api/v1/search_controller.rb +++ b/app/controllers/api/v1/search_controller.rb @@ -12,7 +12,7 @@ class Api::V1::SearchController < Api::BaseController def index @search = Search.new(search_results) - render json: @search, serializer: REST::SearchSerializer + render json: @search, serializer: REST::SearchSerializer, monsterfork_api: monsterfork_api end private diff --git a/app/controllers/api/v1/statuses/bookmarks_controller.rb b/app/controllers/api/v1/statuses/bookmarks_controller.rb index 51d133b22..d7adda285 100644 --- a/app/controllers/api/v1/statuses/bookmarks_controller.rb +++ b/app/controllers/api/v1/statuses/bookmarks_controller.rb @@ -10,7 +10,7 @@ class Api::V1::Statuses::BookmarksController < Api::BaseController def create @status = bookmarked_status - render json: @status, serializer: REST::StatusSerializer + render json: @status, serializer: REST::StatusSerializer, monsterfork_api: monsterfork_api end def destroy @@ -20,7 +20,7 @@ class Api::V1::Statuses::BookmarksController < Api::BaseController bookmark = Bookmark.find_by!(account: current_user.account, status: @status) bookmark.destroy! - render json: @status, serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new([@status], current_user&.account_id, bookmarks_map: @bookmarks_map) + render json: @status, serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new([@status], current_user&.account_id, bookmarks_map: @bookmarks_map), monsterfork_api: monsterfork_api end private diff --git a/app/controllers/api/v1/statuses/favourited_by_accounts_controller.rb b/app/controllers/api/v1/statuses/favourited_by_accounts_controller.rb index d9d4bf7f3..80621881a 100644 --- a/app/controllers/api/v1/statuses/favourited_by_accounts_controller.rb +++ b/app/controllers/api/v1/statuses/favourited_by_accounts_controller.rb @@ -11,7 +11,7 @@ class Api::V1::Statuses::FavouritedByAccountsController < Api::BaseController def index @accounts = load_accounts - render json: @accounts, each_serializer: REST::AccountSerializer + render json: @accounts, each_serializer: REST::AccountSerializer, monsterfork_api: monsterfork_api end private diff --git a/app/controllers/api/v1/statuses/favourites_controller.rb b/app/controllers/api/v1/statuses/favourites_controller.rb index cceee9060..8529bcd03 100644 --- a/app/controllers/api/v1/statuses/favourites_controller.rb +++ b/app/controllers/api/v1/statuses/favourites_controller.rb @@ -10,7 +10,7 @@ class Api::V1::Statuses::FavouritesController < Api::BaseController def create @status = favourited_status - render json: @status, serializer: REST::StatusSerializer + render json: @status, serializer: REST::StatusSerializer, monsterfork_api: monsterfork_api end def destroy @@ -19,7 +19,7 @@ class Api::V1::Statuses::FavouritesController < Api::BaseController UnfavouriteWorker.perform_async(current_user.account_id, @status.id) - render json: @status, serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new([@status], current_user&.account_id, favourites_map: @favourites_map) + render json: @status, serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new([@status], current_user&.account_id, favourites_map: @favourites_map), monsterfork_api: monsterfork_api end private diff --git a/app/controllers/api/v1/statuses/mutes_controller.rb b/app/controllers/api/v1/statuses/mutes_controller.rb index b02469b4f..bf024baf2 100644 --- a/app/controllers/api/v1/statuses/mutes_controller.rb +++ b/app/controllers/api/v1/statuses/mutes_controller.rb @@ -14,14 +14,14 @@ class Api::V1::Statuses::MutesController < Api::BaseController current_account.mute_conversation!(@conversation) @mutes_map = { @conversation.id => true } - render json: @status, serializer: REST::StatusSerializer + render json: @status, serializer: REST::StatusSerializer, monsterfork_api: monsterfork_api end def destroy current_account.unmute_conversation!(@conversation) @mutes_map = { @conversation.id => false } - render json: @status, serializer: REST::StatusSerializer + render json: @status, serializer: REST::StatusSerializer, monsterfork_api: monsterfork_api end private diff --git a/app/controllers/api/v1/statuses/pins_controller.rb b/app/controllers/api/v1/statuses/pins_controller.rb index 4118a8ce4..726d53a61 100644 --- a/app/controllers/api/v1/statuses/pins_controller.rb +++ b/app/controllers/api/v1/statuses/pins_controller.rb @@ -12,7 +12,7 @@ class Api::V1::Statuses::PinsController < Api::BaseController def create StatusPin.create!(account: current_account, status: @status) distribute_add_activity! - render json: @status, serializer: REST::StatusSerializer + render json: @status, serializer: REST::StatusSerializer, monsterfork_api: monsterfork_api end def destroy @@ -23,7 +23,7 @@ class Api::V1::Statuses::PinsController < Api::BaseController distribute_remove_activity! end - render json: @status, serializer: REST::StatusSerializer + render json: @status, serializer: REST::StatusSerializer, monsterfork_api: monsterfork_api end private diff --git a/app/controllers/api/v1/statuses/reblogged_by_accounts_controller.rb b/app/controllers/api/v1/statuses/reblogged_by_accounts_controller.rb index 15eb3a026..58faa05b1 100644 --- a/app/controllers/api/v1/statuses/reblogged_by_accounts_controller.rb +++ b/app/controllers/api/v1/statuses/reblogged_by_accounts_controller.rb @@ -11,7 +11,7 @@ class Api::V1::Statuses::RebloggedByAccountsController < Api::BaseController def index @accounts = load_accounts - render json: @accounts, each_serializer: REST::AccountSerializer + render json: @accounts, each_serializer: REST::AccountSerializer, monsterfork_api: monsterfork_api end private diff --git a/app/controllers/api/v1/statuses/reblogs_controller.rb b/app/controllers/api/v1/statuses/reblogs_controller.rb index ed4f55100..986ce120b 100644 --- a/app/controllers/api/v1/statuses/reblogs_controller.rb +++ b/app/controllers/api/v1/statuses/reblogs_controller.rb @@ -10,7 +10,7 @@ class Api::V1::Statuses::ReblogsController < Api::BaseController def create @status = ReblogService.new.call(current_user.account, status_for_reblog, reblog_params) - render json: @status, serializer: REST::StatusSerializer + render json: @status, serializer: REST::StatusSerializer, monsterfork_api: monsterfork_api end def destroy @@ -20,7 +20,7 @@ class Api::V1::Statuses::ReblogsController < Api::BaseController authorize status_for_destroy, :unreblog? RemovalWorker.perform_async(status_for_destroy.id) - render json: @status, serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new([@status], current_user&.account_id, reblogs_map: @reblogs_map) + render json: @status, serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new([@status], current_user&.account_id, reblogs_map: @reblogs_map), monsterfork_api: monsterfork_api end private diff --git a/app/controllers/api/v1/statuses_controller.rb b/app/controllers/api/v1/statuses_controller.rb index fa3483822..ca92cf882 100644 --- a/app/controllers/api/v1/statuses_controller.rb +++ b/app/controllers/api/v1/statuses_controller.rb @@ -18,7 +18,7 @@ class Api::V1::StatusesController < Api::BaseController def show @status = cache_collection([@status], Status).first - render json: @status, serializer: REST::StatusSerializer + render json: @status, serializer: REST::StatusSerializer, monsterfork_api: monsterfork_api end def context @@ -30,7 +30,7 @@ class Api::V1::StatusesController < Api::BaseController @context = Context.new(ancestors: loaded_ancestors, descendants: loaded_descendants) statuses = [@status] + @context.ancestors + @context.descendants - render json: @context, serializer: REST::ContextSerializer, relationships: StatusRelationshipsPresenter.new(statuses, current_user&.account_id) + render json: @context, serializer: REST::ContextSerializer, relationships: StatusRelationshipsPresenter.new(statuses, current_user&.account_id), monsterfork_api: monsterfork_api end def card @@ -39,7 +39,7 @@ class Api::V1::StatusesController < Api::BaseController if @card.nil? render_empty else - render json: @card, serializer: REST::PreviewCardSerializer + render json: @card, serializer: REST::PreviewCardSerializer, monsterfork_api: monsterfork_api end end @@ -62,7 +62,7 @@ class Api::V1::StatusesController < Api::BaseController if @status.nil? raise Mastodon::ValidationError, 'Bangtags processed successfully.' else - render json: @status, serializer: @status.is_a?(ScheduledStatus) ? REST::ScheduledStatusSerializer : REST::StatusSerializer + render json: @status, serializer: @status.is_a?(ScheduledStatus) ? REST::ScheduledStatusSerializer : REST::StatusSerializer, monsterfork_api: monsterfork_api end end @@ -72,7 +72,7 @@ class Api::V1::StatusesController < Api::BaseController RemovalWorker.perform_async(@status.id) - render json: @status, serializer: REST::StatusSerializer, source_requested: true + render json: @status, serializer: REST::StatusSerializer, source_requested: true, monsterfork_api: monsterfork_api end private diff --git a/app/controllers/api/v1/suggestions_controller.rb b/app/controllers/api/v1/suggestions_controller.rb index 9da2b60ae..a6151f796 100644 --- a/app/controllers/api/v1/suggestions_controller.rb +++ b/app/controllers/api/v1/suggestions_controller.rb @@ -10,7 +10,7 @@ class Api::V1::SuggestionsController < Api::BaseController respond_to :json def index - render json: @accounts, each_serializer: REST::AccountSerializer + render json: @accounts, each_serializer: REST::AccountSerializer, monsterfork_api: monsterfork_api end def destroy diff --git a/app/controllers/api/v1/timelines/direct_controller.rb b/app/controllers/api/v1/timelines/direct_controller.rb index d8a76d153..e6c2a1a1d 100644 --- a/app/controllers/api/v1/timelines/direct_controller.rb +++ b/app/controllers/api/v1/timelines/direct_controller.rb @@ -9,7 +9,7 @@ class Api::V1::Timelines::DirectController < Api::BaseController def show @statuses = load_statuses - render json: @statuses, each_serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new(@statuses, current_user&.account_id) + render json: @statuses, each_serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new(@statuses, current_user&.account_id), monsterfork_api: monsterfork_api end private diff --git a/app/controllers/api/v1/timelines/home_controller.rb b/app/controllers/api/v1/timelines/home_controller.rb index 589bc3486..81a42cb06 100644 --- a/app/controllers/api/v1/timelines/home_controller.rb +++ b/app/controllers/api/v1/timelines/home_controller.rb @@ -13,6 +13,7 @@ class Api::V1::Timelines::HomeController < Api::BaseController render json: @statuses, each_serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new(@statuses, current_user&.account_id), + monsterfork_api: monsterfork_api, status: regeneration_in_progress? ? 206 : 200 end diff --git a/app/controllers/api/v1/timelines/list_controller.rb b/app/controllers/api/v1/timelines/list_controller.rb index b52f53bf9..1c5030d0e 100644 --- a/app/controllers/api/v1/timelines/list_controller.rb +++ b/app/controllers/api/v1/timelines/list_controller.rb @@ -11,7 +11,8 @@ class Api::V1::Timelines::ListController < Api::BaseController def show render json: @statuses, each_serializer: REST::StatusSerializer, - relationships: StatusRelationshipsPresenter.new(@statuses, current_user.account_id) + relationships: StatusRelationshipsPresenter.new(@statuses, current_user.account_id), + monsterfork_api: monsterfork_api end private diff --git a/app/controllers/api/v1/timelines/public_controller.rb b/app/controllers/api/v1/timelines/public_controller.rb index 9fee4b362..b9a72b070 100644 --- a/app/controllers/api/v1/timelines/public_controller.rb +++ b/app/controllers/api/v1/timelines/public_controller.rb @@ -7,7 +7,7 @@ class Api::V1::Timelines::PublicController < Api::BaseController def show @statuses = load_statuses - render json: @statuses, each_serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new(@statuses, current_user&.account_id) + render json: @statuses, each_serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new(@statuses, current_user&.account_id), monsterfork_api: monsterfork_api end private diff --git a/app/controllers/api/v1/timelines/tag_controller.rb b/app/controllers/api/v1/timelines/tag_controller.rb index 7e60e422b..8bb44a43d 100644 --- a/app/controllers/api/v1/timelines/tag_controller.rb +++ b/app/controllers/api/v1/timelines/tag_controller.rb @@ -8,7 +8,7 @@ class Api::V1::Timelines::TagController < Api::BaseController def show @statuses = load_statuses - render json: @statuses, each_serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new(@statuses, current_user&.account_id) + render json: @statuses, each_serializer: REST::StatusSerializer, relationships: StatusRelationshipsPresenter.new(@statuses, current_user&.account_id), monsterfork_api: monsterfork_api end private diff --git a/app/controllers/api/v2/search_controller.rb b/app/controllers/api/v2/search_controller.rb index 9aa6edc69..815c04cef 100644 --- a/app/controllers/api/v2/search_controller.rb +++ b/app/controllers/api/v2/search_controller.rb @@ -3,6 +3,6 @@ class Api::V2::SearchController < Api::V1::SearchController def index @search = Search.new(search_results) - render json: @search, serializer: REST::V2::SearchSerializer + render json: @search, serializer: REST::V2::SearchSerializer, monsterfork_api: monsterfork_api end end diff --git a/app/controllers/api/web/embeds_controller.rb b/app/controllers/api/web/embeds_controller.rb index 6231733b7..3e7919184 100644 --- a/app/controllers/api/web/embeds_controller.rb +++ b/app/controllers/api/web/embeds_controller.rb @@ -7,7 +7,7 @@ class Api::Web::EmbedsController < Api::Web::BaseController def create status = StatusFinder.new(params[:url]).status - render json: status, serializer: OEmbedSerializer, width: 400 + render json: status, serializer: OEmbedSerializer, width: 400, monsterfork_api: monsterfork_api rescue ActiveRecord::RecordNotFound oembed = FetchOEmbedService.new.call(params[:url]) oembed[:html] = Formatter.instance.sanitize(oembed[:html], Sanitize::Config::MASTODON_OEMBED) if oembed[:html].present? diff --git a/app/controllers/api/web/push_subscriptions_controller.rb b/app/controllers/api/web/push_subscriptions_controller.rb index d8153e082..af3e09d24 100644 --- a/app/controllers/api/web/push_subscriptions_controller.rb +++ b/app/controllers/api/web/push_subscriptions_controller.rb @@ -39,7 +39,7 @@ class Api::Web::PushSubscriptionsController < Api::Web::BaseController active_session.update!(web_push_subscription: web_subscription) - render json: web_subscription, serializer: REST::WebPushSubscriptionSerializer + render json: web_subscription, serializer: REST::WebPushSubscriptionSerializer, monsterfork_api: monsterfork_api end def update @@ -48,7 +48,7 @@ class Api::Web::PushSubscriptionsController < Api::Web::BaseController web_subscription = ::Web::PushSubscription.find(params[:id]) web_subscription.update!(data: data_params) - render json: web_subscription, serializer: REST::WebPushSubscriptionSerializer + render json: web_subscription, serializer: REST::WebPushSubscriptionSerializer, monsterfork_api: monsterfork_api end private |