Enum.each(subscriptions, fn(sub) ->
response = FeedRepresenter.to_simple_form(user, [activity], [user])
|> :xmerl.export_simple(:xmerl_xml)
+ |> to_string
signature = sign(sub.secret, response)
HTTPoison.post(sub.callback, response, [
end
def sign(secret, doc) do
- :crypto.hmac(:sha, secret, doc) |> Base.encode16
+ :crypto.hmac(:sha, secret, to_string(doc)) |> Base.encode16
end
def incoming_subscription_request(user, %{"hub.mode" => "subscribe"} = params) do
{:ok, websub}
else {:error, reason} ->
+ Logger.debug("Couldn't create subscription.")
+ Logger.debug(inspect(reason))
+
{:error, reason}
end
end
Repo.get_by(WebsubServerSubscription, topic: topic, callback: callback) || %WebsubServerSubscription{}
end
+ # Temp hack for mastodon.
+ defp lease_time(%{"hub.lease_seconds" => ""}) do
+ {:ok, 60 * 60 * 24 * 3} # three days
+ end
+
defp lease_time(%{"hub.lease_seconds" => lease_seconds}) do
{:ok, String.to_integer(lease_seconds)}
end
defp valid_topic(%{"hub.topic" => topic}, user) do
if topic == OStatus.feed_path(user) do
- {:ok, topic}
+ {:ok, OStatus.feed_path(user)}
else
{:error, "Wrong topic requested, expected #{OStatus.feed_path(user)}, got #{topic}"}
end