fix: multiple bugs

This commit is contained in:
HDVinnie
2023-03-19 19:11:46 -04:00
parent 480c7093a2
commit 40db300774
7 changed files with 42 additions and 58 deletions
+5 -3
View File
@@ -215,11 +215,13 @@ class TopicController extends Controller
$topic = Topic::findOrFail($id);
abort_unless($user->group->is_modo || $user->id === $topic->first_post_user_id, 403);
$topic->name = $request->name;
$forum = Forum::findOrFail($request->forum_id);
$forum = Forum::findOrFail($request->input('forum_id'));
if ($forum->getPermission()->start_topic) {
$topic->forum_id = $request->forum->id;
$topic->name = $request->input('name');
$topic->forum_id = $forum->id;
$topic->save();
} else {
return to_route('forums.index')
->withErrors('You Cannot Start A New Topic Here!');
+1
View File
@@ -46,6 +46,7 @@ class TopicPostSearch extends Component
'likes' => fn ($query) => $query->where('like', '=', 1),
'likes as dislike_count' => fn ($query) => $query->where('dislike', '=', 1),
])
->withSum('tips', 'cost')
->where('topic_id', '=', $this->topic->id)
->join('topics', 'topics.id', '=', 'posts.topic_id')
->join(
+27 -48
View File
@@ -80,10 +80,10 @@ class TorrentRequestSearch extends Component
'imdbId' => ['except' => ''],
'tvdbId' => ['except' => ''],
'malId' => ['except' => ''],
'unfilled' => ['except' => false],
'unfilled' => ['except' => false],
'claimed' => ['except' => false],
'pending' => ['except' => false],
'filled' => ['except' => false],
'filled' => ['except' => false],
'myRequests' => ['except' => false],
'myClaims' => ['except' => false],
'myVoted' => ['except' => false],
@@ -128,46 +128,25 @@ class TorrentRequestSearch extends Component
final public function getTorrentRequestsProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator
{
$user = auth()->user();
$isRegexAllowed = $user->group->is_modo;
$isRegex = fn ($field) => $isRegexAllowed
&& \strlen($field) > 2
&& $field[0] === '/'
&& $field[-1] === '/'
&& @preg_match($field, 'Validate regex') !== false;
return TorrentRequest::with(['category', 'type', 'resolution'])
->withCount(['comments'])
->when($this->name, function ($query): void {
$query->where('name', 'LIKE', '%'.$this->name.'%');
})
->when($this->requestor, function ($query): void {
$match = User::where('username', 'LIKE', '%'.$this->requestor.'%')->oldest('username')->first();
if ($match) {
$query
->where('user_id', '=', $match->id)
->when(! (auth()->user()->group->is_modo || auth()->user()->id === $match->id), function ($query): void {
$query->where('anon', '=', 0);
});
}
})
->when($this->categories, function ($query): void {
$query->whereIntegerInRaw('category_id', $this->categories);
})
->when($this->types, function ($query): void {
$query->whereIntegerInRaw('type_id', $this->types);
})
->when($this->resolutions, function ($query): void {
$query->whereIntegerInRaw('resolution_id', $this->resolutions);
})
->when($this->tmdbId, function ($query): void {
$query->where('tmdb', '=', $this->tmdbId);
})
->when($this->imdbId, function ($query): void {
if (preg_match('/tt0*?(?=(\d{7,8}))/', $this->imdbId, $matches)) {
$query->where('imdb', '=', $matches[1]);
} else {
$query->where('imdb', '=', $this->imdbId);
}
})
->when($this->tvdbId, function ($query): void {
$query->where('tvdb', '=', $this->tvdbId);
})
->when($this->malId, function ($query): void {
$query->where('mal', '=', $this->malId);
})
->when($this->name !== '', fn ($query) => $query->ofName($this->name, $isRegex($this->name)))
->when($this->requestor !== '', fn ($query) => $query->ofUploader($this->requestor))
->when($this->categories !== [], fn ($query) => $query->ofCategory($this->categories))
->when($this->types !== [], fn ($query) => $query->ofType($this->types))
->when($this->resolutions !== [], fn ($query) => $query->ofResolution($this->resolutions))
->when($this->tmdbId !== '', fn ($query) => $query->ofTmdb((int) $this->tmdbId))
->when($this->imdbId !== '', fn ($query) => $query->ofImdb((int) (preg_match('/tt0*(?=(\d{7,}))/', $this->imdbId, $matches) ? $matches[1] : $this->imdbId)))
->when($this->tvdbId !== '', fn ($query) => $query->ofTvdb((int) $this->tvdbId))
->when($this->malId !== '', fn ($query) => $query->ofMal((int) $this->malId))
->when($this->unfilled || $this->claimed || $this->pending || $this->filled, function ($query): void {
$query->where(function ($query): void {
$query->where(function ($query): void {
@@ -192,19 +171,19 @@ class TorrentRequestSearch extends Component
});
});
})
->when($this->myRequests, function ($query): void {
$query->where('user_id', '=', auth()->user()->id);
->when($this->myRequests, function ($query) use ($user): void {
$query->where('user_id', '=', $user->id);
})
->when($this->myClaims, function ($query): void {
$requestClaims = TorrentRequestClaim::where('username', '=', auth()->user()->username)->pluck('request_id');
->when($this->myClaims, function ($query) use ($user): void {
$requestClaims = TorrentRequestClaim::where('username', '=', $user->username)->pluck('request_id');
$query->whereIntegerInRaw('id', $requestClaims)->whereNull('torrent_id')->whereNull('approved_by');
})
->when($this->myVoted, function ($query): void {
$requestVotes = TorrentRequestBounty::where('user_id', '=', auth()->user()->id)->pluck('requests_id');
->when($this->myVoted, function ($query) use ($user): void {
$requestVotes = TorrentRequestBounty::where('user_id', '=', $user->id)->pluck('requests_id');
$query->whereIntegerInRaw('id', $requestVotes);
})
->when($this->myFilled, function ($query): void {
$query->where('filled_by', '=', auth()->user()->id);
->when($this->myFilled, function ($query) use ($user): void {
$query->where('filled_by', '=', $user->id);
})
->orderBy($this->sortField, $this->sortDirection)
->paginate($this->perPage);
+2
View File
@@ -17,6 +17,7 @@ use App\Helpers\Bbcode;
use App\Helpers\Linkify;
use App\Notifications\NewComment;
use App\Traits\Auditable;
use App\Traits\TorrentFilter;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use voku\helper\AntiXSS;
@@ -25,6 +26,7 @@ class TorrentRequest extends Model
{
use Auditable;
use HasFactory;
use TorrentFilter;
/**
* The Attributes That Should Be Mutated To Dates.
@@ -102,8 +102,8 @@ export default {
e.preventDefault();
let target = e.target.hash;
const tmp = target.split('/');
$('#chat-message').bbcode('/' + tmp[1] + ' ' + tmp[2] + ' ');
$('#chat-message').htmlcode('/' + tmp[1] + ' ' + tmp[2] + ' ');
$('#chat-message').val('/' + tmp[1] + ' ' + tmp[2] + ' ');
$('#chat-message').val('/' + tmp[1] + ' ' + tmp[2] + ' ');
}
},
canMod(message) {
+4 -4
View File
@@ -570,12 +570,12 @@ export default {
});
},
forceMessage(name) {
$('#chat-message').bbcode('/msg ' + name + ' ');
$('#chat-message').htmlcode('/msg ' + name + ' ');
$('#chat-message').val('/msg ' + name + ' ');
$('#chat-message').val('/msg ' + name + ' ');
},
forceGift(name) {
$('#chat-message').bbcode('/gift ' + name + ' ');
$('#chat-message').htmlcode('/gift ' + name + ' ');
$('#chat-message').val('/gift ' + name + ' ');
$('#chat-message').val('/gift ' + name + ' ');
},
freezeChat() {
this.frozen = true;
+1 -1
View File
@@ -77,7 +77,7 @@
<select name="user_id" class="form__select" x-on:change="$root.submit()">
<option hidden disabled selected value=""></option>
@foreach(App\Models\User::select(['id', 'username'])->whereIn('group_id', App\Models\Group::where('is_modo', 1)->whereNotIn('id', [9])->pluck('id')->toArray())->get() as $user)
<option value="{{ $user->id }}" @selected($user->id = $ticket->staff_id)>
<option value="{{ $user->id }}" @selected($user->id === $ticket->staff_id)>
{{ $user->username }}
</option>
@endforeach