diff --git a/.env.example.ini b/.env.example.ini index 52c9b5a..f166ada 100755 --- a/.env.example.ini +++ b/.env.example.ini @@ -11,5 +11,5 @@ reply_average_hours = 0; available_from_hour = 0; [service_forgejo] -base_url = "" -scan_profiles = "" \ No newline at end of file +url = "" +profiles = "" \ No newline at end of file diff --git a/api/coffee/DELETE.php b/api/coffee/DELETE.php new file mode 100644 index 0000000..251ad37 --- /dev/null +++ b/api/coffee/DELETE.php @@ -0,0 +1,30 @@ +GET([ + new Rules(CoffeeTable::ID->value) + ->required() + ->type(Type::STRING) + ->min(UUID::LENGTH) + ->max(UUID::LENGTH) + ])); + } + + public function main(): Response { + return new Response(new Coffee($_GET[CoffeeTable::ID->value])->delete()); + } + } \ No newline at end of file diff --git a/api/coffee/GET.php b/api/coffee/GET.php new file mode 100644 index 0000000..b3387c7 --- /dev/null +++ b/api/coffee/GET.php @@ -0,0 +1,19 @@ +POST([ + new Rules(CoffeeTable::DATE_CREATED->value) + ->type(Type::STRING) + ->default(null) + ])); + } + + public function main(): Response { + $datetime = new DateTimeImmutable(); + + // Parse DateTime from POST string + if ($_POST[CoffeeTable::DATE_CREATED->value]) { + try { + $datetime = new DateTimeImmutable($_POST[CoffeeTable::DATE_CREATED->value]); + } catch (DateMalformedStringException $error) { + return new Response($error->getMessage(), 400); + } + } + + return new Response(Coffee::new($datetime)); + } + } \ No newline at end of file diff --git a/api/languages/GET.php b/api/languages/GET.php new file mode 100644 index 0000000..cc667a3 --- /dev/null +++ b/api/languages/GET.php @@ -0,0 +1,19 @@ +generate(); - } - public function main(): Response { switch ($_GET[self::KEY_SERVICE]) { + case ServiceEnum::FORGEJO->value: + return new Response($this->update_forgejo()); + case ServiceEnum::TIMELINE->value: - return new Response("OK"); + return new Response($this->update_timeline()); case ServiceEnum::ALL->value: default: - return new Response($this->update_timeline()); + return new Response( + $this->update_timeline() && + $this->update_forgejo() + ); } } + + private function update_timeline(): bool { + return new GenerateTimeline()->generate(); + } + + private function update_forgejo(): bool { + return new Forgejo()->update(); + } } \ No newline at end of file diff --git a/public/contact.php b/public/contact.php index c76edef..4def19f 100644 --- a/public/contact.php +++ b/public/contact.php @@ -1,18 +1,15 @@ hour() >= $_ENV["client_time_available"]["available_from_hour"] && $this->hour() < $_ENV["client_time_available"]["available_to_hour"]; + return $this->hour() >= $_ENV["config_time_available"]["available_from_hour"] && $this->hour() < $_ENV["config_time_available"]["available_to_hour"]; } public function get_estimated_reply_hours(): int { // I'm available! Return the estimated reply time for that if ($this->is_available()) { - return $_ENV["client_time_available"]["reply_average_hours"]; + return $_ENV["config_time_available"]["reply_average_hours"]; } - return $this->hour() < $_ENV["client_time_available"]["available_from_hour"] + return $this->hour() < $_ENV["config_time_available"]["available_from_hour"] // Return hours past midnight until I become available (clamped to estimated reply hours) - ? max($_ENV["client_time_available"]["available_from_hour"] - $this->hour(), $_ENV["client_time_available"]["reply_average_hours"]) + ? max($_ENV["config_time_available"]["available_from_hour"] - $this->hour(), $_ENV["config_time_available"]["reply_average_hours"]) // Return hours before midnight until I become available (clamped to estimated reply hours) - : max($_ENV["client_time_available"]["available_from_hour"] + (24 - $this->hour()), $_ENV["client_time_available"]["reply_average_hours"]); + : max($_ENV["config_time_available"]["available_from_hour"] + (24 - $this->hour()), $_ENV["config_time_available"]["reply_average_hours"]); } } @@ -84,18 +81,9 @@ + name] ?? "", $_POST[Messages::EMAIL->name] ?? null); ?> - call(Endpoints::MESSAGES->value)->post([ - MessagesTable::EMAIL->value => $_POST[MessagesTable::EMAIL->value], - MessagesTable::MESSAGE->value => $_POST[MessagesTable::MESSAGE->value] - ]); - - ?> - - ok): ?> + date_created): ?>

🙏 Message sent!

@@ -103,8 +91,6 @@

😟 Oh no, something went wrong

-

Response from API:

-
output() ?>
@@ -113,11 +99,11 @@
- + - +