mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 14:31:26 +00:00
Merge pull request #404 from pixelfed/frontend-ui-refactor
Frontend ui refactor
This commit is contained in:
commit
a157edc7b3
5 changed files with 141 additions and 24 deletions
|
@ -6,10 +6,21 @@ use Illuminate\Http\Request;
|
|||
use Carbon\Carbon;
|
||||
use App\Mail\ConfirmEmail;
|
||||
use Auth, DB, Cache, Mail, Redis;
|
||||
use App\{EmailVerification, Notification, Profile, User};
|
||||
use App\{
|
||||
EmailVerification,
|
||||
Notification,
|
||||
Profile,
|
||||
User,
|
||||
UserFilter
|
||||
};
|
||||
|
||||
class AccountController extends Controller
|
||||
{
|
||||
protected $filters = [
|
||||
'user.mute',
|
||||
'user.block'
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
|
@ -134,4 +145,97 @@ class AccountController extends Controller
|
|||
return $notifications;
|
||||
}
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return view('account.messages');
|
||||
}
|
||||
|
||||
|
||||
public function showMessage(Request $request, $id)
|
||||
{
|
||||
return view('account.message');
|
||||
}
|
||||
|
||||
public function mute(Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
'type' => 'required|string',
|
||||
'item' => 'required|integer|min:1'
|
||||
]);
|
||||
|
||||
$user = Auth::user()->profile;
|
||||
$type = $request->input('type');
|
||||
$item = $request->input('item');
|
||||
$action = "{$type}.mute";
|
||||
|
||||
if(!in_array($action, $this->filters)) {
|
||||
return abort(406);
|
||||
}
|
||||
$filterable = [];
|
||||
switch ($type) {
|
||||
case 'user':
|
||||
$profile = Profile::findOrFail($item);
|
||||
if($profile->id == $user->id) {
|
||||
return abort(403);
|
||||
}
|
||||
$class = get_class($profile);
|
||||
$filterable['id'] = $profile->id;
|
||||
$filterable['type'] = $class;
|
||||
break;
|
||||
|
||||
default:
|
||||
# code...
|
||||
break;
|
||||
}
|
||||
|
||||
$filter = UserFilter::firstOrCreate([
|
||||
'user_id' => $user->id,
|
||||
'filterable_id' => $filterable['id'],
|
||||
'filterable_type' => $filterable['type'],
|
||||
'filter_type' => 'mute'
|
||||
]);
|
||||
|
||||
return redirect()->back();
|
||||
|
||||
}
|
||||
|
||||
public function block(Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
'type' => 'required|string',
|
||||
'item' => 'required|integer|min:1'
|
||||
]);
|
||||
|
||||
$user = Auth::user()->profile;
|
||||
$type = $request->input('type');
|
||||
$item = $request->input('item');
|
||||
$action = "{$type}.block";
|
||||
if(!in_array($action, $this->filters)) {
|
||||
return abort(406);
|
||||
}
|
||||
$filterable = [];
|
||||
switch ($type) {
|
||||
case 'user':
|
||||
$profile = Profile::findOrFail($item);
|
||||
$class = get_class($profile);
|
||||
$filterable['id'] = $profile->id;
|
||||
$filterable['type'] = $class;
|
||||
break;
|
||||
|
||||
default:
|
||||
# code...
|
||||
break;
|
||||
}
|
||||
|
||||
$filter = UserFilter::firstOrCreate([
|
||||
'user_id' => $user->id,
|
||||
'filterable_id' => $filterable['id'],
|
||||
'filterable_type' => $filterable['type'],
|
||||
'filter_type' => 'block'
|
||||
]);
|
||||
|
||||
return redirect()->back();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,5 +6,10 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
class UserFilter extends Model
|
||||
{
|
||||
//
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'filterable_id',
|
||||
'filterable_type',
|
||||
'filter_type'
|
||||
];
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
<li class="nav-item px-2">
|
||||
<div title="Create new post" data-toggle="tooltip" data-placement="bottom">
|
||||
<a href="{{route('compose')}}" class="nav-link" data-toggle="modal" data-target="#composeModal">
|
||||
<i class="far fa-plus-square fa-lg text-primary"></i>
|
||||
<i class="fas fa-camera-retro fa-lg text-primary"></i>
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
class ExampleTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* A basic test example.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testBasicTest()
|
||||
{
|
||||
$response = $this->get('/');
|
||||
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
}
|
29
tests/Feature/InstalledTest.php
Normal file
29
tests/Feature/InstalledTest.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
|
||||
class InstalledTest extends TestCase
|
||||
{
|
||||
public function testLandingTest()
|
||||
{
|
||||
$response = $this->get('/');
|
||||
$response
|
||||
->assertStatus(200)
|
||||
->assertSeeText('Image Sharing for Everyone');
|
||||
}
|
||||
|
||||
public function testNodeinfoTest()
|
||||
{
|
||||
$response = $this->get('/.well-known/nodeinfo');
|
||||
$response
|
||||
->assertStatus(200)
|
||||
->assertJson([
|
||||
"links" => [
|
||||
["rel" => "http://nodeinfo.diaspora.software/ns/schema/2.0"]
|
||||
]]);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue