summaryrefslogtreecommitdiff
path: root/send.rb
diff options
context:
space:
mode:
Diffstat (limited to 'send.rb')
-rw-r--r--send.rb33
1 files changed, 15 insertions, 18 deletions
diff --git a/send.rb b/send.rb
index 91d3e9b..6dd4f3b 100644
--- a/send.rb
+++ b/send.rb
@@ -1,13 +1,11 @@
-post '/' do # TODO
+post '/outbox' do # TODO
protected!
- recipients = public
+ recipients = params[:public] == 'true' ? public : []
recipients << params[:to]
- # content = []
tag = []
params[:content].lines.each do |line|
- # line.chomp!
tags = line.split(/\s+/).grep(/^#\w+$/)
tags.each do |name|
tag_url = File.join(TAGS[:url], name.sub('#', ''))
@@ -27,7 +25,6 @@ post '/' do # TODO
'name' => mention
}
end
- # content << line
end
attachment = []
@@ -36,31 +33,33 @@ post '/' do # TODO
audio: %w[flac wav mp3 ogg],
video: %w[mp4 webm]
}
- params[:media].each do |_media|
- ext = File.extname(line).sub('.', '')
- media_type = extensions.select { |_k, v| v.include? ext }.keys[0].to_s + '/' + ext
- attachment << {
- 'type' => 'Document',
- 'mediaType' => media_type,
- 'url' => line
- }
+ if params[:media]
+ params[:media].each do |_media|
+ ext = File.extname(line).sub('.', '')
+ media_type = extensions.select { |_k, v| v.include? ext }.keys[0].to_s + '/' + ext
+ attachment << {
+ 'type' => 'Document',
+ 'mediaType' => media_type,
+ 'url' => line
+ }
+ end
end
object = {
'type' => 'Note',
'attributedTo' => ACTOR,
'inReplyTo' => params[:inReplyTo],
- 'content' => "<p>\n#{content.join("\n<br>")}\n</p>",
+ 'content' => "<p>\n#{params[:content]}\n</p>",
'attachment' => attachment,
'tag' => tag,
'to' => recipients
}
- activity = outbox 'Create', object, recipients, true
+ activity = outbox 'Create', object, recipients
activity['object']['tag'].each do |tag|
next unless tag['type'] == 'Hashtag'
- tag_path = File.join(TAGS_DIR, tag['name'].sub('#', '')) + '.json'
+ tag_path = File.join(TAGS[:dir], tag['name'].sub('#', '')) + '.json'
next if File.exist? tag_path
File.open(tag_path, 'w+') do |f|
@@ -73,7 +72,5 @@ post '/' do # TODO
}
f.puts tag_collection.to_json
end
- # update_collection tag_path, activity['object']['id']
end
- redirect(params['anchor'] || '/inbox')
end