diff options
author | Benjamin Neff <benjamin@coding4coffee.ch> | 2022-10-08 00:39:44 +0300 |
---|---|---|
committer | Benjamin Neff <benjamin@coding4coffee.ch> | 2022-10-30 01:32:31 +0300 |
commit | cbbb0a55c2b6a75206d26e541183cdbfffa2c23d (patch) | |
tree | 6e38224c113eb506ac03a37e1a226d8626de165d /app | |
parent | 03796e8fe2421ddfbc5380b8194ee68afbe3b88b (diff) |
Add redirect to mobile-only photo URL when in desktop UI
This URL is only used in the mobile UI, but when somebody then copies
the link and sends it to somebody on the desktop UI, they don't see
anything. So lets just redirect to the post containing the photo, so
there is at least something to show.
If there is no linked post, just redirect to the image instead.
Fixes #8352
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/photos_controller.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index c9447b495..e7a827de4 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -13,9 +13,17 @@ class PhotosController < ApplicationController current_user.photos_from(Person.find_by(guid: params[:person_id])).where(id: params[:id]).first else Photo.where(id: params[:id], public: true).first - end + end 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 def index |