summaryrefslogtreecommitdiff
path: root/client.rb
diff options
context:
space:
mode:
authorpdp8 <pdp8@pdp8.info>2023-07-01 01:54:02 +0200
committerpdp8 <pdp8@pdp8.info>2023-07-01 01:54:02 +0200
commit086709cae3da7a01a011fe906004c8685fdd2ed0 (patch)
tree0872f3a6cfc303cdc61b883baae47af24960603d /client.rb
parent5af8d78e195c7479769240b32703d5b76843db4d (diff)
direct collection access from client
Diffstat (limited to 'client.rb')
-rw-r--r--client.rb37
1 files changed, 15 insertions, 22 deletions
diff --git a/client.rb b/client.rb
index b62f139..3016d02 100644
--- a/client.rb
+++ b/client.rb
@@ -134,8 +134,21 @@ end
['/inbox', '/archive', '/outbox'].each do |path|
get path, provides: 'html' do
protected!
- @items = fetch(File.join(SOCIAL_URL, path))['orderedItems']
- threads
+ @dir = path.sub('/', '')
+ collection = ordered_collection(File.join(SOCIAL_DIR, path, 'note'))['orderedItems']
+ @threads = []
+ collection.each do |object|
+ object['indent'] = 0
+ object['replies'] = []
+ if object['inReplyTo'].nil? || collection.select { |o| o['id'] == object['inReplyTo'] }.empty?
+ @threads << object
+ else
+ collection.select { |o| o['id'] == object['inReplyTo'] }.each do |o|
+ object['indent'] = o['indent'] + 4
+ o['replies'] << object
+ end
+ end
+ end
erb :collection
end
end
@@ -145,26 +158,6 @@ helpers do
halt 403 unless session['client']
end
- def outbox(activity)
- curl("-X POST -d #{activity.to_json}", File.join(SOCIAL_URL, 'outbox'))
- end
-
- def threads
- @threads = []
- @items.each do |i|
- i['indent'] = 0
- i['replies'] = []
- if i['inReplyTo'].nil? || @items.select { |it| it['id'] == i['inReplyTo'] }.empty?
- @threads << i
- else
- @items.select { |it| it['id'] == i['inReplyTo'] }.each do |it|
- i['indent'] = it['indent'] + 4
- it['replies'] << i
- end
- end
- end
- end
-
def parse_follow(follow)
case follow
when /^#/