superfeedr_engine 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6c41a146f01127073bc4fb5b8a3761abcb57fd4e
4
- data.tar.gz: 40cb80b21ebb748b7f5cbfa2494d1f8dd784c3b4
3
+ metadata.gz: bee7e6e4273eb2466ef9a69825b211bc2617811d
4
+ data.tar.gz: c4419381bc2e2fd73d54b3ebb6b963d2f698b47a
5
5
  SHA512:
6
- metadata.gz: fe8a90c441db5ff74d41adfb62aa3863ea683b58ae2f99f26c76bbcf42b7bf87cfc165a9246b979a6a1ec3407d929bb075d1d98a431906208ed80d9ba972bd56
7
- data.tar.gz: c542e203a3136570559ace72c24e9892e3c176edb3fcc8911b71a354bf37c94ded604b4b07e3bff6906a3f86d1b174e1f97feba25c9522935305cccab5f77037
6
+ metadata.gz: 7f7ae5a487f7f240957dfd37c26da685a713d8a9e0c75b4a11f726e0bcfae7f3d4d083a60d850d2e68bd65c394f0b02dcfa3011c4dca7a47c68c590cb1d1ac61
7
+ data.tar.gz: 4345fcaa94300d9f5fdfc719e796a986c8eecc53561b9865021e6225eb12359680e66aa956b5e69bd2cd03914970be7442e4ecb5d2e372e3288f19af361c9817
@@ -4,37 +4,45 @@ require_dependency "superfeedr_engine/application_controller"
4
4
  module SuperfeedrEngine
5
5
  class PubsubhubbubController < ApplicationController
6
6
 
7
- def notify
8
- signature = request.headers['HTTP_X_HUB_SIGNATURE']
9
- if !signature
10
- Rails.logger.error("Missing signature. Ignored payload for #{params[:feed_id]}. Use retrieve if missing.")
11
- else
12
- algo, hash = signature.split('=')
13
- if algo != "sha1"
14
- Rails.logger.error("Unknown signature mechanism #{algo}. Ignored paylod for #{params[:feed_id]}. Use retrieve if missing.")
15
- else
16
- feed = feed_klass.find(params[:feed_id])
17
- if !feed
18
- Rails.logger.error("Unknown notification for #{params[:feed_id]}.")
19
- else
7
+ def notify
8
+ signature = request.headers['HTTP_X_HUB_SIGNATURE']
9
+ if !signature
10
+ Rails.logger.error("Missing signature. Ignored payload for #{params[:feed_id]}. Use retrieve if missing.")
11
+ else
12
+ algo, hash = signature.split('=')
13
+ if algo != "sha1"
14
+ Rails.logger.error("Unknown signature mechanism #{algo}. Ignored paylod for #{params[:feed_id]}. Use retrieve if missing.")
15
+ else
16
+ feed = feed_klass.find(params[:feed_id])
17
+ if !feed
18
+ Rails.logger.error("Unknown notification for #{params[:feed_id]}.")
19
+ else
20
20
  digest = OpenSSL::Digest.new(algo)
21
21
  computed = OpenSSL::HMAC.hexdigest(digest, feed.secret, request.raw_post)
22
- if computed == hash
23
- feed.notified(params)
24
- else
25
- Rails.logger.error("Non matching signature. Ignored paylod for #{params[:feed_id]}. Use retrieve if missing.")
26
- end
27
- end
28
- end
22
+ if computed == hash
23
+ params.delete("pubsubhubbub")
24
+ params.delete("feed_id")
25
+ if !feed_klass.method_defined?(:notified)
26
+ Rails.logger.error("Please make sure your #{feed_klass} intances have a 'notified' method.")
27
+ elsif feed.method(:notified).arity == 2
28
+ feed.notified(params, request.raw_post)
29
+ elsif feed.method(:notified).arity == 1
30
+ feed.notified(params)
31
+ end
32
+ else
33
+ Rails.logger.error("Non matching signature. Ignored paylod for #{params[:feed_id]}. Use retrieve if missing.")
34
+ end
35
+ end
36
+ end
29
37
  end
30
38
  render :text => "Thanks"
31
- end
39
+ end
32
40
 
33
- protected
41
+ protected
34
42
 
35
- def feed_klass
36
- SuperfeedrEngine::Engine.feed_class.constantize
37
- end
43
+ def feed_klass
44
+ SuperfeedrEngine::Engine.feed_class.constantize
45
+ end
38
46
 
39
47
  end
40
48
  end
@@ -1,3 +1,3 @@
1
1
  module SuperfeedrEngine
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: superfeedr_engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - superfeedr
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-24 00:00:00.000000000 Z
11
+ date: 2015-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails