diff options
Diffstat (limited to 'client.rb')
-rw-r--r-- | client.rb | 33 |
1 files changed, 14 insertions, 19 deletions
@@ -55,13 +55,6 @@ post '/' do redirect(params['anchor'] || '/inbox') end -post '/share' do - protected! - selection(params).each { |f| FileUtils.mv f, f.sub(%r{/inbox/}, '/shared/') } - outbox 'Announce', params['id'], public - redirect(params['anchor'] || '/inbox') -end - post '/delete' do protected! collection = Kernel.const_get(params['dir'].upcase) @@ -83,14 +76,21 @@ end post '/unfollow' do protected! actor, mention = parse_follow params['follow'] - outbox 'Undo', JSON.parse(File.read(following_path)), [actor] - p actor - following_path = File.join(FOLLOWING_DIR, "#{mention}.json") - if File.exist?(following_path) - outbox 'Undo', JSON.parse(File.read(following_path)), [actor] - FileUtils.rm_f following_path - redirect(params['anchor'] || '/inbox') + Dir[File.join(OUTBOX_DIR, 'follow', '*.json')].each do |f| + activity = JSON.parse(File.read(f)) + if activity['object'] == actor + outbox 'Undo', activity, [actor] + update_collection FOLLOWING, actor, true + end end + redirect(params['anchor'] || '/inbox') +end + +post '/share' do + protected! + selection(params).each { |f| FileUtils.mv f, f.sub(%r{/inbox/}, '/shared/') } + outbox 'Announce', params['id'], public + redirect(params['anchor'] || '/inbox') end post '/login' do @@ -107,10 +107,7 @@ end get path, provides: 'html' do protected! @dir = path.sub('/', '') - # p(Kernel.const_get(@dir.upcase)) - # p(File.read(Kernel.const_get(@dir.upcase))) collection = JSON.parse(File.read(Kernel.const_get(@dir.upcase)))['orderedItems'].uniq - # collection = ordered_collection(File.join(SOCIAL_DIR, path, 'note'))['orderedItems'] @threads = [] collection.each do |object| object['indent'] = 0 @@ -123,8 +120,6 @@ end object['indent'] = o['indent'] + 2 o['replies'] << object - # else - # p o end end end |