fix oembed spec; prevent people from commenting on posts that wont federate

This commit is contained in:
Maxwell Salzberg 2011-10-26 17:32:02 -07:00
parent 03380516f1
commit 9789e25c99
4 changed files with 23 additions and 2 deletions

View file

@ -19,8 +19,10 @@ class PostsController < ApplicationController
if user_signed_in?
@post = current_user.find_visible_shareable_by_id(Post, params[:id], :key => key)
@commenting_disabled = user_can_not_comment_on_post?
else
@post = Post.where(key => params[:id], :public => true).includes(:author, :comments => :author).first
@commenting_disabled = true
end
if @post
@ -65,4 +67,18 @@ class PostsController < ApplicationController
def set_format_if_malformed_from_status_net
request.format = :html if request.format == 'application/html+xml'
end
private
def user_can_not_comment_on_post?
if @post.public && @post.author.local?
false
elsif current_user.contact_for(@post.author)
false
elsif current_user.owns?(@post)
false
else
true
end
end
end

View file

@ -70,7 +70,10 @@
&ndash;
- unless commenting_disabled?(post)
- if commenting_disabled?(post)
%span.federated_person{:title => "#{t('.federated_account')}"}
=t('.currently_unavailable')
- else
%span.like_action
= like_action(post, current_user)

View file

@ -776,6 +776,8 @@ en:
all_contacts: "All contacts"
stream_element:
viewable_to_anyone: "This post is viewable to anyone on the web"
federated_account: "Remote users who you are not connected to can not currently receive your likes and comments"
currently_unavailable: 'currently unavailable'
via: "via %{link}"
hide_and_mute: "Hide and Mute"
like: "Like"

View file

@ -109,7 +109,7 @@ describe OEmbedHelper do
real_data = data['oembed_data']
cache = OEmbedCache.new(:url => data['link_url'])
cache.data = real_data
formatted = o_embed_html(cache)
formatted = o_embed_html(cache).gsub('https', 'http')
case type
when 'photo'
formatted.should =~ /#{data['oembed_data']['url']}/