distributed-press-api-client 0.4.0 → 0.4.1
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a5f4b33d4222028ca00dfe7e4a3f9e0fd5a4e4c620068e8ae094df84e4d4a2c
|
4
|
+
data.tar.gz: ba21a56decb67357d65243ea5f7a12f92e705f689a2501fe3419921d6ffeea0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a8f016d1fba233cf4e106b6f114fa82b34949af8b88cde9c252d4c33bb440c30c233eadee120205d4ff9c019327f44d9f9e4971abc8733c4e2c5856ec2a5986
|
7
|
+
data.tar.gz: 43019f74c34831fa3a9164db342e971307ab8c76e225445a7a95cf82f025e2496af8cfa0c1264fcd620ad2126f1066093280bbcfa5d113705c658247583c7aec
|
@@ -86,12 +86,12 @@ class DistributedPress
|
|
86
86
|
|
87
87
|
def _dump(_)
|
88
88
|
Marshal.dump({
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
89
|
+
public_key_url: public_key_url,
|
90
|
+
url: url,
|
91
|
+
private_key_pem: @private_key_pem,
|
92
|
+
key_size: key_size,
|
93
|
+
cache_store: self.class.cache_store
|
94
|
+
})
|
95
95
|
end
|
96
96
|
|
97
97
|
def self._load(hash)
|
@@ -211,6 +211,14 @@ class DistributedPress
|
|
211
211
|
end.perform do |fragment|
|
212
212
|
fragment_to_body!(fragment, response_body)
|
213
213
|
end.tap do |response|
|
214
|
+
# Brotli decompression is delayed until after full download
|
215
|
+
if response.headers['content-encoding'] == 'br'
|
216
|
+
''.dup.tap do |inflated_response_body|
|
217
|
+
inflate_body!(response_body, inflated_response_body)
|
218
|
+
response_body = inflated_response_body
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
214
222
|
next if response_body.empty?
|
215
223
|
|
216
224
|
fix_response!(response, response_body)
|
@@ -275,16 +283,19 @@ class DistributedPress
|
|
275
283
|
# tests, 2GB of zeroes were compressed to a 1.6KB fragment.
|
276
284
|
#
|
277
285
|
# @todo Maybe each_char is too slow?
|
278
|
-
# @param
|
286
|
+
# @param body [String]
|
279
287
|
# @param append_to [String]
|
280
|
-
def
|
281
|
-
|
288
|
+
def inflate_body!(body, append_to)
|
289
|
+
body_io = StringIO.new(body)
|
282
290
|
|
283
|
-
BRS::Stream::Reader.new(
|
284
|
-
|
291
|
+
BRS::Stream::Reader.new(body_io, source_buffer_length: 256,
|
292
|
+
destination_buffer_length: 1024).each_char do |char|
|
285
293
|
append_to << char
|
286
294
|
|
287
|
-
|
295
|
+
if append_to.bytesize > 1_000_000
|
296
|
+
raise ContentTooLargeError,
|
297
|
+
"Content too large after inflating, stopped at #{append_to.bytesize} bytes!"
|
298
|
+
end
|
288
299
|
end
|
289
300
|
end
|
290
301
|
|
@@ -294,22 +305,16 @@ class DistributedPress
|
|
294
305
|
# @param :fragment [HTTParty::ResponseFragment]
|
295
306
|
# @param :append_to [String]
|
296
307
|
def fragment_to_body!(fragment, append_to)
|
297
|
-
|
298
|
-
|
299
|
-
# Raise an error rather than returning an empty body
|
300
|
-
unless brotli?
|
301
|
-
raise BrotliUnsupportedError,
|
302
|
-
'Server sent brotli-encoded response but ruby-brs gem is missing'
|
303
|
-
end
|
304
|
-
|
305
|
-
inflate_fragment!(fragment, append_to)
|
306
|
-
else
|
307
|
-
append_to << fragment
|
308
|
+
if fragment.http_response['content-encoding'] == 'br' && !brotli?
|
309
|
+
raise BrotliUnsupportedError, 'Server sent brotli-encoded response but ruby-brs gem is missing'
|
308
310
|
end
|
309
311
|
|
310
|
-
|
311
|
-
|
312
|
-
|
312
|
+
append_to << fragment
|
313
|
+
|
314
|
+
return unless append_to.bytesize > 1_000_000
|
315
|
+
|
316
|
+
raise ContentTooLargeError,
|
317
|
+
"Content too large, stopped at #{append_to.bytesize} bytes!"
|
313
318
|
end
|
314
319
|
|
315
320
|
# Re-adds a streamed body to the response and caches it again so
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'uri'
|
4
|
+
require_relative 'client'
|
5
|
+
|
6
|
+
class DistributedPress
|
7
|
+
module V1
|
8
|
+
module Social
|
9
|
+
# Manages the actor's followers on the Social Inbox
|
10
|
+
class Followers
|
11
|
+
# @return [DistributedPress::V1::Social::Client]
|
12
|
+
attr_reader :client
|
13
|
+
|
14
|
+
# @return [String]
|
15
|
+
attr_reader :actor
|
16
|
+
|
17
|
+
# @param :client [DistributedPress::V1::Social::Client]
|
18
|
+
# @param :actor [String]
|
19
|
+
def initialize(client:, actor:)
|
20
|
+
@client = client
|
21
|
+
@actor = actor
|
22
|
+
end
|
23
|
+
|
24
|
+
# Get the actor's inbox
|
25
|
+
#
|
26
|
+
# @return [HTTParty::Response]
|
27
|
+
def get
|
28
|
+
client.get(endpoint: endpoint)
|
29
|
+
end
|
30
|
+
|
31
|
+
#
|
32
|
+
#
|
33
|
+
# @param :id [String] Activity ID
|
34
|
+
# @return [HTTParty::Response]
|
35
|
+
def remove(id:)
|
36
|
+
client.delete(endpoint: "#{endpoint}/#{URI.encode_uri_component(id)}")
|
37
|
+
end
|
38
|
+
|
39
|
+
# Followers
|
40
|
+
#
|
41
|
+
# @return [String]
|
42
|
+
def endpoint
|
43
|
+
@endpoint ||= "/v1/#{actor}/followers"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: distributed-press-api-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- f
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-03-
|
11
|
+
date: 2024-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -311,6 +311,7 @@ files:
|
|
311
311
|
- lib/distributed_press/v1/social/blocklist.rb
|
312
312
|
- lib/distributed_press/v1/social/client.rb
|
313
313
|
- lib/distributed_press/v1/social/dereferencer.rb
|
314
|
+
- lib/distributed_press/v1/social/followers.rb
|
314
315
|
- lib/distributed_press/v1/social/hook.rb
|
315
316
|
- lib/distributed_press/v1/social/inbox.rb
|
316
317
|
- lib/distributed_press/v1/social/outbox.rb
|