source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/settings/advanced_controller.rb | Ruby | mit | 8,966 | main | 3,149 | # frozen_string_literal: true
class Settings::AdvancedController < Settings::BaseController
before_action :authorize
def show
render inertia: "Settings/Advanced/Show", props: settings_presenter.advanced_props
end
def update
begin
BlockedCustomerObject.transaction do
block_customer_email... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/settings/team_controller.rb | Ruby | mit | 8,966 | main | 786 | # frozen_string_literal: true
class Settings::TeamController < Settings::BaseController
before_action :authorize
before_action :check_email_presence
def show
set_meta_tag(title: "Team")
team_presenter = Settings::TeamPresenter.new(pundit_user:)
render inertia: "Settings/Team/Show", props: {
m... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/settings/base_controller.rb | Ruby | mit | 8,966 | main | 379 | # frozen_string_literal: true
class Settings::BaseController < Sellers::BaseController
layout "inertia"
inertia_share do
{
settings_pages: -> { settings_presenter.pages }
}
end
before_action do
set_meta_tag(title: "Settings")
end
protected
def settings_presenter
@settings_pre... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/settings/totp_controller.rb | Ruby | mit | 8,966 | main | 2,316 | # frozen_string_literal: true
class Settings::TotpController < Settings::BaseController
before_action :set_user
before_action :authorize
def create
if @user.totp_enabled?
return render json: { success: false, error_message: "Authenticator app is already enabled." }, status: :unprocessable_entity
e... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/settings/authorized_applications_controller.rb | Ruby | mit | 8,966 | main | 318 | # frozen_string_literal: true
class Settings::AuthorizedApplicationsController < Settings::BaseController
def index
authorize([:settings, :authorized_applications, OauthApplication])
render inertia: "Settings/AuthorizedApplications/Index", props: settings_presenter.authorized_applications_props
end
end |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/settings/third_party_analytics_controller.rb | Ruby | mit | 8,966 | main | 1,760 | # frozen_string_literal: true
class Settings::ThirdPartyAnalyticsController < Settings::BaseController
before_action :authorize
def show
render inertia: "Settings/ThirdPartyAnalytics/Show", props: {
third_party_analytics: settings_presenter.third_party_analytics_props,
products: current_seller.lin... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/settings/payments_controller.rb | Ruby | mit | 8,966 | main | 10,534 | # frozen_string_literal: true
class Settings::PaymentsController < Settings::BaseController
include ActionView::Helpers::SanitizeHelper
before_action :authorize
def show
render inertia: "Settings/Payments/Show", props: settings_presenter.payments_props(remote_ip: request.remote_ip)
end
def update
... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/settings/profile_controller.rb | Ruby | mit | 8,966 | main | 2,753 | # frozen_string_literal: true
class Settings::ProfileController < Settings::BaseController
before_action :authorize
def show
profile_presenter = ProfilePresenter.new(pundit_user:, seller: current_seller)
render inertia: "Settings/Profile/Show", props: settings_presenter.profile_props.merge(
profile... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/settings/team/invitations_controller.rb | Ruby | mit | 8,966 | main | 4,436 | # frozen_string_literal: true
class Settings::Team::InvitationsController < Sellers::BaseController
before_action :set_team_invitation, only: %i[update destroy restore resend_invitation]
def create
authorize [:settings, :team, TeamInvitation]
team_invitation = current_seller.team_invitations.new(create_p... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/settings/team/members_controller.rb | Ruby | mit | 8,966 | main | 1,231 | # frozen_string_literal: true
class Settings::Team::MembersController < Sellers::BaseController
before_action :set_team_membership, only: %i[update destroy restore]
def index
authorize [:settings, :team, current_seller], :show?
@team_presenter = Settings::TeamPresenter.new(pundit_user:)
render json: ... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/settings/profile/products_controller.rb | Ruby | mit | 8,966 | main | 397 | # frozen_string_literal: true
class Settings::Profile::ProductsController < Settings::BaseController
def show
product = current_seller.products.find_by_external_id!(params[:id])
authorize product
# Avoid passing the pundit_user so that the product renders as non-editable
render json: ProductPresente... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/oauth/authorized_applications_controller.rb | Ruby | mit | 8,966 | main | 641 | # frozen_string_literal: true
class Oauth::AuthorizedApplicationsController < Doorkeeper::AuthorizedApplicationsController
def index
redirect_to settings_authorized_applications_path
end
def destroy
application = OauthApplication.authorized_for(current_resource_owner).find_by_external_id(params[:id])
... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/oauth/applications_controller.rb | Ruby | mit | 8,966 | main | 3,713 | # frozen_string_literal: true
class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
protect_from_forgery
include CsrfTokenInjector
include Impersonate
before_action :authenticate_user!
before_action :set_application_params, only: %i[create update]
before_action :set_application, only: ... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/oauth/authorizations_controller.rb | Ruby | mit | 8,966 | main | 500 | # frozen_string_literal: true
class Oauth::AuthorizationsController < Doorkeeper::AuthorizationsController
before_action :hide_layouts
before_action :default_to_authorization_code
before_action :hide_from_search_results
private
def hide_layouts
@hide_layouts = true
end
def hide_from_search_... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/oauth/mobile_pre_authorizations_controller.rb | Ruby | mit | 8,966 | main | 668 | # frozen_string_literal: true
class Oauth::MobilePreAuthorizationsController < ApplicationController
before_action :hide_layouts
def new
cookies[:is_gumroad_mobile_app] = {
value: "1",
expires: 5.minutes.from_now,
secure: true,
same_site: :none,
}
@oauth_authorize_url = "/oaut... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/oauth/tokens_controller.rb | Ruby | mit | 8,966 | main | 285 | # frozen_string_literal: true
class Oauth::TokensController < Doorkeeper::TokensController
include LogrageHelper
private
def strategy
# default to authorization code
params[:grant_type] = "authorization_code" if params[:grant_type].blank?
super
end
end |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/oauth/access_tokens_controller.rb | Ruby | mit | 8,966 | main | 668 | # frozen_string_literal: true
class Oauth::AccessTokensController < Sellers::BaseController
before_action :set_application
def create
authorize [:settings, :authorized_applications, @application]
access_token = @application.get_or_generate_access_token
render json: { success: true, token: access_toke... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/oauth/notion/authorizations_controller.rb | Ruby | mit | 8,966 | main | 472 | # frozen_string_literal: true
class Oauth::Notion::AuthorizationsController < Oauth::AuthorizationsController
before_action :retrieve_notion_bot_token, only: [:new]
private
def retrieve_notion_bot_token
if params[:code].present?
response = NotionApi.new.get_bot_token(code: params[:code], user: c... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/help_center/base_controller.rb | Ruby | mit | 8,966 | main | 808 | # frozen_string_literal: true
class HelpCenter::BaseController < ApplicationController
include HelperWidget
layout "inertia"
rescue_from ActiveHash::RecordNotFound, with: :redirect_to_help_center_root
before_action do
set_meta_tag(property: "og:type", value: "website")
set_meta_tag(name: "twitter:ca... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/help_center/articles_controller.rb | Ruby | mit | 8,966 | main | 1,993 | # frozen_string_literal: true
class HelpCenter::ArticlesController < HelpCenter::BaseController
before_action :redirect_legacy_articles, only: :show
def index
title = "Gumroad Help Center"
description = "Common questions and support documentation"
canonical_url = help_center_root_url
set_meta_tag... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/help_center/categories_controller.rb | Ruby | mit | 8,966 | main | 477 | # frozen_string_literal: true
class HelpCenter::CategoriesController < HelpCenter::BaseController
def show
category = HelpCenter::Category.find_by!(slug: params[:slug])
set_meta_tag(title: "#{category.title} - Gumroad Help Center")
set_meta_tag(tag_name: "link", rel: "canonical", href: help_center_categ... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/payouts/exports_controller.rb | Ruby | mit | 8,966 | main | 717 | # frozen_string_literal: true
class Payouts::ExportsController < Sellers::BaseController
include PayoutsHelper
skip_before_action :check_suspended
before_action :load_payout_ids
def create
authorize :balance, :export?
ExportPayoutData.perform_async(@payout_ids, impersonating_user&.id || logged_in_us... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/payouts/exportables_controller.rb | Ruby | mit | 8,966 | main | 1,181 | # frozen_string_literal: true
class Payouts::ExportablesController < Sellers::BaseController
include PayoutsHelper
before_action :load_years_with_payouts
def index
authorize :balance, :export?
selected_year = params[:year]&.to_i
selected_year = @years_with_payouts.include?(selected_year) ? select... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/internal/product_posts_controller.rb | Ruby | mit | 8,966 | main | 476 | # frozen_string_literal: true
class Api::Internal::ProductPostsController < Api::Internal::BaseController
include FetchProductByUniquePermalink
before_action :authenticate_user!
before_action :fetch_product_by_unique_permalink, only: :index
def index
e404 if @product.user != current_seller
render js... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/internal/home_page_numbers_controller.rb | Ruby | mit | 8,966 | main | 472 | # frozen_string_literal: true
class Api::Internal::HomePageNumbersController < Api::Internal::BaseController
include ActionView::Helpers::NumberHelper
def index
home_page_numbers = Rails.cache.fetch("homepage_numbers", expires_in: 1.day) do
prev_week_payout_usd = $redis.get(RedisKey.prev_week_payout_usd... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/internal/receipt_previews_controller.rb | Ruby | mit | 8,966 | main | 2,169 | # frozen_string_literal: true
class Api::Internal::ReceiptPreviewsController < Api::Internal::BaseController
include FetchProductByUniquePermalink
before_action :authenticate_user!
before_action :fetch_product_by_unique_permalink
def show
e404 if @product.nil? || @product.user != current_seller
@pro... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/internal/ai_product_details_generations_controller.rb | Ruby | mit | 8,966 | main | 2,095 | # frozen_string_literal: true
class Api::Internal::AiProductDetailsGenerationsController < Api::Internal::BaseController
include Throttling
before_action :authenticate_user!
before_action :throttle_ai_requests
after_action :verify_authorized
AI_REQUESTS_PER_PERIOD = 10
AI_REQUESTS_PERIOD_WINDOW = 1.hour
... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/internal/product_public_files_controller.rb | Ruby | mit | 8,966 | main | 865 | # frozen_string_literal: true
class Api::Internal::ProductPublicFilesController < Api::Internal::BaseController
include FetchProductByUniquePermalink
before_action :authenticate_user!
before_action :fetch_product_and_enforce_ownership, only: :create
after_action :verify_authorized
def create
authorize ... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/internal/mobile_minimum_versions_controller.rb | Ruby | mit | 8,966 | main | 625 | # frozen_string_literal: true
class Api::Internal::MobileMinimumVersionsController < Api::Internal::BaseController
before_action -> { doorkeeper_authorize! :account }
def show
# Values for these keys can be set in Rails console to force all mobile app users to upgrade to a specific version.
# It's very ja... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/internal/existing_product_files_controller.rb | Ruby | mit | 8,966 | main | 431 | # frozen_string_literal: true
class Api::Internal::ExistingProductFilesController < Api::Internal::BaseController
include FetchProductByUniquePermalink
before_action :authenticate_user!
before_action :fetch_product_by_unique_permalink, only: :index
def index
e404 if @product.user != current_seller
r... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/internal/grmc/webhook_controller.rb | Ruby | mit | 8,966 | main | 900 | # frozen_string_literal: true
class Api::Internal::Grmc::WebhookController < Api::Internal::BaseController
skip_before_action :verify_authenticity_token
before_action :authorize_hmac_signature!
def handle
HandleGrmcCallbackJob.perform_async(JSON.parse(request.body.read))
head :ok
end
private
de... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/internal/helper/payouts_controller.rb | Ruby | mit | 8,966 | main | 3,789 | # frozen_string_literal: true
class Api::Internal::Helper::PayoutsController < Api::Internal::Helper::BaseController
before_action :fetch_user
def index
payouts = @user.payments.order(created_at: :desc).limit(5).map do |payment|
{
external_id: payment.external_id,
amount_cents: payment.... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/internal/helper/purchases_controller.rb | Ruby | mit | 8,966 | main | 7,597 | # frozen_string_literal: true
class Api::Internal::Helper::PurchasesController < Api::Internal::Helper::BaseController
before_action :fetch_last_purchase, only: [:refund_last_purchase, :resend_last_receipt]
def refund_last_purchase
if @purchase.present? && @purchase.refund_and_save!(GUMROAD_ADMIN_ID)
re... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/internal/helper/webhook_controller.rb | Ruby | mit | 8,966 | main | 739 | # frozen_string_literal: true
class Api::Internal::Helper::WebhookController < Api::Internal::Helper::BaseController
skip_before_action :authorize_helper_token!
before_action :authorize_hmac_signature!
before_action :require_params!
def handle
event = params[:event]
payload = params[:payload]
Rai... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/internal/helper/base_controller.rb | Ruby | mit | 8,966 | main | 1,671 | # frozen_string_literal: true
class Api::Internal::Helper::BaseController < Api::Internal::BaseController
skip_before_action :verify_authenticity_token
before_action :verify_authorization_header!
before_action :authorize_helper_token!
HMAC_EXPIRATION = 1.minute
private
def authorize_hmac_signature!
... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/internal/helper/users_controller.rb | Ruby | mit | 8,966 | main | 7,151 | # frozen_string_literal: true
class Api::Internal::Helper::UsersController < Api::Internal::Helper::BaseController
skip_before_action :authorize_helper_token!, only: [:user_info]
before_action :authorize_hmac_signature!, only: [:user_info]
def user_info
render json: { success: false, error: "'email' paramet... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/internal/helper/instant_payouts_controller.rb | Ruby | mit | 8,966 | main | 965 | # frozen_string_literal: true
class Api::Internal::Helper::InstantPayoutsController < Api::Internal::Helper::BaseController
include CurrencyHelper
before_action :fetch_user
def index
balance_cents = @user.instantly_payable_unpaid_balance_cents
render json: {
success: true,
balance: formatt... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/internal/product_review_videos/approvals_controller.rb | Ruby | mit | 8,966 | main | 533 | # frozen_string_literal: true
class Api::Internal::ProductReviewVideos::ApprovalsController < Api::Internal::BaseController
before_action :authenticate_user!
before_action :set_product_review_video!
after_action :verify_authorized
def create
authorize @product_review_video, :approve?
@product_review... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/internal/product_review_videos/rejections_controller.rb | Ruby | mit | 8,966 | main | 533 | # frozen_string_literal: true
class Api::Internal::ProductReviewVideos::RejectionsController < Api::Internal::BaseController
before_action :authenticate_user!
before_action :set_product_review_video!
after_action :verify_authorized
def create
authorize @product_review_video, :reject?
@product_review... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/internal/installments/audience_counts_controller.rb | Ruby | mit | 8,966 | main | 481 | # frozen_string_literal: true
class Api::Internal::Installments::AudienceCountsController < Api::Internal::BaseController
before_action :authenticate_user!
after_action :verify_authorized
def show
installment = current_seller.installments.alive.find_by_external_id(params[:id])
return (skip_authorization... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/internal/installments/recipient_counts_controller.rb | Ruby | mit | 8,966 | main | 844 | # frozen_string_literal: true
class Api::Internal::Installments::RecipientCountsController < Api::Internal::BaseController
before_action :authenticate_user!
after_action :verify_authorized
def show
authorize Installment, :updated_recipient_count?
permitted_params = params.permit(
:paid_more_than_... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/internal/installments/preview_emails_controller.rb | Ruby | mit | 8,966 | main | 581 | # frozen_string_literal: true
class Api::Internal::Installments::PreviewEmailsController < Api::Internal::BaseController
before_action :authenticate_user!
after_action :verify_authorized
def create
installment = current_seller.installments.alive.find_by_external_id(params[:id])
return e404_json unless i... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/internal/admin/users_controller.rb | Ruby | mit | 8,966 | main | 1,020 | # frozen_string_literal: true
class Api::Internal::Admin::UsersController < Api::Internal::Admin::BaseController
def suspension
return render json: { success: false, message: "email is required" }, status: :bad_request if params[:email].blank?
user = User.alive.by_email(params[:email]).first
return rend... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/internal/admin/licenses_controller.rb | Ruby | mit | 8,966 | main | 1,131 | # frozen_string_literal: true
class Api::Internal::Admin::LicensesController < Api::Internal::Admin::BaseController
def lookup
return render json: { success: false, message: "license_key is required" }, status: :bad_request if params[:license_key].blank?
license = License.find_by(serial: params[:license_key... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/internal/admin/purchases_controller.rb | Ruby | mit | 8,966 | main | 535 | # frozen_string_literal: true
class Api::Internal::Admin::PurchasesController < Api::Internal::Admin::BaseController
def show
return render json: { success: false, message: "Purchase not found" }, status: :not_found unless params[:id].to_s.match?(/\A\d+\z/)
purchase = Purchase.find_by_external_id_numeric(pa... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/internal/admin/base_controller.rb | Ruby | mit | 8,966 | main | 2,384 | # frozen_string_literal: true
class Api::Internal::Admin::BaseController < Api::Internal::BaseController
skip_before_action :verify_authenticity_token
before_action :verify_authorization_header!
before_action :authorize_admin_token!
private
def authorize_admin_token!
token = request.authorization.sp... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/internal/admin/payouts_controller.rb | Ruby | mit | 8,966 | main | 900 | # frozen_string_literal: true
class Api::Internal::Admin::PayoutsController < Api::Internal::Admin::BaseController
before_action :fetch_user
def list
payouts = @user.payments.order(created_at: :desc).limit(5).map { serialize_payout(_1) }
payout_note = @user.comments.with_type_payout_note.where(author_id: ... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/mobile/purchases_controller.rb | Ruby | mit | 8,966 | main | 4,082 | # frozen_string_literal: true
class Api::Mobile::PurchasesController < Api::Mobile::BaseController
before_action { doorkeeper_authorize! :mobile_api }
before_action :fetch_purchase, only: [:purchase_attributes, :archive, :unarchive, :destroy]
DEFAULT_SEARCH_RESULTS_SIZE = 10
DEFAULT_PER_PAGE = 100
MAX_PER_PA... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/mobile/media_locations_controller.rb | Ruby | mit | 8,966 | main | 273 | # frozen_string_literal: true
class Api::Mobile::MediaLocationsController < Api::Mobile::BaseController
include RecordMediaLocation
before_action { doorkeeper_authorize! :mobile_api }
def create
render json: { success: record_media_location(params) }
end
end |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/mobile/analytics_controller.rb | Ruby | mit | 8,966 | main | 2,560 | # frozen_string_literal: true
class Api::Mobile::AnalyticsController < Api::Mobile::BaseController
before_action -> { doorkeeper_authorize! :creator_api }
before_action :set_date_range, only: [:by_date, :by_state, :by_referral]
rescue_from Faraday::TimeoutError do
render json: { success: false, message: "An... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/mobile/preorders_controller.rb | Ruby | mit | 8,966 | main | 510 | # frozen_string_literal: true
class Api::Mobile::PreordersController < Api::Mobile::BaseController
before_action :fetch_preorder_by_external_id, only: :preorder_attributes
def preorder_attributes
render json: { success: true, product: @preorder.mobile_json_data }
end
private
def fetch_preorder_by_ext... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/mobile/url_redirects_controller.rb | Ruby | mit | 8,966 | main | 3,330 | # frozen_string_literal: true
class Api::Mobile::UrlRedirectsController < Api::Mobile::BaseController
before_action :fetch_url_redirect_by_external_id, only: :url_redirect_attributes
before_action :fetch_url_redirect_by_token, only: %i[stream hls_playlist download]
before_action :mark_rental_as_viewed, only: :hl... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/mobile/sessions_controller.rb | Ruby | mit | 8,966 | main | 363 | # frozen_string_literal: true
class Api::Mobile::SessionsController < Api::Mobile::BaseController
before_action { doorkeeper_authorize! :mobile_api }
skip_before_action :verify_authenticity_token, only: :create
def create
sign_in current_resource_owner
render json: { success: true, user: { email: curre... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/mobile/feature_flags_controller.rb | Ruby | mit | 8,966 | main | 271 | # frozen_string_literal: true
class Api::Mobile::FeatureFlagsController < Api::Mobile::BaseController
before_action { doorkeeper_authorize! :mobile_api }
def show
render json: { enabled_for_user: Feature.active?(params[:id], current_resource_owner) }
end
end |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/mobile/consumption_analytics_controller.rb | Ruby | mit | 8,966 | main | 286 | # frozen_string_literal: true
class Api::Mobile::ConsumptionAnalyticsController < Api::Mobile::BaseController
include CreateConsumptionEvent
before_action { doorkeeper_authorize! :mobile_api }
def create
render json: { success: create_consumption_event!(params) }
end
end |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/mobile/devices_controller.rb | Ruby | mit | 8,966 | main | 641 | # frozen_string_literal: true
class Api::Mobile::DevicesController < Api::Mobile::BaseController
before_action { doorkeeper_authorize! :creator_api, :mobile_api }
def create
device = current_resource_owner.devices.build(device_params)
begin
saved = device.save
rescue ActiveRecord::RecordNotUniq... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/mobile/installments_controller.rb | Ruby | mit | 8,966 | main | 1,606 | # frozen_string_literal: true
class Api::Mobile::InstallmentsController < Api::Mobile::BaseController
before_action :fetch_installment, only: [:show]
before_action :fetch_context_object, only: [:show]
def show
render json: { success: true, installment: @installment.installment_mobile_json_data(purchase: @pu... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/mobile/base_controller.rb | Ruby | mit | 8,966 | main | 1,366 | # frozen_string_literal: true
class Api::Mobile::BaseController < ApplicationController
include Pagy::Backend
before_action :check_mobile_token
rescue_from Pagy::VariableError do |exception|
render status: :bad_request, json: { error: { message: exception.message } }
end
# Secret token that mobile use... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/mobile/sales_controller.rb | Ruby | mit | 8,966 | main | 717 | # frozen_string_literal: true
class Api::Mobile::SalesController < Api::Mobile::BaseController
include ProcessRefund
before_action { doorkeeper_authorize! :mobile_api }
before_action :fetch_purchase, only: [:show]
def show
render json: { success: true, purchase: @purchase.json_data_for_mobile({ include_sa... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/mobile/subscriptions_controller.rb | Ruby | mit | 8,966 | main | 322 | # frozen_string_literal: true
class Api::Mobile::SubscriptionsController < Api::Mobile::BaseController
before_action :fetch_subscription_by_external_id, only: :subscription_attributes
def subscription_attributes
render json: { success: true, subscription: @subscription.subscription_mobile_json_data }
end
en... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/v2/payouts_controller.rb | Ruby | mit | 8,966 | main | 3,329 | # frozen_string_literal: true
class Api::V2::PayoutsController < Api::V2::BaseController
include PayoutsHelper
before_action -> { doorkeeper_authorize!(:view_payouts) }
RESULTS_PER_PAGE = 10
def index
begin
end_date = Date.strptime(params[:before], "%Y-%m-%d") if params[:before]
rescue Argumen... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/v2/thumbnails_controller.rb | Ruby | mit | 8,966 | main | 1,300 | # frozen_string_literal: true
class Api::V2::ThumbnailsController < Api::V2::BaseController
before_action { doorkeeper_authorize! :edit_products }
before_action :fetch_product
def create
return render_response(false, message: "Please provide a signed_blob_id.") if params[:signed_blob_id].blank?
thumbna... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/v2/users_controller.rb | Ruby | mit | 8,966 | main | 1,224 | # frozen_string_literal: true
class Api::V2::UsersController < Api::V2::BaseController
before_action -> { doorkeeper_authorize!(*Doorkeeper.configuration.public_scopes.concat([:view_public])) }, only: [:show, :ifttt_sale_trigger]
def show
if params[:is_ifttt]
user = current_resource_owner
user.nam... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/v2/tax_forms_controller.rb | Ruby | mit | 8,966 | main | 2,191 | # frozen_string_literal: true
class Api::V2::TaxFormsController < Api::V2::BaseController
include Api::V2::TaxCenterAccess
def index
forms = current_resource_owner.user_tax_forms.order(:tax_year, :tax_form_type)
if params[:year].present?
year = parse_year_param
return render_year_not_availabl... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/v2/covers_controller.rb | Ruby | mit | 8,966 | main | 1,498 | # frozen_string_literal: true
class Api::V2::CoversController < Api::V2::BaseController
before_action { doorkeeper_authorize! :edit_products }
before_action :fetch_product
def create
asset_preview = @product.asset_previews.build
if params[:signed_blob_id].present?
asset_preview.file.attach(params... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/v2/earnings_controller.rb | Ruby | mit | 8,966 | main | 647 | # frozen_string_literal: true
class Api::V2::EarningsController < Api::V2::BaseController
include Api::V2::TaxCenterAccess
def show
year = parse_year_param
return render_year_not_available(year, "Earnings") unless valid_tax_year?(year)
presenter = TaxCenterPresenter.new(seller: current_resource_owner... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/v2/skus_controller.rb | Ruby | mit | 8,966 | main | 543 | # frozen_string_literal: true
class Api::V2::SkusController < Api::V2::BaseController
before_action -> { doorkeeper_authorize!(*Doorkeeper.configuration.public_scopes.concat([:view_public])) }
before_action :fetch_product
def index
skus = if @product.skus_enabled?
@product.skus.alive.not_is_default_sk... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/v2/sales_controller.rb | Ruby | mit | 8,966 | main | 6,593 | # frozen_string_literal: true
class Api::V2::SalesController < Api::V2::BaseController
include CurrencyHelper
before_action(only: [:index, :show]) { doorkeeper_authorize! :view_sales }
before_action(only: [:mark_as_shipped]) { doorkeeper_authorize! :mark_sales_as_shipped }
before_action(only: [:refund]) { door... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/v2/subscribers_controller.rb | Ruby | mit | 8,966 | main | 1,961 | # frozen_string_literal: true
class Api::V2::SubscribersController < Api::V2::BaseController
before_action -> { doorkeeper_authorize!(:view_sales) }
before_action :fetch_product, only: :index
RESULTS_PER_PAGE = 100
def index
subscriptions = Subscription.where(link_id: @product.id).active
subscription... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/v2/bundle_contents_controller.rb | Ruby | mit | 8,966 | main | 1,858 | # frozen_string_literal: true
class Api::V2::BundleContentsController < Api::V2::BaseController
MAX_INTEGER = 2_147_483_647
before_action { doorkeeper_authorize! :edit_products }
before_action :fetch_product
def update
return render_response(false, message: "This product is not a bundle.") if @product.no... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/v2/resource_subscriptions_controller.rb | Ruby | mit | 8,966 | main | 1,971 | # frozen_string_literal: true
class Api::V2::ResourceSubscriptionsController < Api::V2::BaseController
before_action(only: [:index, :create, :destroy]) { doorkeeper_authorize! :view_sales }
def index
resource_name = params[:resource_name]
if ResourceSubscription.valid_resource_name?(resource_name)
... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/v2/files_controller.rb | Ruby | mit | 8,966 | main | 3,178 | # frozen_string_literal: true
class Api::V2::FilesController < Api::V2::BaseController
before_action { doorkeeper_authorize! :edit_products }
PRESIGNED_URL_EXPIRY_SECONDS = 900
PART_SIZE = 100.megabytes
MAX_FILE_SIZE_GB = 20 # matching the web uploader limit
MAX_FILE_SIZE = MAX_FILE_SIZE_GB.gigabytes
def... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/v2/licenses_controller.rb | Ruby | mit | 8,966 | main | 5,222 | # frozen_string_literal: true
class Api::V2::LicensesController < Api::V2::BaseController
before_action :log_params, only: [:verify]
before_action :clean_params, only: [:verify]
before_action(only: [:enable, :disable, :decrement_uses_count, :rotate]) { doorkeeper_authorize! :edit_products }
before_action :fetc... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/v2/custom_fields_controller.rb | Ruby | mit | 8,966 | main | 2,268 | # frozen_string_literal: true
class Api::V2::CustomFieldsController < Api::V2::BaseController
before_action(only: [:index]) { doorkeeper_authorize!(*Doorkeeper.configuration.public_scopes.concat([:view_public])) }
before_action(only: [:create, :update, :destroy]) { doorkeeper_authorize! :edit_products }
before_a... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/v2/links_controller.rb | Ruby | mit | 8,966 | main | 32,054 | # frozen_string_literal: true
class Api::V2::LinksController < Api::V2::BaseController
BASE_PRODUCT_ASSOCIATIONS = [
:preorder_link, :tags, :taxonomy,
{ display_asset_previews: [:file_attachment, :file_blob] },
{ bundle_products: [:product, :variant] },
].freeze
INDEX_PRODUCT_ASSOCIATIONS = (BASE_PR... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/v2/base_controller.rb | Ruby | mit | 8,966 | main | 5,013 | # frozen_string_literal: true
class Api::V2::BaseController < ApplicationController
after_action :log_method_use
private
def doorkeeper_authorize!(*scopes)
super(*scopes, :account)
end
def fetch_product
products = current_resource_owner.links
@product = products.find_by_external_id(... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/v2/variants_controller.rb | Ruby | mit | 8,966 | main | 5,111 | # frozen_string_literal: true
class Api::V2::VariantsController < Api::V2::BaseController
before_action(only: [:index, :show]) { doorkeeper_authorize!(*Doorkeeper.configuration.public_scopes.concat([:view_public])) }
before_action(only: [:create, :update, :destroy]) { doorkeeper_authorize! :edit_products }
befor... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/v2/variant_categories_controller.rb | Ruby | mit | 8,966 | main | 1,648 | # frozen_string_literal: true
class Api::V2::VariantCategoriesController < Api::V2::BaseController
before_action(only: [:index, :show]) { doorkeeper_authorize!(*Doorkeeper.configuration.public_scopes.concat([:view_public])) }
before_action(only: [:create, :update, :destroy]) { doorkeeper_authorize! :edit_products ... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/v2/offer_codes_controller.rb | Ruby | mit | 8,966 | main | 2,734 | # frozen_string_literal: true
class Api::V2::OfferCodesController < Api::V2::BaseController
before_action(only: [:index, :show]) { doorkeeper_authorize!(*Doorkeeper.configuration.public_scopes.concat([:view_public])) }
before_action(only: [:create, :update, :destroy]) { doorkeeper_authorize! :edit_products }
bef... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/api/v2/notion_unfurl_urls_controller.rb | Ruby | mit | 8,966 | main | 4,237 | # frozen_string_literal: true
class Api::V2::NotionUnfurlUrlsController < Api::V2::BaseController
before_action(only: [:create]) { doorkeeper_authorize! :unfurl }
before_action :parse_uri, only: [:create]
before_action :fetch_product, only: [:create]
skip_before_action :verify_authenticity_token, only: [:creat... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/bundles/base_controller.rb | Ruby | mit | 8,966 | main | 519 | # frozen_string_literal: true
class Bundles::BaseController < Sellers::BaseController
include Product::BundlesMarketing
layout "inertia"
before_action :set_bundle
before_action :authorize_bundle
before_action :set_default_page_title
protected
def set_bundle
@bundle = Link.can_be_bundle.find_by... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/bundles/content_controller.rb | Ruby | mit | 8,966 | main | 2,691 | # frozen_string_literal: true
class Bundles::ContentController < Bundles::BaseController
def edit
props = BundlePresenter.new(bundle: @bundle).edit_content_props
props[:search_data] = InertiaRails.defer(merge: true) { search_results }
flash.now[:alert] = "Select products and save your changes to finish... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/bundles/share_controller.rb | Ruby | mit | 8,966 | main | 1,796 | # frozen_string_literal: true
class Bundles::ShareController < Bundles::BaseController
before_action :ensure_published
def edit
props = BundlePresenter.new(bundle: @bundle).edit_share_props
render inertia: "Bundles/Share/Edit", props:
end
def update
authorize @bundle
bundle = nil
Active... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | app/controllers/bundles/product_controller.rb | Ruby | mit | 8,966 | main | 4,223 | # frozen_string_literal: true
class Bundles::ProductController < Bundles::BaseController
def edit
props = BundlePresenter.new(bundle: @bundle).edit_product_props
flash.now[:alert] = "Select products and save your changes to finish converting this product to a bundle." unless @bundle.is_bundle?
render i... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/discover_taxonomy_constraint.rb | Ruby | mit | 8,966 | main | 485 | # frozen_string_literal: true
class DiscoverTaxonomyConstraint
def self.matches?(request)
valid_taxonomy_paths.include?(request.path)
end
def self.valid_taxonomy_paths
@valid_taxonomy_paths ||= Taxonomy.eager_load(:self_and_ancestors)
.order("taxonomy_hierarchies.ge... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/catch_bad_request_errors.rb | Ruby | mit | 8,966 | main | 393 | # frozen_string_literal: true
class CatchBadRequestErrors
def initialize(app)
@app = app
end
def call(env)
@app.call(env)
rescue ActionController::BadRequest
if env["HTTP_ACCEPT"].include?("application/json")
[400, { "Content-Type" => "application/json" }, [{ success: false }.to_json]]
e... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/user_custom_domain_constraint.rb | Ruby | mit | 8,966 | main | 307 | # frozen_string_literal: true
class UserCustomDomainConstraint
def self.matches?(request)
Subdomain.find_seller_by_request(request).present? ||
CustomDomain.find_by_host(request.host)&.user&.username.present? ||
SubdomainRedirectorService.new.redirect_url_for(request).present?
end
end |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/custom_rouge_theme.rb | Ruby | mit | 8,966 | main | 320 | # frozen_string_literal: true
# Overrides the 'bg0' pallete of Rouge's Gruvbox light theme
# https://github.com/rouge-ruby/rouge/blob/43d346cceb1123510de67ec58a2fa1e29d22cc7b/lib/rouge/themes/gruvbox.rb
class CustomRougeTheme < Rouge::Themes::Gruvbox
def self.make_light!
super
palette bg0: "#fff"
end
end |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/utilities/d3.rb | Ruby | mit | 8,966 | main | 1,458 | # frozen_string_literal: true
##
# A collection of D3 related helper methods.
##
class D3
class << self
def formatted_date(date, today_date: Date.today)
date == today_date ? "Today" : date.strftime("%b %e, %Y")
end
def formatted_date_with_timezone(time, timezone)
today_date = Time.current.i... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/utilities/log_redactor.rb | Ruby | mit | 8,966 | main | 608 | # frozen_string_literal: true
module LogRedactor
FILTERED = "[FILTERED]"
SENSITIVE_KEYS = %w[
token
stripe_publishable_key
authorization
paypal-auth-assertion
verify_sign
].freeze
module_function
def redact(value)
case value
when Hash
value.each_with_object({}) do |(k, v)... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/utilities/ffprobe.rb | Ruby | mit | 8,966 | main | 968 | # frozen_string_literal: true
class Ffprobe
attr_reader :path
def initialize(path)
@path = File.expand_path(path)
end
def parse
raise ArgumentError, "File not found #{path}" unless File.exist?(path)
OpenStruct.new(first_stream)
end
private
def calculate_framerate(r_frame_rate)
rfr... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/utilities/feature.rb | Ruby | mit | 8,966 | main | 804 | # frozen_string_literal: true
module Feature
extend self
def activate(feature_name)
Flipper.enable(feature_name)
end
def activate_user(feature_name, user)
Flipper.enable_actor(feature_name, user)
end
def deactivate(feature_name)
Flipper.disable(feature_name)
end
def deactivate_user(feat... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/utilities/xml_helpers.rb | Ruby | mit | 8,966 | main | 635 | # frozen_string_literal: true
# Public: Helper functions for working with the built in REXML parser.
module XmlHelpers
# Public: Gets the text contained within the element at the given
# xpath, and given a root element. The root element may be any
# XML element and does not need to be the root of the document as... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/utilities/geo_ip.rb | Ruby | mit | 8,966 | main | 1,312 | # frozen_string_literal: true
module GeoIp
class Result
attr_reader :country_name, :country_code, :region_name, :city_name, :postal_code, :latitude, :longitude
def initialize(country_name:, country_code:, region_name:, city_name:, postal_code:, latitude:, longitude:)
@country_name = country_name
... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/utilities/o_embed_finder.rb | Ruby | mit | 8,966 | main | 2,026 | # frozen_string_literal: true
class OEmbedFinder
SOUNDCLOUD_PARAMS = %w[auto_play show_artwork show_comments buying sharing download show_playcount show_user liking].freeze
# limited oembed urls for mobile (we don't know if mobile can support other urls)
MOBILE_URL_REGEXES = [%r{player.vimeo.com/video/\d+}, %r{... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/utilities/with_max_execution_time.rb | Ruby | mit | 8,966 | main | 990 | # frozen_string_literal: true
module WithMaxExecutionTime
# NOTE: Rails >= 6.0.0.rc1 supports Optimizer hints. Consider using them instead if available.
class QueryTimeoutError < Timeout::Error; end
def self.timeout_queries(seconds:)
connection = ActiveRecord::Base.connection
previous_max_execution_tim... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/utilities/card_type.rb | Ruby | mit | 8,966 | main | 257 | # frozen_string_literal: true
class CardType
UNKNOWN = "generic_card"
VISA = "visa"
AMERICAN_EXPRESS = "amex"
MASTERCARD = "mastercard"
DISCOVER = "discover"
JCB = "jcb"
DINERS_CLUB = "diners"
PAYPAL = "paypal"
UNION_PAY = "unionpay"
end |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/utilities/csv_safe.rb | Ruby | mit | 8,966 | main | 1,246 | # frozen_string_literal: true
require "csv"
# Custom CSV sanitization to prevent formula injection
# Based on csv-safe gem but modified to preserve numeric strings with + or -
# Original: https://github.com/zvory/csv-safe/blob/master/lib/csv-safe.rb
class CsvSafe < CSV
FORMULA_PREFIXES = ["=", "@", "|", "%", "\r", ... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/utilities/dev_tools.rb | Ruby | mit | 8,966 | main | 5,674 | # frozen_string_literal: true
class DevTools
class << self
# Useful in admin for the same reasons as `delete_all_indices_and_reindex_all`, but when you
# don't want to index *everything* because you're connected to a copy of the production DB,
# which has too many records for that to be practical.
de... |
github | antiwork/gumroad | https://github.com/antiwork/gumroad | lib/utilities/us_zip_codes.rb | Ruby | mit | 8,966 | main | 893 | # frozen_string_literal: true
module UsZipCodes
# Given a zip code in the United States, identifies the state code.
# 5-digit zip codes are supported.
# Zip+4 is also supported, but only the first 5 digits are used to determine the state.
# Accepts surrounding whitespace. Accepts a single whitespace or hyphen ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.