diff options
author | Roger Braun <roger@rogerbraun.net> | 2017-04-29 19:47:56 +0200 |
---|---|---|
committer | Roger Braun <roger@rogerbraun.net> | 2017-04-29 19:47:56 +0200 |
commit | ba1ea770012893ea818f248e9a0a2ee3ab854676 (patch) | |
tree | 810b94c5d91ef5ec8ceeadecc3db485c9f5fe690 /lib | |
parent | 427bac0966c551eb16eaa6595d99fc5361a32ea9 (diff) | |
download | pleroma-ba1ea770012893ea818f248e9a0a2ee3ab854676.tar.gz |
Make key fetching use ostatus fetching.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/salmon/salmon.ex | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/lib/pleroma/web/salmon/salmon.ex b/lib/pleroma/web/salmon/salmon.ex index 99cca1f55..777898cfa 100644 --- a/lib/pleroma/web/salmon/salmon.ex +++ b/lib/pleroma/web/salmon/salmon.ex @@ -21,24 +21,16 @@ defmodule Pleroma.Web.Salmon do [data, type, encoding, alg, sig] end + # TODO rewrite in with-stile + # Make it fetch the key from the saved user if there is one def fetch_magic_key(salmon) do [data, _, _, _, _] = decode(salmon) doc = XML.parse_document(data) - {:xmlObj, :string, uri} = :xmerl_xpath.string('string(//author[1]/uri)', doc) + uri = XML.string_from_xpath("/entry/author[1]/uri", doc) - uri = to_string(uri) - base = URI.parse(uri).host + {:ok, info} = Pleroma.Web.OStatus.gather_user_info(uri) - # TODO: Find out if this endpoint is mandated by the standard. - # At least diaspora does it differently - {:ok, response} = HTTPoison.get(base <> "/.well-known/webfinger", ["Accept": "application/xrd+xml"], [params: [resource: uri]]) - - doc = XML.parse_document(response.body) - - {:xmlObj, :string, magickey} = :xmerl_xpath.string('string(//Link[@rel="magic-public-key"]/@href)', doc) - "data:application/magic-public-key," <> magickey = to_string(magickey) - - magickey + info.magic_key end def decode_and_validate(magickey, salmon) do |