From 35350d1ceb43e3e3ec578f748640770a14d74070 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonne=20Ha=C3=9F?= Date: Thu, 31 Jan 2013 15:58:23 +0100 Subject: [PATCH] Include reshares in the public user feed, closes #1781 --- Changelog.md | 1 + app/controllers/users_controller.rb | 2 +- app/views/users/public.atom.builder | 1 + spec/controllers/users_controller_spec.rb | 6 ++++++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index c343a24b0..73cf907cc 100644 --- a/Changelog.md +++ b/Changelog.md @@ -3,6 +3,7 @@ ## Features * Deleting a post that was shared to Facebook now deletes it from Facebook too [#3980]( https://github.com/diaspora/diaspora/pull/3980) +* Include reshares in a users public atom feed [#1781](https://github.com/diaspora/diaspora/issues/1781) ## Bug Fixes diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index f980f2424..2b66ec775 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -103,7 +103,7 @@ class UsersController < ApplicationController if @user = User.find_by_username(params[:username]) respond_to do |format| format.atom do - @posts = StatusMessage.where(:author_id => @user.person_id, :public => true).order('created_at DESC').limit(25) + @posts = Post.where(:author_id => @user.person_id, :public => true).order('created_at DESC').limit(25) end format.any { redirect_to person_path(@user.person) } diff --git a/app/views/users/public.atom.builder b/app/views/users/public.atom.builder index 3c5fb21a7..c540c9186 100644 --- a/app/views/users/public.atom.builder +++ b/app/views/users/public.atom.builder @@ -28,6 +28,7 @@ atom_feed({'xmlns:thr' => 'http://purl.org/syndication/thread/1.0', @posts.each do |post| + post = post.absolute_root if post.is_a? Reshare feed.entry post, :url => "#{@user.url}p/#{post.id}", :id => "#{@user.url}p/#{post.id}" do |entry| diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 537e7390f..b72088692 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -54,6 +54,12 @@ describe UsersController do response.body.should include('a href') end + it 'includes reshares in the atom feed' do + reshare = FactoryGirl.create(:reshare, :author => @user.person) + get :public, :username => @user.username, :format => :atom + response.body.should include reshare.root.raw_message + end + it 'redirects to a profile page if html is requested' do get :public, :username => @user.username response.should be_redirect