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

class Pubsubhubbub::UnsubscribeService < 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