about summary refs log tree commit diff
path: root/app/services/pubsubhubbub/unsubscribe_service.rb
blob: a2fdc548a99f7fc10eecd83de70f20ef349f41ce (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# frozen_string_literal: true

class Pubsubhubbub::SubscribeService < BaseService
  def call(account, callback)
    return ['Invalid topic URL', 422] if account.nil?

    subscription = Subscription.where(account: account, callback_url: callback)

    unless subscription.nil?
      Pubsubhubbub::ConfirmationWorker.perform_async(subscription.id, 'unsubscribe')
    end

    ['', 202]
  end
end