about summary refs log tree commit diff
path: root/app/services/pubsubhubbub/unsubscribe_service.rb
blob: 7adadf8ed286816eab512b3975e4f1f1119b28f6 (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.find_by(account: account, callback_url: callback)

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

    ['', 202]
  end
end