Files
ignacionelson 6e47d76ba6 ProjectSend 2.0.0
Client file sharing, rebuilt from the ground up: a private area per
client, resumable uploads, folders, groups and categories, sharing with
expiry dates and download limits, comments, file versions, an activity
log, a REST API, and sixteen languages.

This repository begins here. ProjectSend 2 was developed privately, and
that development history is not published — the previous generation
remains available, with its own history, at projectsend/legacy.

Free software under the GNU General Public License v2, or (at your
option) any later version.
2026-08-14 01:38:12 -03:00

48 lines
1.8 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Modules\Comments\Http\Controllers;
use App\Http\Controllers\Controller;
use App\Modules\Files\Models\File;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Gate;
/**
* Where a comment notification lands.
*
* A notification type has one url closure for every recipient, but a
* comment's recipients are staff and clients at once, and they have no
* page in common — staff open the file's own screen, clients their
* portal. Resolving that here, per request, keeps the branch in one
* obvious place instead of teaching the notification centre to care who
* is reading it.
*/
class CommentDeepLinkController extends Controller
{
public function __invoke(Request $request, File $file): RedirectResponse
{
$viewer = $request->user();
assert($viewer !== null);
Gate::forUser($viewer)->authorize('view', $file);
if ($viewer->isStaff()) {
// The file's own page, which is also where the activity log's
// "View" link lands — one destination for "show me this
// conversation" rather than two. It works whatever page of the
// library the file happens to be on, which the slide-over did
// not.
return redirect()->route('files.edit', [$file, 'tab' => 'comments']);
}
// The portal is a list, so this opens the file's own comment panel
// from its row. A file that is not on the page the client lands on
// (deep in a folder, or past the first page) simply does not open —
// they still arrive somewhere sensible, which is why this is a
// query parameter rather than a promise.
return redirect()->route('my-files.index', ['comments' => $file->id]);
}
}