post '/' do # TODO protected! recipients = 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('#', '')) tag << { 'type' => 'Hashtag', 'href' => tag_url, 'name' => name } end mentions = line.split(/\s+/).grep(/^@\w+@\S+$/) mentions.each do |mention| actor = actor(mention) tag << { 'type' => 'Mention', 'href' => actor, 'name' => mention } end # content << line end attachment = [] extensions = { image: %w[jpeg png], 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 } end object = { 'type' => 'Note', 'attributedTo' => ACTOR, 'inReplyTo' => params[:inReplyTo], 'content' => "
\n#{content.join("\n
")}\n