Merge pull request #8400 from SuperTux88/8352-mobile-photo-url-redirect
Add redirect to mobile-only photo URL when in desktop UI
This commit is contained in:
commit
f6105e54a9
3 changed files with 23 additions and 1 deletions
|
|
@ -52,6 +52,7 @@ We use yarn to install the frontend dependencies now, so you need to have that i
|
||||||
* Photo-upload file picker now correctly restricts possible file types [#8205](https://github.com/diaspora/diaspora/pull/8205)
|
* Photo-upload file picker now correctly restricts possible file types [#8205](https://github.com/diaspora/diaspora/pull/8205)
|
||||||
* Make inline code inside links show the link color [#8387](https://github.com/diaspora/diaspora/pull/8387)
|
* Make inline code inside links show the link color [#8387](https://github.com/diaspora/diaspora/pull/8387)
|
||||||
* Fix fetching public posts on first account search was missing some data [#8390](https://github.com/diaspora/diaspora/pull/8390)
|
* Fix fetching public posts on first account search was missing some data [#8390](https://github.com/diaspora/diaspora/pull/8390)
|
||||||
|
* Add redirect from mobile UI photo URLs to post when not using mobile UI [#8400](https://github.com/diaspora/diaspora/pull/8400)
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
* Add client-side cropping of profile image uploads [#7581](https://github.com/diaspora/diaspora/pull/7581)
|
* Add client-side cropping of profile image uploads [#7581](https://github.com/diaspora/diaspora/pull/7581)
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,17 @@ class PhotosController < ApplicationController
|
||||||
current_user.photos_from(Person.find_by(guid: params[:person_id])).where(id: params[:id]).first
|
current_user.photos_from(Person.find_by(guid: params[:person_id])).where(id: params[:id]).first
|
||||||
else
|
else
|
||||||
Photo.where(id: params[:id], public: true).first
|
Photo.where(id: params[:id], public: true).first
|
||||||
end
|
end
|
||||||
|
|
||||||
raise ActiveRecord::RecordNotFound unless @photo
|
raise ActiveRecord::RecordNotFound unless @photo
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html {
|
||||||
|
post = @photo.status_message
|
||||||
|
redirect_to post ? post_path(post) : @photo.url
|
||||||
|
}
|
||||||
|
format.mobile { render "photos/show" }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
|
||||||
|
|
@ -230,6 +230,19 @@ describe PhotosController, :type => :controller do
|
||||||
expect(response).to be_successful
|
expect(response).to be_successful
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should redirect to the post of the photo when not on mobile" do
|
||||||
|
alices_post = alice.post(:status_message, text: "Post with photo", to: alice.aspects.first.id, public: false)
|
||||||
|
@alices_photo.update(status_message: alices_post)
|
||||||
|
|
||||||
|
get :show, params: {person_id: alice.person.guid, id: @alices_photo.id}
|
||||||
|
expect(response).to redirect_to(post_path(alices_post))
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should redirect to the photo file when not on mobile and no post exists" do
|
||||||
|
get :show, params: {person_id: alice.person.guid, id: @alices_photo.id}
|
||||||
|
expect(response).to redirect_to(@alices_photo.url)
|
||||||
|
end
|
||||||
|
|
||||||
it "doesn't leak private photos to the public" do
|
it "doesn't leak private photos to the public" do
|
||||||
sign_out :user
|
sign_out :user
|
||||||
expect {
|
expect {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue