distributed-press-api-client 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26a1b1d09a0b95c8852f253a6d4bf5c5a8f506c0e8176f65bbbffe1ef8f06aff
|
4
|
+
data.tar.gz: a06560b95f7e1969c52e653fb563569bb17b811e91995766a36f3f8de85b640d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bce9df9c4cd0eb80868af163c63a9234006d5c779b91e768bd4726aebd0978fb44a240b9c7806912ea480f338a47ead8d433b3c7b956662eb0cb2b9527c93f57
|
7
|
+
data.tar.gz: 28be64d94b3add7ac1333f85ff2f00a4e55b9568783de437172264c619227d75e28801082a0600186480935e2dda9605411e68dc8d53cc10280ceed1893fe411
|
@@ -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
|
@@ -24,11 +24,13 @@ class DistributedPress
|
|
24
24
|
# Creates a Social Inbox by uploading the keypair to it.
|
25
25
|
#
|
26
26
|
# @param actor_url [String] The URL where the Actor profile is hosted
|
27
|
+
# @param announce [Boolean] Automatically announce new accounts
|
27
28
|
# @return [HTTParty::Response]
|
28
|
-
def create(actor_url)
|
29
|
+
def create(actor_url, announce = false)
|
29
30
|
inbox_body = {
|
30
31
|
'actorUrl' => actor_url,
|
31
32
|
'publicKeyId' => "#{actor_url}#main-key",
|
33
|
+
'announce' => announce,
|
32
34
|
'keypair' => {
|
33
35
|
'publicKeyPem' => client.public_key.public_to_pem,
|
34
36
|
'privateKeyPem' => client.private_key.export
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- f
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-04-05 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
|