mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-25 06:23:18 +00:00
Merge branch 'staging' of https://github.com/pixelfed/pixelfed into translation-coverage-extension
This commit is contained in:
commit
fa9bd9b050
30 changed files with 1847 additions and 2702 deletions
15
CHANGELOG.md
15
CHANGELOG.md
|
@ -1,6 +1,17 @@
|
|||
# Release Notes
|
||||
|
||||
## [Unreleased](https://github.com/pixelfed/pixelfed/compare/v0.12.1...dev)
|
||||
## [Unreleased](https://github.com/pixelfed/pixelfed/compare/v0.12.3...dev)
|
||||
- ([](https://github.com/pixelfed/pixelfed/commit/))
|
||||
|
||||
## [v0.12.3 (2024-07-01)](https://github.com/pixelfed/pixelfed/compare/v0.12.2...v0.12.3)
|
||||
|
||||
### Updates
|
||||
- Fix migrations bug ([4d1180b1](https://github.com/pixelfed/pixelfed/commit/4d1180b1))
|
||||
|
||||
## [v0.12.2 (2024-07-01)](https://github.com/pixelfed/pixelfed/compare/v0.12.1...v0.12.2)
|
||||
|
||||
### Framework
|
||||
- Updated to Laravel 11 (requires php 8.2+)
|
||||
|
||||
### Added
|
||||
- New api/v1/instance/peers API endpoint, disabled by default ([4aad1c22](https://github.com/pixelfed/pixelfed/commit/4aad1c22))
|
||||
|
@ -33,7 +44,7 @@
|
|||
- Update and refactor total local post count logic, cache value and schedule updates twice daily to eliminate the perf issue on larger instances ([4f2b8ed2](https://github.com/pixelfed/pixelfed/commit/4f2b8ed2))
|
||||
- Update Media model, fix broken thumbnail/gray thumbnail bug ([e33643c2](https://github.com/pixelfed/pixelfed/commit/e33643c2))
|
||||
- Update StatusController, fix unlisted post guest/ap access bug ([83098428](https://github.com/pixelfed/pixelfed/commit/83098428))
|
||||
- ([](https://github.com/pixelfed/pixelfed/commit/))
|
||||
- Update discover, add network trending using Beagle API ([2cae8b48](https://github.com/pixelfed/pixelfed/commit/2cae8b48))
|
||||
|
||||
## [v0.12.1 (2024-05-07)](https://github.com/pixelfed/pixelfed/compare/v0.12.0...v0.12.1)
|
||||
|
||||
|
|
|
@ -2,57 +2,45 @@
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\{
|
||||
AccountInterstitial,
|
||||
Contact,
|
||||
Hashtag,
|
||||
Instance,
|
||||
Newsroom,
|
||||
OauthClient,
|
||||
Profile,
|
||||
Report,
|
||||
Status,
|
||||
StatusHashtag,
|
||||
Story,
|
||||
User
|
||||
};
|
||||
use DB, Cache, Storage;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Redis;
|
||||
use App\Http\Controllers\Admin\{
|
||||
AdminAutospamController,
|
||||
AdminDirectoryController,
|
||||
AdminDiscoverController,
|
||||
AdminHashtagsController,
|
||||
AdminInstanceController,
|
||||
AdminReportController,
|
||||
// AdminGroupsController,
|
||||
AdminMediaController,
|
||||
AdminSettingsController,
|
||||
// AdminStorageController,
|
||||
AdminSupportController,
|
||||
AdminUserController
|
||||
};
|
||||
use Illuminate\Validation\Rule;
|
||||
use App\Services\AdminStatsService;
|
||||
use App\Contact;
|
||||
use App\Http\Controllers\Admin\AdminAutospamController;
|
||||
use App\Http\Controllers\Admin\AdminDirectoryController;
|
||||
use App\Http\Controllers\Admin\AdminDiscoverController;
|
||||
use App\Http\Controllers\Admin\AdminHashtagsController;
|
||||
use App\Http\Controllers\Admin\AdminInstanceController;
|
||||
use App\Http\Controllers\Admin\AdminMediaController;
|
||||
use App\Http\Controllers\Admin\AdminReportController;
|
||||
use App\Http\Controllers\Admin\AdminSettingsController;
|
||||
use App\Http\Controllers\Admin\AdminUserController;
|
||||
use App\Instance;
|
||||
use App\Models\CustomEmoji;
|
||||
use App\Newsroom;
|
||||
use App\OauthClient;
|
||||
use App\Profile;
|
||||
use App\Services\AccountService;
|
||||
use App\Services\AdminStatsService;
|
||||
use App\Services\ConfigCacheService;
|
||||
use App\Services\StatusService;
|
||||
use App\Services\StoryService;
|
||||
use App\Models\CustomEmoji;
|
||||
use App\Status;
|
||||
use App\Story;
|
||||
use App\User;
|
||||
use Cache;
|
||||
use DB;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Storage;
|
||||
|
||||
class AdminController extends Controller
|
||||
{
|
||||
use AdminReportController,
|
||||
AdminAutospamController,
|
||||
use AdminAutospamController,
|
||||
AdminDirectoryController,
|
||||
AdminDiscoverController,
|
||||
AdminHashtagsController,
|
||||
// AdminGroupsController,
|
||||
AdminMediaController,
|
||||
AdminSettingsController,
|
||||
AdminInstanceController,
|
||||
// AdminStorageController,
|
||||
AdminMediaController,
|
||||
AdminReportController,
|
||||
AdminSettingsController,
|
||||
AdminUserController;
|
||||
|
||||
public function __construct()
|
||||
|
@ -67,9 +55,27 @@ class AdminController extends Controller
|
|||
return view('admin.home');
|
||||
}
|
||||
|
||||
public function customCss()
|
||||
{
|
||||
return view('admin.settings.customcss');
|
||||
}
|
||||
|
||||
public function saveCustomCss(Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
'css' => 'sometimes|max:5000',
|
||||
'show' => 'sometimes',
|
||||
]);
|
||||
ConfigCacheService::put('uikit.custom.css', $request->input('css'));
|
||||
ConfigCacheService::put('uikit.show_custom.css', $request->boolean('show'));
|
||||
|
||||
return view('admin.settings.customcss');
|
||||
}
|
||||
|
||||
public function stats()
|
||||
{
|
||||
$data = AdminStatsService::get();
|
||||
|
||||
return view('admin.stats', compact('data'));
|
||||
}
|
||||
|
||||
|
@ -83,25 +89,27 @@ class AdminController extends Controller
|
|||
$users = User::orderByDesc('id')->cursorPaginate(10);
|
||||
|
||||
$res = [
|
||||
"next_page_url" => $users->nextPageUrl(),
|
||||
"data" => $users->map(function($user) {
|
||||
'next_page_url' => $users->nextPageUrl(),
|
||||
'data' => $users->map(function ($user) {
|
||||
$account = AccountService::get($user->profile_id, true);
|
||||
if(!$account) {
|
||||
if (! $account) {
|
||||
return [
|
||||
"id" => $user->profile_id,
|
||||
"username" => $user->username,
|
||||
"status" => "deleted",
|
||||
"avatar" => "/storage/avatars/default.jpg",
|
||||
"created_at" => $user->created_at
|
||||
'id' => $user->profile_id,
|
||||
'username' => $user->username,
|
||||
'status' => 'deleted',
|
||||
'avatar' => '/storage/avatars/default.jpg',
|
||||
'created_at' => $user->created_at,
|
||||
];
|
||||
}
|
||||
$account['user_id'] = $user->id;
|
||||
|
||||
return $account;
|
||||
})
|
||||
->filter(function($user) {
|
||||
->filter(function ($user) {
|
||||
return $user;
|
||||
})
|
||||
}),
|
||||
];
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
@ -112,14 +120,15 @@ class AdminController extends Controller
|
|||
->cursorPaginate(10);
|
||||
|
||||
$res = [
|
||||
"next_page_url" => $posts->nextPageUrl(),
|
||||
"data" => $posts->map(function($post) {
|
||||
'next_page_url' => $posts->nextPageUrl(),
|
||||
'data' => $posts->map(function ($post) {
|
||||
$status = StatusService::get($post->id, false);
|
||||
if(!$status) {
|
||||
return ["id" => $post->id, "created_at" => $post->created_at];
|
||||
if (! $status) {
|
||||
return ['id' => $post->id, 'created_at' => $post->created_at];
|
||||
}
|
||||
|
||||
return $status;
|
||||
})
|
||||
}),
|
||||
];
|
||||
|
||||
return $res;
|
||||
|
@ -133,13 +142,14 @@ class AdminController extends Controller
|
|||
public function statuses(Request $request)
|
||||
{
|
||||
$statuses = Status::orderBy('id', 'desc')->cursorPaginate(10);
|
||||
$data = $statuses->map(function($status) {
|
||||
$data = $statuses->map(function ($status) {
|
||||
return StatusService::get($status->id, false);
|
||||
})
|
||||
->filter(function($s) {
|
||||
->filter(function ($s) {
|
||||
return $s;
|
||||
})
|
||||
->toArray();
|
||||
|
||||
return view('admin.statuses.home', compact('statuses', 'data'));
|
||||
}
|
||||
|
||||
|
@ -157,23 +167,24 @@ class AdminController extends Controller
|
|||
'filter' => [
|
||||
'nullable',
|
||||
'string',
|
||||
Rule::in(['all', 'local', 'remote'])
|
||||
]
|
||||
Rule::in(['all', 'local', 'remote']),
|
||||
],
|
||||
]);
|
||||
$search = $request->input('search');
|
||||
$filter = $request->input('filter');
|
||||
$limit = 12;
|
||||
$profiles = Profile::select('id','username')
|
||||
$profiles = Profile::select('id', 'username')
|
||||
->whereNull('status')
|
||||
->when($search, function($q, $search) {
|
||||
->when($search, function ($q, $search) {
|
||||
return $q->where('username', 'like', "%$search%");
|
||||
})->when($filter, function($q, $filter) {
|
||||
if($filter == 'local') {
|
||||
})->when($filter, function ($q, $filter) {
|
||||
if ($filter == 'local') {
|
||||
return $q->whereNull('domain');
|
||||
}
|
||||
if($filter == 'remote') {
|
||||
if ($filter == 'remote') {
|
||||
return $q->whereNotNull('domain');
|
||||
}
|
||||
|
||||
return $q;
|
||||
})->orderByDesc('id')
|
||||
->simplePaginate($limit);
|
||||
|
@ -185,13 +196,14 @@ class AdminController extends Controller
|
|||
{
|
||||
$profile = Profile::findOrFail($id);
|
||||
$user = $profile->user;
|
||||
|
||||
return view('admin.profiles.edit', compact('profile', 'user'));
|
||||
}
|
||||
|
||||
public function appsHome(Request $request)
|
||||
{
|
||||
$filter = $request->input('filter');
|
||||
if($filter == 'revoked') {
|
||||
if ($filter == 'revoked') {
|
||||
$apps = OauthClient::with('user')
|
||||
->whereNotNull('user_id')
|
||||
->whereRevoked(true)
|
||||
|
@ -203,39 +215,43 @@ class AdminController extends Controller
|
|||
->orderByDesc('id')
|
||||
->paginate(10);
|
||||
}
|
||||
|
||||
return view('admin.apps.home', compact('apps'));
|
||||
}
|
||||
|
||||
public function messagesHome(Request $request)
|
||||
{
|
||||
$messages = Contact::orderByDesc('id')->paginate(10);
|
||||
|
||||
return view('admin.messages.home', compact('messages'));
|
||||
}
|
||||
|
||||
public function messagesShow(Request $request, $id)
|
||||
{
|
||||
$message = Contact::findOrFail($id);
|
||||
|
||||
return view('admin.messages.show', compact('message'));
|
||||
}
|
||||
|
||||
public function messagesMarkRead(Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
'id' => 'required|integer|min:1'
|
||||
'id' => 'required|integer|min:1',
|
||||
]);
|
||||
$id = $request->input('id');
|
||||
$message = Contact::findOrFail($id);
|
||||
if($message->read_at) {
|
||||
if ($message->read_at) {
|
||||
return;
|
||||
}
|
||||
$message->read_at = now();
|
||||
$message->save();
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
public function newsroomHome(Request $request)
|
||||
{
|
||||
$newsroom = Newsroom::latest()->paginate(10);
|
||||
|
||||
return view('admin.newsroom.home', compact('newsroom'));
|
||||
}
|
||||
|
||||
|
@ -247,6 +263,7 @@ class AdminController extends Controller
|
|||
public function newsroomEdit(Request $request, $id)
|
||||
{
|
||||
$news = Newsroom::findOrFail($id);
|
||||
|
||||
return view('admin.newsroom.edit', compact('news'));
|
||||
}
|
||||
|
||||
|
@ -254,6 +271,7 @@ class AdminController extends Controller
|
|||
{
|
||||
$news = Newsroom::findOrFail($id);
|
||||
$news->delete();
|
||||
|
||||
return redirect('/i/admin/newsroom');
|
||||
}
|
||||
|
||||
|
@ -262,13 +280,13 @@ class AdminController extends Controller
|
|||
$this->validate($request, [
|
||||
'title' => 'required|string|min:1|max:100',
|
||||
'summary' => 'nullable|string|max:200',
|
||||
'body' => 'nullable|string'
|
||||
'body' => 'nullable|string',
|
||||
]);
|
||||
$changed = false;
|
||||
$changedFields = [];
|
||||
$slug = str_slug($request->input('title'));
|
||||
if(Newsroom::whereSlug($slug)->exists()) {
|
||||
$slug = $slug . '-' . str_random(4);
|
||||
if (Newsroom::whereSlug($slug)->exists()) {
|
||||
$slug = $slug.'-'.str_random(4);
|
||||
}
|
||||
$news = Newsroom::findOrFail($id);
|
||||
$fields = [
|
||||
|
@ -280,13 +298,13 @@ class AdminController extends Controller
|
|||
'auth_only' => 'boolean',
|
||||
'show_link' => 'boolean',
|
||||
'force_modal' => 'boolean',
|
||||
'published' => 'published'
|
||||
'published' => 'published',
|
||||
];
|
||||
foreach($fields as $field => $type) {
|
||||
foreach ($fields as $field => $type) {
|
||||
switch ($type) {
|
||||
case 'string':
|
||||
if($request->{$field} != $news->{$field}) {
|
||||
if($field == 'title') {
|
||||
if ($request->{$field} != $news->{$field}) {
|
||||
if ($field == 'title') {
|
||||
$news->slug = $slug;
|
||||
}
|
||||
$news->{$field} = $request->{$field};
|
||||
|
@ -297,7 +315,7 @@ class AdminController extends Controller
|
|||
|
||||
case 'boolean':
|
||||
$state = $request->{$field} == 'on' ? true : false;
|
||||
if($state != $news->{$field}) {
|
||||
if ($state != $news->{$field}) {
|
||||
$news->{$field} = $state;
|
||||
$changed = true;
|
||||
array_push($changedFields, $field);
|
||||
|
@ -306,7 +324,7 @@ class AdminController extends Controller
|
|||
case 'published':
|
||||
$state = $request->{$field} == 'on' ? true : false;
|
||||
$published = $news->published_at != null;
|
||||
if($state != $published) {
|
||||
if ($state != $published) {
|
||||
$news->published_at = $state ? now() : null;
|
||||
$changed = true;
|
||||
array_push($changedFields, $field);
|
||||
|
@ -316,26 +334,26 @@ class AdminController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
if($changed) {
|
||||
if ($changed) {
|
||||
$news->save();
|
||||
}
|
||||
$redirect = $news->published_at ? $news->permalink() : $news->editUrl();
|
||||
|
||||
return redirect($redirect);
|
||||
}
|
||||
|
||||
|
||||
public function newsroomStore(Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
'title' => 'required|string|min:1|max:100',
|
||||
'summary' => 'nullable|string|max:200',
|
||||
'body' => 'nullable|string'
|
||||
'body' => 'nullable|string',
|
||||
]);
|
||||
$changed = false;
|
||||
$changedFields = [];
|
||||
$slug = str_slug($request->input('title'));
|
||||
if(Newsroom::whereSlug($slug)->exists()) {
|
||||
$slug = $slug . '-' . str_random(4);
|
||||
if (Newsroom::whereSlug($slug)->exists()) {
|
||||
$slug = $slug.'-'.str_random(4);
|
||||
}
|
||||
$news = new Newsroom();
|
||||
$fields = [
|
||||
|
@ -347,13 +365,13 @@ class AdminController extends Controller
|
|||
'auth_only' => 'boolean',
|
||||
'show_link' => 'boolean',
|
||||
'force_modal' => 'boolean',
|
||||
'published' => 'published'
|
||||
'published' => 'published',
|
||||
];
|
||||
foreach($fields as $field => $type) {
|
||||
foreach ($fields as $field => $type) {
|
||||
switch ($type) {
|
||||
case 'string':
|
||||
if($request->{$field} != $news->{$field}) {
|
||||
if($field == 'title') {
|
||||
if ($request->{$field} != $news->{$field}) {
|
||||
if ($field == 'title') {
|
||||
$news->slug = $slug;
|
||||
}
|
||||
$news->{$field} = $request->{$field};
|
||||
|
@ -364,7 +382,7 @@ class AdminController extends Controller
|
|||
|
||||
case 'boolean':
|
||||
$state = $request->{$field} == 'on' ? true : false;
|
||||
if($state != $news->{$field}) {
|
||||
if ($state != $news->{$field}) {
|
||||
$news->{$field} = $state;
|
||||
$changed = true;
|
||||
array_push($changedFields, $field);
|
||||
|
@ -373,7 +391,7 @@ class AdminController extends Controller
|
|||
case 'published':
|
||||
$state = $request->{$field} == 'on' ? true : false;
|
||||
$published = $news->published_at != null;
|
||||
if($state != $published) {
|
||||
if ($state != $published) {
|
||||
$news->published_at = $state ? now() : null;
|
||||
$changed = true;
|
||||
array_push($changedFields, $field);
|
||||
|
@ -383,10 +401,11 @@ class AdminController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
if($changed) {
|
||||
if ($changed) {
|
||||
$news->save();
|
||||
}
|
||||
$redirect = $news->published_at ? $news->permalink() : $news->editUrl();
|
||||
|
||||
return redirect($redirect);
|
||||
}
|
||||
|
||||
|
@ -398,18 +417,18 @@ class AdminController extends Controller
|
|||
public function diagnosticsDecrypt(Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
'payload' => 'required'
|
||||
'payload' => 'required',
|
||||
]);
|
||||
|
||||
$key = 'exception_report:';
|
||||
$decrypted = decrypt($request->input('payload'));
|
||||
|
||||
if(!starts_with($decrypted, $key)) {
|
||||
if (! starts_with($decrypted, $key)) {
|
||||
abort(403, 'Can only decrypt error diagnostics');
|
||||
}
|
||||
|
||||
$res = [
|
||||
'decrypted' => substr($decrypted, strlen($key))
|
||||
'decrypted' => substr($decrypted, strlen($key)),
|
||||
];
|
||||
|
||||
return response()->json($res);
|
||||
|
@ -419,71 +438,74 @@ class AdminController extends Controller
|
|||
{
|
||||
$stories = Story::with('profile')->latest()->paginate(10);
|
||||
$stats = StoryService::adminStats();
|
||||
|
||||
return view('admin.stories.home', compact('stories', 'stats'));
|
||||
}
|
||||
|
||||
public function customEmojiHome(Request $request)
|
||||
{
|
||||
if(!(bool) config_cache('federation.custom_emoji.enabled')) {
|
||||
if (! (bool) config_cache('federation.custom_emoji.enabled')) {
|
||||
return view('admin.custom-emoji.not-enabled');
|
||||
}
|
||||
$this->validate($request, [
|
||||
'sort' => 'sometimes|in:all,local,remote,duplicates,disabled,search'
|
||||
'sort' => 'sometimes|in:all,local,remote,duplicates,disabled,search',
|
||||
]);
|
||||
|
||||
if($request->has('cc')) {
|
||||
if ($request->has('cc')) {
|
||||
Cache::forget('pf:admin:custom_emoji:stats');
|
||||
Cache::forget('pf:custom_emoji');
|
||||
|
||||
return redirect(route('admin.custom-emoji'));
|
||||
}
|
||||
|
||||
$sort = $request->input('sort') ?? 'all';
|
||||
|
||||
if($sort == 'search' && empty($request->input('q'))) {
|
||||
if ($sort == 'search' && empty($request->input('q'))) {
|
||||
return redirect(route('admin.custom-emoji'));
|
||||
}
|
||||
|
||||
$pg = config('database.default') == 'pgsql';
|
||||
|
||||
$emojis = CustomEmoji::when($sort, function($query, $sort) use($request, $pg) {
|
||||
if($sort == 'all') {
|
||||
if($pg) {
|
||||
$emojis = CustomEmoji::when($sort, function ($query, $sort) use ($request, $pg) {
|
||||
if ($sort == 'all') {
|
||||
if ($pg) {
|
||||
return $query->latest();
|
||||
} else {
|
||||
return $query->groupBy('shortcode')->latest();
|
||||
}
|
||||
} else if($sort == 'local') {
|
||||
} elseif ($sort == 'local') {
|
||||
return $query->latest()->where('domain', '=', config('pixelfed.domain.app'));
|
||||
} else if($sort == 'remote') {
|
||||
} elseif ($sort == 'remote') {
|
||||
return $query->latest()->where('domain', '!=', config('pixelfed.domain.app'));
|
||||
} else if($sort == 'duplicates') {
|
||||
} elseif ($sort == 'duplicates') {
|
||||
return $query->latest()->groupBy('shortcode')->havingRaw('count(*) > 1');
|
||||
} else if($sort == 'disabled') {
|
||||
} elseif ($sort == 'disabled') {
|
||||
return $query->latest()->whereDisabled(true);
|
||||
} else if($sort == 'search') {
|
||||
} elseif ($sort == 'search') {
|
||||
$q = $query
|
||||
->latest()
|
||||
->where('shortcode', 'like', '%' . $request->input('q') . '%')
|
||||
->orWhere('domain', 'like', '%' . $request->input('q') . '%');
|
||||
if(!$request->has('dups')) {
|
||||
if(!$pg) {
|
||||
->where('shortcode', 'like', '%'.$request->input('q').'%')
|
||||
->orWhere('domain', 'like', '%'.$request->input('q').'%');
|
||||
if (! $request->has('dups')) {
|
||||
if (! $pg) {
|
||||
$q = $q->groupBy('shortcode');
|
||||
}
|
||||
}
|
||||
|
||||
return $q;
|
||||
}
|
||||
})
|
||||
->simplePaginate(10)
|
||||
->withQueryString();
|
||||
|
||||
$stats = Cache::remember('pf:admin:custom_emoji:stats', 43200, function() use($pg) {
|
||||
$stats = Cache::remember('pf:admin:custom_emoji:stats', 43200, function () use ($pg) {
|
||||
$res = [
|
||||
'total' => CustomEmoji::count(),
|
||||
'active' => CustomEmoji::whereDisabled(false)->count(),
|
||||
'remote' => CustomEmoji::where('domain', '!=', config('pixelfed.domain.app'))->count(),
|
||||
];
|
||||
|
||||
if($pg) {
|
||||
if ($pg) {
|
||||
$res['duplicate'] = CustomEmoji::select('shortcode')->groupBy('shortcode')->havingRaw('count(*) > 1')->count();
|
||||
} else {
|
||||
$res['duplicate'] = CustomEmoji::groupBy('shortcode')->havingRaw('count(*) > 1')->count();
|
||||
|
@ -499,16 +521,18 @@ class AdminController extends Controller
|
|||
{
|
||||
abort_unless((bool) config_cache('federation.custom_emoji.enabled'), 404);
|
||||
$emoji = CustomEmoji::findOrFail($id);
|
||||
$emoji->disabled = !$emoji->disabled;
|
||||
$emoji->disabled = ! $emoji->disabled;
|
||||
$emoji->save();
|
||||
$key = CustomEmoji::CACHE_KEY . str_replace(':', '', $emoji->shortcode);
|
||||
$key = CustomEmoji::CACHE_KEY.str_replace(':', '', $emoji->shortcode);
|
||||
Cache::forget($key);
|
||||
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function customEmojiAdd(Request $request)
|
||||
{
|
||||
abort_unless((bool) config_cache('federation.custom_emoji.enabled'), 404);
|
||||
|
||||
return view('admin.custom-emoji.add');
|
||||
}
|
||||
|
||||
|
@ -522,12 +546,12 @@ class AdminController extends Controller
|
|||
'max:80',
|
||||
'starts_with::',
|
||||
'ends_with::',
|
||||
Rule::unique('custom_emoji')->where(function ($query) use($request) {
|
||||
Rule::unique('custom_emoji')->where(function ($query) use ($request) {
|
||||
return $query->whereDomain(config('pixelfed.domain.app'))
|
||||
->whereShortcode($request->input('shortcode'));
|
||||
})
|
||||
}),
|
||||
],
|
||||
'emoji' => 'required|file|mimes:jpg,png|max:' . (config('federation.custom_emoji.max_size') / 1000)
|
||||
'emoji' => 'required|file|mimes:jpg,png|max:'.(config('federation.custom_emoji.max_size') / 1000),
|
||||
]);
|
||||
|
||||
$emoji = new CustomEmoji;
|
||||
|
@ -535,11 +559,12 @@ class AdminController extends Controller
|
|||
$emoji->domain = config('pixelfed.domain.app');
|
||||
$emoji->save();
|
||||
|
||||
$fileName = $emoji->id . '.' . $request->emoji->extension();
|
||||
$fileName = $emoji->id.'.'.$request->emoji->extension();
|
||||
$request->emoji->storePubliclyAs('public/emoji', $fileName);
|
||||
$emoji->media_path = 'emoji/' . $fileName;
|
||||
$emoji->media_path = 'emoji/'.$fileName;
|
||||
$emoji->save();
|
||||
Cache::forget('pf:custom_emoji');
|
||||
|
||||
return redirect(route('admin.custom-emoji'));
|
||||
}
|
||||
|
||||
|
@ -550,6 +575,7 @@ class AdminController extends Controller
|
|||
Storage::delete("public/{$emoji->media_path}");
|
||||
Cache::forget('pf:custom_emoji');
|
||||
$emoji->delete();
|
||||
|
||||
return redirect(route('admin.custom-emoji'));
|
||||
}
|
||||
|
||||
|
@ -558,6 +584,7 @@ class AdminController extends Controller
|
|||
abort_unless((bool) config_cache('federation.custom_emoji.enabled'), 404);
|
||||
$emoji = CustomEmoji::orderBy('id')->whereDisabled(false)->whereShortcode($id)->firstOrFail();
|
||||
$emojis = CustomEmoji::whereShortcode($id)->where('id', '!=', $emoji->id)->cursorPaginate(10);
|
||||
|
||||
return view('admin.custom-emoji.duplicates', compact('emoji', 'emojis'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ use App\Services\BookmarkService;
|
|||
use App\Services\ConfigCacheService;
|
||||
use App\Services\FollowerService;
|
||||
use App\Services\HashtagService;
|
||||
use App\Services\Internal\BeagleService;
|
||||
use App\Services\LikeService;
|
||||
use App\Services\ReblogService;
|
||||
use App\Services\SnowflakeService;
|
||||
|
@ -420,4 +421,11 @@ class DiscoverController extends Controller
|
|||
|
||||
return response()->json($ids, 200, [], JSON_UNESCAPED_SLASHES);
|
||||
}
|
||||
|
||||
public function discoverNetworkTrending(Request $request)
|
||||
{
|
||||
abort_if(! $request->user(), 404);
|
||||
|
||||
return BeagleService::getDiscoverPosts();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,18 +2,25 @@
|
|||
|
||||
namespace App\Services\Internal;
|
||||
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use App\Services\InstanceService;
|
||||
use App\Services\StatusService;
|
||||
use App\Util\ActivityPub\Helpers;
|
||||
use Illuminate\Http\Client\ConnectionException;
|
||||
use Illuminate\Http\Client\RequestException;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class BeagleService
|
||||
{
|
||||
const DEFAULT_RULES_CACHE_KEY = 'pf:services:beagle:default_rules:v1';
|
||||
|
||||
const DISCOVER_CACHE_KEY = 'pf:services:beagle:discover:v1';
|
||||
|
||||
const DISCOVER_POSTS_CACHE_KEY = 'pf:services:beagle:discover-posts:v1';
|
||||
|
||||
public static function getDefaultRules()
|
||||
{
|
||||
return Cache::remember(self::DEFAULT_RULES_CACHE_KEY, now()->addDays(7), function() {
|
||||
return Cache::remember(self::DEFAULT_RULES_CACHE_KEY, now()->addDays(7), function () {
|
||||
try {
|
||||
$res = Http::withOptions(['allow_redirects' => false])
|
||||
->timeout(5)
|
||||
|
@ -28,17 +35,85 @@ class BeagleService
|
|||
return;
|
||||
}
|
||||
|
||||
if(!$res->ok()) {
|
||||
if (! $res->ok()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$json = $res->json();
|
||||
|
||||
if(!isset($json['rule_suggestions']) || !count($json['rule_suggestions'])) {
|
||||
if (! isset($json['rule_suggestions']) || ! count($json['rule_suggestions'])) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $json['rule_suggestions'];
|
||||
});
|
||||
}
|
||||
|
||||
public static function getDiscover()
|
||||
{
|
||||
return Cache::remember(self::DISCOVER_CACHE_KEY, now()->addHours(6), function () {
|
||||
try {
|
||||
$res = Http::withOptions(['allow_redirects' => false])
|
||||
->withHeaders([
|
||||
'X-Pixelfed-Api' => 1,
|
||||
])->timeout(5)
|
||||
->connectTimeout(5)
|
||||
->retry(2, 500)
|
||||
->get('https://beagle.pixelfed.net/api/v1/discover');
|
||||
} catch (RequestException $e) {
|
||||
return;
|
||||
} catch (ConnectionException $e) {
|
||||
return;
|
||||
} catch (Exception $e) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (! $res->ok()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$json = $res->json();
|
||||
|
||||
if (! isset($json['statuses']) || ! count($json['statuses'])) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $json['statuses'];
|
||||
});
|
||||
}
|
||||
|
||||
public static function getDiscoverPosts()
|
||||
{
|
||||
return Cache::remember(self::DISCOVER_POSTS_CACHE_KEY, now()->addHours(1), function () {
|
||||
$posts = collect(self::getDiscover())
|
||||
->filter(function ($post) {
|
||||
$bannedInstances = InstanceService::getBannedDomains();
|
||||
$domain = parse_url($post['id'], PHP_URL_HOST);
|
||||
|
||||
return ! in_array($domain, $bannedInstances);
|
||||
})
|
||||
->map(function ($post) {
|
||||
$domain = parse_url($post['id'], PHP_URL_HOST);
|
||||
if ($domain === config_cache('pixelfed.domain.app')) {
|
||||
$parts = explode('/', $post['id']);
|
||||
$id = array_last($parts);
|
||||
|
||||
return StatusService::get($id);
|
||||
}
|
||||
|
||||
$post = Helpers::statusFetch($post['id']);
|
||||
if (! $post) {
|
||||
return;
|
||||
}
|
||||
$id = $post->id;
|
||||
|
||||
return StatusService::get($id);
|
||||
})
|
||||
->filter()
|
||||
->values()
|
||||
->toArray();
|
||||
|
||||
return $posts;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"license": "AGPL-3.0-only",
|
||||
"type": "project",
|
||||
"require": {
|
||||
"php": "^8.1|^8.2|^8.3",
|
||||
"php": "^8.2|^8.3",
|
||||
"ext-bcmath": "*",
|
||||
"ext-ctype": "*",
|
||||
"ext-curl": "*",
|
||||
|
@ -14,18 +14,17 @@
|
|||
"ext-mbstring": "*",
|
||||
"ext-openssl": "*",
|
||||
"bacon/bacon-qr-code": "^2.0.3",
|
||||
"beyondcode/laravel-websockets": "^1.13",
|
||||
"brick/math": "^0.9.3",
|
||||
"buzz/laravel-h-captcha": "^1.0.4",
|
||||
"doctrine/dbal": "^3.0",
|
||||
"intervention/image": "^2.4",
|
||||
"jenssegers/agent": "^2.6",
|
||||
"laravel-notification-channels/webpush": "^7.1",
|
||||
"laravel/framework": "^10.0",
|
||||
"laravel-notification-channels/webpush": "^8.0",
|
||||
"laravel/framework": "^11.0",
|
||||
"laravel/helpers": "^1.1",
|
||||
"laravel/horizon": "^5.0",
|
||||
"laravel/passport": "^11.0",
|
||||
"laravel/tinker": "^2.0",
|
||||
"laravel/passport": "^12.0",
|
||||
"laravel/tinker": "^2.9",
|
||||
"laravel/ui": "^4.2",
|
||||
"league/flysystem-aws-s3-v3": "^3.0",
|
||||
"league/iso3166": "^2.1|^4.0",
|
||||
|
@ -33,24 +32,22 @@
|
|||
"phpseclib/phpseclib": "~2.0",
|
||||
"pixelfed/fractal": "^0.18.0",
|
||||
"pixelfed/laravel-snowflake": "^2.0",
|
||||
"pixelfed/zttp": "^0.5",
|
||||
"pragmarx/google2fa": "^8.0",
|
||||
"predis/predis": "^2.0",
|
||||
"pusher/pusher-php-server": "^7.2",
|
||||
"spatie/laravel-backup": "^8.0.0",
|
||||
"spatie/laravel-image-optimizer": "^1.7",
|
||||
"stevebauman/purify": "6.0.*",
|
||||
"spatie/laravel-image-optimizer": "^1.8.0",
|
||||
"stevebauman/purify": "^6.2.0",
|
||||
"symfony/http-client": "^6.1",
|
||||
"symfony/http-kernel": "^6.0.0",
|
||||
"symfony/mailgun-mailer": "^6.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"brianium/paratest": "^6.1",
|
||||
"fakerphp/faker": "^1.20",
|
||||
"laravel/pint": "^1.14",
|
||||
"laravel/telescope": "^4.14",
|
||||
"mockery/mockery": "^1.0",
|
||||
"nunomaduro/collision": "^6.1",
|
||||
"phpunit/phpunit": "^9.0"
|
||||
"fakerphp/faker": "^1.23",
|
||||
"laravel/pint": "^1.13",
|
||||
"laravel/telescope": "^5.0",
|
||||
"mockery/mockery": "^1.6",
|
||||
"nunomaduro/collision": "^8.1",
|
||||
"phpunit/phpunit": "^11.0.1"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
|
@ -86,6 +83,9 @@
|
|||
"post-create-project-cmd": [
|
||||
"@php artisan key:generate --ansi"
|
||||
],
|
||||
"post-update-cmd": [
|
||||
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
|
||||
],
|
||||
"post-autoload-dump": [
|
||||
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
|
||||
"@php artisan package:discover --ansi"
|
||||
|
|
2999
composer.lock
generated
2999
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -23,7 +23,7 @@ return [
|
|||
| This value is the version of your Pixelfed instance.
|
||||
|
|
||||
*/
|
||||
'version' => '0.12.1',
|
||||
'version' => '0.12.3',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('oauth_auth_codes', function (Blueprint $table) {
|
||||
$table->string('id', 100)->primary();
|
||||
$table->unsignedBigInteger('user_id')->index();
|
||||
$table->unsignedBigInteger('client_id');
|
||||
$table->text('scopes')->nullable();
|
||||
$table->boolean('revoked');
|
||||
$table->dateTime('expires_at')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('oauth_auth_codes');
|
||||
}
|
||||
};
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('oauth_access_tokens', function (Blueprint $table) {
|
||||
$table->string('id', 100)->primary();
|
||||
$table->unsignedBigInteger('user_id')->nullable()->index();
|
||||
$table->unsignedBigInteger('client_id');
|
||||
$table->string('name')->nullable();
|
||||
$table->text('scopes')->nullable();
|
||||
$table->boolean('revoked');
|
||||
$table->timestamps();
|
||||
$table->dateTime('expires_at')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('oauth_access_tokens');
|
||||
}
|
||||
};
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('oauth_refresh_tokens', function (Blueprint $table) {
|
||||
$table->string('id', 100)->primary();
|
||||
$table->string('access_token_id', 100)->index();
|
||||
$table->boolean('revoked');
|
||||
$table->dateTime('expires_at')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('oauth_refresh_tokens');
|
||||
}
|
||||
};
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('oauth_clients', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->unsignedBigInteger('user_id')->nullable()->index();
|
||||
$table->string('name');
|
||||
$table->string('secret', 100)->nullable();
|
||||
$table->string('provider')->nullable();
|
||||
$table->text('redirect');
|
||||
$table->boolean('personal_access_client');
|
||||
$table->boolean('password_client');
|
||||
$table->boolean('revoked');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('oauth_clients');
|
||||
}
|
||||
};
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('oauth_personal_access_clients', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->unsignedBigInteger('client_id');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('oauth_personal_access_clients');
|
||||
}
|
||||
};
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Get the migration connection name.
|
||||
*/
|
||||
public function getConnection(): ?string
|
||||
{
|
||||
return config('telescope.storage.database.connection');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$schema = Schema::connection($this->getConnection());
|
||||
|
||||
$schema->create('telescope_entries', function (Blueprint $table) {
|
||||
$table->bigIncrements('sequence');
|
||||
$table->uuid('uuid');
|
||||
$table->uuid('batch_id');
|
||||
$table->string('family_hash')->nullable();
|
||||
$table->boolean('should_display_on_index')->default(true);
|
||||
$table->string('type', 20);
|
||||
$table->longText('content');
|
||||
$table->dateTime('created_at')->nullable();
|
||||
|
||||
$table->unique('uuid');
|
||||
$table->index('batch_id');
|
||||
$table->index('family_hash');
|
||||
$table->index('created_at');
|
||||
$table->index(['type', 'should_display_on_index']);
|
||||
});
|
||||
|
||||
$schema->create('telescope_entries_tags', function (Blueprint $table) {
|
||||
$table->uuid('entry_uuid');
|
||||
$table->string('tag');
|
||||
|
||||
$table->primary(['entry_uuid', 'tag']);
|
||||
$table->index('tag');
|
||||
|
||||
$table->foreign('entry_uuid')
|
||||
->references('uuid')
|
||||
->on('telescope_entries')
|
||||
->onDelete('cascade');
|
||||
});
|
||||
|
||||
$schema->create('telescope_monitoring', function (Blueprint $table) {
|
||||
$table->string('tag')->primary();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
$schema = Schema::connection($this->getConnection());
|
||||
|
||||
$schema->dropIfExists('telescope_entries_tags');
|
||||
$schema->dropIfExists('telescope_entries');
|
||||
$schema->dropIfExists('telescope_monitoring');
|
||||
}
|
||||
};
|
|
@ -5,13 +5,6 @@ use Illuminate\Support\Facades\Schema;
|
|||
|
||||
class UpdateStatusTableChangeCaptionToText extends Migration
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
DB::getDoctrineSchemaManager()
|
||||
->getDatabasePlatform()
|
||||
->registerDoctrineTypeMapping('enum', 'string');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
|
|
|
@ -6,11 +6,6 @@ use Illuminate\Database\Migrations\Migration;
|
|||
|
||||
class AddSnowflakeidsToUsersTable extends Migration
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
DB::getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
|
|
|
@ -6,11 +6,6 @@ use Illuminate\Database\Migrations\Migration;
|
|||
|
||||
class AddLayoutToProfilesTable extends Migration
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
DB::getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
|
|
|
@ -6,11 +6,6 @@ use Illuminate\Database\Migrations\Migration;
|
|||
|
||||
class AddSnowflakeIdsToCollectionsTable extends Migration
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
DB::getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
|
|
|
@ -6,11 +6,6 @@ use Illuminate\Database\Migrations\Migration;
|
|||
|
||||
class AddUniqueToStatusesTable extends Migration
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
DB::getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
|
|
|
@ -6,11 +6,6 @@ use Illuminate\Database\Migrations\Migration;
|
|||
|
||||
class AddObjectIdToStatusesTable extends Migration
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
DB::getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
|
|
|
@ -6,10 +6,6 @@ use Illuminate\Support\Facades\Schema;
|
|||
|
||||
class UpdateStoriesTable extends Migration
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
DB::getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
|
||||
}
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
|
|
|
@ -41,15 +41,15 @@ class AddComposeSettingsToUserSettingsTable extends Migration
|
|||
Schema::table('media', function (Blueprint $table) {
|
||||
$table->string('caption')->change();
|
||||
|
||||
$schemaManager = Schema::getConnection()->getDoctrineSchemaManager();
|
||||
$indexesFound = $schemaManager->listTableIndexes('media');
|
||||
if (array_key_exists('media_profile_id_index', $indexesFound)) {
|
||||
$indexes = Schema::getIndexes('media');
|
||||
$indexesFound = collect($indexes)->map(function($i) { return $i['name']; })->toArray();
|
||||
if (in_array('media_profile_id_index', $indexesFound)) {
|
||||
$table->dropIndex('media_profile_id_index');
|
||||
}
|
||||
if (array_key_exists('media_mime_index', $indexesFound)) {
|
||||
if (in_array('media_mime_index', $indexesFound)) {
|
||||
$table->dropIndex('media_mime_index');
|
||||
}
|
||||
if (array_key_exists('media_license_index', $indexesFound)) {
|
||||
if (in_array('media_license_index', $indexesFound)) {
|
||||
$table->dropIndex('media_license_index');
|
||||
}
|
||||
});
|
||||
|
|
|
@ -14,10 +14,9 @@ class UpdateStoriesTableFixExpiresAtColumn extends Migration
|
|||
public function up()
|
||||
{
|
||||
Schema::table('stories', function (Blueprint $table) {
|
||||
$sm = Schema::getConnection()->getDoctrineSchemaManager();
|
||||
$doctrineTable = $sm->listTableDetails('stories');
|
||||
|
||||
if($doctrineTable->hasIndex('stories_expires_at_index')) {
|
||||
$indexes = Schema::getIndexes('stories');
|
||||
$indexesFound = collect($indexes)->map(function($i) { return $i['name']; })->toArray();
|
||||
if (in_array('stories_expires_at_index', $indexesFound)) {
|
||||
$table->dropIndex('stories_expires_at_index');
|
||||
}
|
||||
$table->timestamp('expires_at')->default(null)->index()->nullable()->change();
|
||||
|
@ -37,10 +36,9 @@ class UpdateStoriesTableFixExpiresAtColumn extends Migration
|
|||
public function down()
|
||||
{
|
||||
Schema::table('stories', function (Blueprint $table) {
|
||||
$sm = Schema::getConnection()->getDoctrineSchemaManager();
|
||||
$doctrineTable = $sm->listTableDetails('stories');
|
||||
|
||||
if($doctrineTable->hasIndex('stories_expires_at_index')) {
|
||||
$indexes = Schema::getIndexes('stories');
|
||||
$indexesFound = collect($indexes)->map(function($i) { return $i['name']; })->toArray();
|
||||
if (in_array('stories_expires_at_index', $indexesFound)) {
|
||||
$table->dropIndex('stories_expires_at_index');
|
||||
}
|
||||
$table->timestamp('expires_at')->default(null)->index()->nullable()->change();
|
||||
|
|
|
@ -14,8 +14,9 @@ class RemoveOldCompoundIndexFromStatusesTable extends Migration
|
|||
public function up()
|
||||
{
|
||||
Schema::table('statuses', function (Blueprint $table) {
|
||||
$sc = Schema::getConnection()->getDoctrineSchemaManager();
|
||||
if(array_key_exists('statuses_in_reply_to_id_reblog_of_id_index', $sc->listTableIndexes('statuses'))) {
|
||||
$indexes = Schema::getIndexes('statuses');
|
||||
$indexesFound = collect($indexes)->map(function($i) { return $i['name']; })->toArray();
|
||||
if (in_array('statuses_in_reply_to_id_reblog_of_id_index', $indexesFound)) {
|
||||
$table->dropIndex('statuses_in_reply_to_id_reblog_of_id_index');
|
||||
}
|
||||
});
|
||||
|
|
|
@ -14,9 +14,9 @@ return new class extends Migration
|
|||
public function up()
|
||||
{
|
||||
Schema::table('avatars', function (Blueprint $table) {
|
||||
$sm = Schema::getConnection()->getDoctrineSchemaManager();
|
||||
$indexesFound = $sm->listTableIndexes('avatars');
|
||||
if(array_key_exists("avatars_cdn_url_unique", $indexesFound)) {
|
||||
$indexes = Schema::getIndexes('avatars');
|
||||
$indexesFound = collect($indexes)->map(function($i) { return $i['name']; })->toArray();
|
||||
if (in_array('avatars_cdn_url_unique', $indexesFound)) {
|
||||
$table->dropUnique('avatars_cdn_url_unique');
|
||||
}
|
||||
});
|
||||
|
|
|
@ -25,9 +25,9 @@ return new class extends Migration
|
|||
});
|
||||
|
||||
Schema::table('user_roles', function (Blueprint $table) {
|
||||
$schemaManager = Schema::getConnection()->getDoctrineSchemaManager();
|
||||
$indexesFound = $schemaManager->listTableIndexes('user_roles');
|
||||
if (array_key_exists('user_roles_profile_id_unique', $indexesFound)) {
|
||||
$indexes = Schema::getIndexes('user_roles');
|
||||
$indexesFound = collect($indexes)->map(function($i) { return $i['name']; })->toArray();
|
||||
if (in_array('user_roles_profile_id_unique', $indexesFound)) {
|
||||
$table->dropUnique('user_roles_profile_id_unique');
|
||||
}
|
||||
$table->unsignedBigInteger('profile_id')->unique()->nullable()->index()->change();
|
||||
|
@ -42,9 +42,9 @@ return new class extends Migration
|
|||
Schema::dropIfExists('parental_controls');
|
||||
|
||||
Schema::table('user_roles', function (Blueprint $table) {
|
||||
$schemaManager = Schema::getConnection()->getDoctrineSchemaManager();
|
||||
$indexesFound = $schemaManager->listTableIndexes('user_roles');
|
||||
if (array_key_exists('user_roles_profile_id_unique', $indexesFound)) {
|
||||
$indexes = Schema::getIndexes('user_roles');
|
||||
$indexesFound = collect($indexes)->map(function($i) { return $i['name']; })->toArray();
|
||||
if (in_array('user_roles_profile_id_unique', $indexesFound)) {
|
||||
$table->dropUnique('user_roles_profile_id_unique');
|
||||
}
|
||||
$table->unsignedBigInteger('profile_id')->unique()->index()->change();
|
||||
|
|
|
@ -12,9 +12,9 @@ return new class extends Migration
|
|||
public function up(): void
|
||||
{
|
||||
Schema::table('instances', function (Blueprint $table) {
|
||||
$schemaManager = Schema::getConnection()->getDoctrineSchemaManager();
|
||||
$indexesFound = $schemaManager->listTableIndexes('instances');
|
||||
if (! array_key_exists('instances_nodeinfo_last_fetched_index', $indexesFound)) {
|
||||
$indexes = Schema::getIndexes('instances');
|
||||
$indexesFound = collect($indexes)->map(function($i) { return $i['name']; })->toArray();
|
||||
if (!in_array('instances_nodeinfo_last_fetched_index', $indexesFound)) {
|
||||
$table->index('nodeinfo_last_fetched');
|
||||
}
|
||||
});
|
||||
|
@ -26,9 +26,9 @@ return new class extends Migration
|
|||
public function down(): void
|
||||
{
|
||||
Schema::table('instances', function (Blueprint $table) {
|
||||
$schemaManager = Schema::getConnection()->getDoctrineSchemaManager();
|
||||
$indexesFound = $schemaManager->listTableIndexes('instances');
|
||||
if (array_key_exists('instances_nodeinfo_last_fetched_index', $indexesFound)) {
|
||||
$indexes = Schema::getIndexes('instances');
|
||||
$indexesFound = collect($indexes)->map(function($i) { return $i['name']; })->toArray();
|
||||
if (in_array('instances_nodeinfo_last_fetched_index', $indexesFound)) {
|
||||
$table->dropIndex('instances_nodeinfo_last_fetched_index');
|
||||
}
|
||||
});
|
||||
|
|
|
@ -12,9 +12,9 @@ return new class extends Migration
|
|||
public function up(): void
|
||||
{
|
||||
Schema::table('statuses', function (Blueprint $table) {
|
||||
$schemaManager = Schema::getConnection()->getDoctrineSchemaManager();
|
||||
$indexesFound = $schemaManager->listTableIndexes('statuses');
|
||||
if (! array_key_exists('statuses_url_index', $indexesFound)) {
|
||||
$indexes = Schema::getIndexes('statuses');
|
||||
$indexesFound = collect($indexes)->map(function($i) { return $i['name']; })->toArray();
|
||||
if (!in_array('statuses_url_index', $indexesFound)) {
|
||||
$table->index('url');
|
||||
}
|
||||
});
|
||||
|
@ -26,9 +26,9 @@ return new class extends Migration
|
|||
public function down(): void
|
||||
{
|
||||
Schema::table('statuses', function (Blueprint $table) {
|
||||
$schemaManager = Schema::getConnection()->getDoctrineSchemaManager();
|
||||
$indexesFound = $schemaManager->listTableIndexes('statuses');
|
||||
if (array_key_exists('statuses_url_index', $indexesFound)) {
|
||||
$indexes = Schema::getIndexes('statuses');
|
||||
$indexesFound = collect($indexes)->map(function($i) { return $i['name']; })->toArray();
|
||||
if (in_array('statuses_url_index', $indexesFound)) {
|
||||
$table->dropIndex('statuses_url_index');
|
||||
}
|
||||
});
|
||||
|
|
45
resources/views/admin/settings/customcss.blade.php
Normal file
45
resources/views/admin/settings/customcss.blade.php
Normal file
|
@ -0,0 +1,45 @@
|
|||
@extends('admin.partial.template-full')
|
||||
|
||||
@section('section')
|
||||
</div>
|
||||
<div class="header bg-primary pb-3 mt-n4">
|
||||
<div class="container-fluid">
|
||||
<div class="header-body">
|
||||
<div class="row align-items-center py-4">
|
||||
<div class="col-lg-6 col-7">
|
||||
<p class="display-1 text-white d-inline-block mb-0">Custom CSS</p>
|
||||
<p class="lead mb-0 text-white">Customize your instance with custom css.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container-fluid mt-4">
|
||||
<div class="col-12 col-md-6">
|
||||
<form method="post">
|
||||
@csrf
|
||||
<div class="form-group">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input
|
||||
type="checkbox"
|
||||
name="show"
|
||||
class="custom-control-input"
|
||||
id="customCheck1"
|
||||
{{ (bool) config_cache('uikit.show_custom.css') ? 'checked' : null}}
|
||||
>
|
||||
<label class="custom-control-label" for="customCheck1">Enable Custom CSS</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="css" class="font-weight-bold">Custom CSS</label>
|
||||
<textarea
|
||||
class="form-control"
|
||||
id="css"
|
||||
name="css"
|
||||
rows="5">{!!config_cache('uikit.custom.css')!!}</textarea>
|
||||
</div>
|
||||
<button class="btn btn-primary">Save</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
|
@ -177,6 +177,7 @@ Route::group(['prefix' => 'api'], function() use($middleware) {
|
|||
Route::get('accounts/popular', 'Api\ApiV1Controller@discoverAccountsPopular')->middleware($middleware);
|
||||
Route::get('posts/trending', 'DiscoverController@trendingApi')->middleware($middleware);
|
||||
Route::get('posts/hashtags', 'DiscoverController@trendingHashtags')->middleware($middleware);
|
||||
Route::get('posts/network/trending', 'DiscoverController@discoverNetworkTrending')->middleware($middleware);
|
||||
});
|
||||
|
||||
Route::group(['prefix' => 'directory'], function () use($middleware) {
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
Route::domain(config('pixelfed.domain.admin'))->prefix('i/admin')->group(function () {
|
||||
Route::redirect('/', '/dashboard');
|
||||
Route::redirect('timeline', config('app.url').'/timeline');
|
||||
Route::get('settings/custom-css', 'AdminController@customCss')->name('admin.custom-css');
|
||||
Route::post('settings/custom-css', 'AdminController@saveCustomCss');
|
||||
Route::get('dashboard', 'AdminController@home')->name('admin.home');
|
||||
Route::get('stats', 'AdminController@stats')->name('admin.stats');
|
||||
Route::get('reports', 'AdminController@reports')->name('admin.reports');
|
||||
|
|
Loading…
Reference in a new issue