mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-10 00:34:50 +00:00
Merge pull request #855 from pixelfed/frontend-ui-refactor
Frontend ui refactor
This commit is contained in:
commit
8e2608cf25
6 changed files with 137 additions and 32 deletions
|
@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||||
class Circle extends Model
|
class Circle extends Model
|
||||||
{
|
{
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
|
'profile_id',
|
||||||
'name',
|
'name',
|
||||||
'description',
|
'description',
|
||||||
'bcc',
|
'bcc',
|
||||||
|
|
52
app/Http/Controllers/UserInviteController.php
Normal file
52
app/Http/Controllers/UserInviteController.php
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Auth;
|
||||||
|
use App\UserInvite;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
class UserInviteController extends Controller
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
abort_if(!config('pixelfed.user_invites.enabled'), 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create(Request $request)
|
||||||
|
{
|
||||||
|
abort_unless(Auth::check(), 403);
|
||||||
|
return view('settings.invites.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show(Request $request)
|
||||||
|
{
|
||||||
|
abort_unless(Auth::check(), 403);
|
||||||
|
$invites = UserInvite::whereUserId(Auth::id())->paginate(10);
|
||||||
|
$limit = config('pixelfed.user_invites.limit.total');
|
||||||
|
$used = UserInvite::whereUserId(Auth::id())->count();
|
||||||
|
return view('settings.invites.home', compact('invites', 'limit', 'used'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
abort_unless(Auth::check(), 403);
|
||||||
|
$this->validate($request, [
|
||||||
|
'email' => 'required|email|unique:users|unique:user_invites',
|
||||||
|
'message' => 'nullable|string|max:500',
|
||||||
|
'tos' => 'required|accepted'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$invite = new UserInvite;
|
||||||
|
$invite->user_id = Auth::id();
|
||||||
|
$invite->profile_id = Auth::user()->profile->id;
|
||||||
|
$invite->email = $request->input('email');
|
||||||
|
$invite->message = $request->input('message');
|
||||||
|
$invite->key = (string) Str::uuid();
|
||||||
|
$invite->token = str_random(32);
|
||||||
|
$invite->save();
|
||||||
|
|
||||||
|
return redirect(route('settings.invites'));
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,35 +17,33 @@ class StatusTransformer extends Fractal\TransformerAbstract
|
||||||
|
|
||||||
public function transform(Status $status)
|
public function transform(Status $status)
|
||||||
{
|
{
|
||||||
return Cache::remember('transform:status:'. $status->url(), 60, function() use($status) {
|
return [
|
||||||
return [
|
'id' => (string) $status->id,
|
||||||
'id' => (string) $status->id,
|
'uri' => $status->url(),
|
||||||
'uri' => $status->url(),
|
'url' => $status->url(),
|
||||||
'url' => $status->url(),
|
'in_reply_to_id' => $status->in_reply_to_id,
|
||||||
'in_reply_to_id' => $status->in_reply_to_id,
|
'in_reply_to_account_id' => $status->in_reply_to_profile_id,
|
||||||
'in_reply_to_account_id' => $status->in_reply_to_profile_id,
|
'reblog' => $status->reblog_of_id || $status->in_reply_to_id ? $this->transform($status->parent()) : null,
|
||||||
'reblog' => $status->reblog_of_id || $status->in_reply_to_id ? $this->transform($status->parent()) : null,
|
'content' => $status->rendered ?? $status->caption,
|
||||||
'content' => $status->rendered ?? $status->caption,
|
'created_at' => $status->created_at->format('c'),
|
||||||
'created_at' => $status->created_at->format('c'),
|
'emojis' => [],
|
||||||
'emojis' => [],
|
'reblogs_count' => $status->shares()->count(),
|
||||||
'reblogs_count' => $status->shares()->count(),
|
'favourites_count' => $status->likes()->count(),
|
||||||
'favourites_count' => $status->likes()->count(),
|
'reblogged' => $status->shared(),
|
||||||
'reblogged' => $status->shared(),
|
'favourited' => $status->liked(),
|
||||||
'favourited' => $status->liked(),
|
'muted' => null,
|
||||||
'muted' => null,
|
'sensitive' => (bool) $status->is_nsfw,
|
||||||
'sensitive' => (bool) $status->is_nsfw,
|
'spoiler_text' => $status->cw_summary,
|
||||||
'spoiler_text' => $status->cw_summary,
|
'visibility' => $status->visibility,
|
||||||
'visibility' => $status->visibility,
|
'application' => [
|
||||||
'application' => [
|
'name' => 'web',
|
||||||
'name' => 'web',
|
'website' => null
|
||||||
'website' => null
|
],
|
||||||
],
|
'language' => null,
|
||||||
'language' => null,
|
'pinned' => null,
|
||||||
'pinned' => null,
|
|
||||||
|
|
||||||
'pf_type' => $status->type ?? $status->setType(),
|
'pf_type' => $status->type ?? $status->setType(),
|
||||||
];
|
];
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function includeAccount(Status $status)
|
public function includeAccount(Status $status)
|
||||||
|
|
15
app/UserInvite.php
Normal file
15
app/UserInvite.php
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class UserInvite extends Model
|
||||||
|
{
|
||||||
|
public function url()
|
||||||
|
{
|
||||||
|
$path = '/i/invite/code';
|
||||||
|
$url = url($path, [$this->key, $this->token]);
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
|
}
|
|
@ -29,7 +29,7 @@ return [
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'bcrypt' => [
|
'bcrypt' => [
|
||||||
'rounds' => 10,
|
'rounds' => env('BCRYPT_COST', 10),
|
||||||
],
|
],
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -44,9 +44,9 @@ return [
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'argon' => [
|
'argon' => [
|
||||||
'memory' => 1024,
|
'memory' => env('ARGON_MEM', 1024),
|
||||||
'threads' => 2,
|
'threads' => env('ARGON_THREADS', 2),
|
||||||
'time' => 2,
|
'time' => env('ARGON_TIME', 2),
|
||||||
],
|
],
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class CreateUserInvitesTable extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::create('user_invites', function (Blueprint $table) {
|
||||||
|
$table->bigIncrements('id');
|
||||||
|
$table->bigInteger('user_id')->unsigned()->index();
|
||||||
|
$table->bigInteger('profile_id')->unsigned()->index();
|
||||||
|
$table->string('email')->unique()->index();
|
||||||
|
$table->text('message')->nullable();
|
||||||
|
$table->string('key');
|
||||||
|
$table->string('token');
|
||||||
|
$table->timestamp('valid_until')->nullable();
|
||||||
|
$table->timestamp('used_at')->nullable()->index();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('user_invites');
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue