mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Various code reshuffelling.
This commit is contained in:
@@ -65,6 +65,64 @@ class WebhookRepository implements WebhookRepositoryInterface
|
||||
return $this->user->webhooks()->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function destroy(Webhook $webhook): void
|
||||
{
|
||||
$webhook->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function destroyAttempt(WebhookAttempt $attempt): void
|
||||
{
|
||||
$attempt->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function destroyMessage(WebhookMessage $message): void
|
||||
{
|
||||
$message->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getAttempts(WebhookMessage $webhookMessage): Collection
|
||||
{
|
||||
return $webhookMessage->webhookAttempts()->orderBy('created_at', 'DESC')->get(['webhook_attempts.*']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getMessages(Webhook $webhook): Collection
|
||||
{
|
||||
return $webhook->webhookMessages()
|
||||
->orderBy('created_at', 'DESC')
|
||||
->get(['webhook_messages.*']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getReadyMessages(Webhook $webhook): Collection
|
||||
{
|
||||
return $webhook->webhookMessages()
|
||||
->where('webhook_messages.sent', 0)
|
||||
->where('webhook_messages.errored', 0)
|
||||
->get(['webhook_messages.*'])
|
||||
->filter(
|
||||
function (WebhookMessage $message) {
|
||||
return $message->webhookAttempts()->count() <= 2;
|
||||
}
|
||||
)->splice(0, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@@ -114,62 +172,4 @@ class WebhookRepository implements WebhookRepositoryInterface
|
||||
|
||||
return $webhook;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function destroy(Webhook $webhook): void
|
||||
{
|
||||
$webhook->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function destroyMessage(WebhookMessage $message): void
|
||||
{
|
||||
$message->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function destroyAttempt(WebhookAttempt $attempt): void
|
||||
{
|
||||
$attempt->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getReadyMessages(Webhook $webhook): Collection
|
||||
{
|
||||
return $webhook->webhookMessages()
|
||||
->where('webhook_messages.sent', 0)
|
||||
->where('webhook_messages.errored', 0)
|
||||
->get(['webhook_messages.*'])
|
||||
->filter(
|
||||
function (WebhookMessage $message) {
|
||||
return $message->webhookAttempts()->count() <= 2;
|
||||
}
|
||||
)->splice(0, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getMessages(Webhook $webhook): Collection
|
||||
{
|
||||
return $webhook->webhookMessages()
|
||||
->orderBy('created_at', 'DESC')
|
||||
->get(['webhook_messages.*']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getAttempts(WebhookMessage $webhookMessage): Collection
|
||||
{
|
||||
return $webhookMessage->webhookAttempts()->orderBy('created_at', 'DESC')->get(['webhook_attempts.*']);
|
||||
}
|
||||
}
|
||||
|
@@ -61,6 +61,42 @@ interface WebhookRepositoryInterface
|
||||
*/
|
||||
public function all(): Collection;
|
||||
|
||||
/**
|
||||
* @param Webhook $webhook
|
||||
*/
|
||||
public function destroy(Webhook $webhook): void;
|
||||
|
||||
/**
|
||||
* @param WebhookAttempt $attempt
|
||||
*/
|
||||
public function destroyAttempt(WebhookAttempt $attempt): void;
|
||||
|
||||
/**
|
||||
* @param WebhookMessage $message
|
||||
*/
|
||||
public function destroyMessage(WebhookMessage $message): void;
|
||||
|
||||
/**
|
||||
* @param WebhookMessage $webhookMessage
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getAttempts(WebhookMessage $webhookMessage): Collection;
|
||||
|
||||
/**
|
||||
* @param Webhook $webhook
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getMessages(Webhook $webhook): Collection;
|
||||
|
||||
/**
|
||||
* @param Webhook $webhook
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getReadyMessages(Webhook $webhook): Collection;
|
||||
|
||||
/**
|
||||
* Set user.
|
||||
*
|
||||
@@ -83,40 +119,4 @@ interface WebhookRepositoryInterface
|
||||
*/
|
||||
public function update(Webhook $webhook, array $data): Webhook;
|
||||
|
||||
/**
|
||||
* @param Webhook $webhook
|
||||
*/
|
||||
public function destroy(Webhook $webhook): void;
|
||||
|
||||
/**
|
||||
* @param WebhookMessage $message
|
||||
*/
|
||||
public function destroyMessage(WebhookMessage $message): void;
|
||||
|
||||
/**
|
||||
* @param WebhookAttempt $attempt
|
||||
*/
|
||||
public function destroyAttempt(WebhookAttempt $attempt): void;
|
||||
|
||||
/**
|
||||
* @param Webhook $webhook
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getReadyMessages(Webhook $webhook): Collection;
|
||||
|
||||
/**
|
||||
* @param Webhook $webhook
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getMessages(Webhook $webhook): Collection;
|
||||
|
||||
/**
|
||||
* @param WebhookMessage $webhookMessage
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function getAttempts(WebhookMessage $webhookMessage): Collection;
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user