mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 16:57:09 +00:00
Code cleanup
This commit is contained in:
@@ -29,7 +29,6 @@ use FireflyIII\Models\WebhookAttempt;
|
||||
use FireflyIII\Models\WebhookMessage;
|
||||
use FireflyIII\Repositories\Webhook\WebhookRepositoryInterface;
|
||||
use FireflyIII\Transformers\WebhookAttemptTransformer;
|
||||
use FireflyIII\Transformers\WebhookMessageTransformer;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
@@ -42,8 +41,8 @@ use League\Fractal\Resource\Item;
|
||||
*/
|
||||
class AttemptController extends Controller
|
||||
{
|
||||
private WebhookRepositoryInterface $repository;
|
||||
public const RESOURCE_KEY = 'webhook_attempts';
|
||||
private WebhookRepositoryInterface $repository;
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
@@ -108,10 +107,10 @@ class AttemptController extends Controller
|
||||
*/
|
||||
public function show(Webhook $webhook, WebhookMessage $message, WebhookAttempt $attempt): JsonResponse
|
||||
{
|
||||
if($message->webhook_id !== $webhook->id) {
|
||||
if ($message->webhook_id !== $webhook->id) {
|
||||
throw new FireflyException('Webhook and webhook message are no match');
|
||||
}
|
||||
if($attempt->webhook_message_id !== $message->id) {
|
||||
if ($attempt->webhook_message_id !== $message->id) {
|
||||
throw new FireflyException('Webhook message and webhook attempt are no match');
|
||||
|
||||
}
|
||||
|
@@ -103,12 +103,17 @@ class DestroyController extends Controller
|
||||
* @return JsonResponse
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function destroyMessage(Webhook $webhook, WebhookMessage $message): JsonResponse
|
||||
public function destroyAttempt(Webhook $webhook, WebhookMessage $message, WebhookAttempt $attempt): JsonResponse
|
||||
{
|
||||
if ($message->webhook_id !== $webhook->id) {
|
||||
throw new FireflyException('Webhook and webhook message are no match');
|
||||
}
|
||||
$this->repository->destroyMessage($message);
|
||||
if ($attempt->webhook_message_id !== $message->id) {
|
||||
throw new FireflyException('Webhook message and webhook attempt are no match');
|
||||
|
||||
}
|
||||
|
||||
$this->repository->destroyAttempt($attempt);
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
@@ -121,21 +126,15 @@ class DestroyController extends Controller
|
||||
* @return JsonResponse
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function destroyAttempt(Webhook $webhook, WebhookMessage $message, WebhookAttempt $attempt): JsonResponse
|
||||
public function destroyMessage(Webhook $webhook, WebhookMessage $message): JsonResponse
|
||||
{
|
||||
if ($message->webhook_id !== $webhook->id) {
|
||||
throw new FireflyException('Webhook and webhook message are no match');
|
||||
}
|
||||
if($attempt->webhook_message_id !== $message->id) {
|
||||
throw new FireflyException('Webhook message and webhook attempt are no match');
|
||||
|
||||
}
|
||||
|
||||
$this->repository->destroyAttempt($attempt);
|
||||
$this->repository->destroyMessage($message);
|
||||
|
||||
return response()->json([], 204);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@@ -71,7 +71,7 @@ class MessageController extends Controller
|
||||
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
||||
$collection = $this->repository->getMessages($webhook);
|
||||
|
||||
$count = $collection->count();
|
||||
$count = $collection->count();
|
||||
$messages = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
||||
|
||||
// make paginator:
|
||||
@@ -99,7 +99,7 @@ class MessageController extends Controller
|
||||
*/
|
||||
public function show(Webhook $webhook, WebhookMessage $message): JsonResponse
|
||||
{
|
||||
if($message->webhook_id !== $webhook->id) {
|
||||
if ($message->webhook_id !== $webhook->id) {
|
||||
throw new FireflyException('Webhook and webhook message are no match');
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user