|
|
@ -19,31 +19,18 @@ class Pubsubhubbub::SubscribeService < BaseService |
|
|
|
private |
|
|
|
private |
|
|
|
|
|
|
|
|
|
|
|
def process_subscribe |
|
|
|
def process_subscribe |
|
|
|
case subscribe_status |
|
|
|
if account.nil? |
|
|
|
when :invalid_topic |
|
|
|
|
|
|
|
['Invalid topic URL', 422] |
|
|
|
['Invalid topic URL', 422] |
|
|
|
when :invalid_callback |
|
|
|
elsif !valid_callback? |
|
|
|
['Invalid callback URL', 422] |
|
|
|
['Invalid callback URL', 422] |
|
|
|
when :callback_not_allowed |
|
|
|
elsif blocked_domain? |
|
|
|
['Callback URL not allowed', 403] |
|
|
|
['Callback URL not allowed', 403] |
|
|
|
when :valid |
|
|
|
else |
|
|
|
confirm_subscription |
|
|
|
confirm_subscription |
|
|
|
['', 202] |
|
|
|
['', 202] |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def subscribe_status |
|
|
|
|
|
|
|
if account.nil? |
|
|
|
|
|
|
|
:invalid_topic |
|
|
|
|
|
|
|
elsif !valid_callback? |
|
|
|
|
|
|
|
:invalid_callback |
|
|
|
|
|
|
|
elsif blocked_domain? |
|
|
|
|
|
|
|
:callback_not_allowed |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
:valid |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def confirm_subscription |
|
|
|
def confirm_subscription |
|
|
|
subscription = locate_subscription |
|
|
|
subscription = locate_subscription |
|
|
|
Pubsubhubbub::ConfirmationWorker.perform_async(subscription.id, 'subscribe', secret, lease_seconds) |
|
|
|
Pubsubhubbub::ConfirmationWorker.perform_async(subscription.id, 'subscribe', secret, lease_seconds) |
|
|
|