From dd65245caa4590327319790b8e60158a3bcdb886 Mon Sep 17 00:00:00 2001 From: Oleh Astappiev Date: Fri, 9 Aug 2024 18:54:39 +0200 Subject: [PATCH] fix: deploy config error --- .../l3s/interweb/server/features/user/UsersResource.java | 8 +++++--- .../src/main/resources/db/migration/V1.0.0__Interweb.sql | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/interweb-server/src/main/java/de/l3s/interweb/server/features/user/UsersResource.java b/interweb-server/src/main/java/de/l3s/interweb/server/features/user/UsersResource.java index 7f80c132..6fd88597 100644 --- a/interweb-server/src/main/java/de/l3s/interweb/server/features/user/UsersResource.java +++ b/interweb-server/src/main/java/de/l3s/interweb/server/features/user/UsersResource.java @@ -1,5 +1,7 @@ package de.l3s.interweb.server.features.user; +import java.util.Optional; + import jakarta.inject.Inject; import jakarta.validation.Valid; import jakarta.validation.constraints.Email; @@ -56,7 +58,7 @@ public class UsersResource { """; @ConfigProperty(name = "interweb.admin.email") - String adminEmail; + Optional adminEmail; @ConfigProperty(name = "interweb.auto-approve.pattern") String autoApprovePattern; @@ -91,8 +93,8 @@ public Uni login(@NotEmpty @QueryParam("email") String email, @Context U private Uni findOrCreateUser(String email) { return User.findByEmail(email).onItem().ifNull().switchTo(() -> createUser(email).call(user -> { - if (!user.approved) { - return mailer.send(Mail.withText(adminEmail, NEW_USER_EMAIL_SUBJECT, NEW_USER_EMAIL_BODY.formatted(user.email))); + if (!user.approved && adminEmail.isPresent()) { + return mailer.send(Mail.withText(adminEmail.get(), NEW_USER_EMAIL_SUBJECT, NEW_USER_EMAIL_BODY.formatted(user.email))); } return Uni.createFrom().voidItem(); diff --git a/interweb-server/src/main/resources/db/migration/V1.0.0__Interweb.sql b/interweb-server/src/main/resources/db/migration/V1.0.0__Interweb.sql index 5b815e0b..b2ba4a4b 100644 --- a/interweb-server/src/main/resources/db/migration/V1.0.0__Interweb.sql +++ b/interweb-server/src/main/resources/db/migration/V1.0.0__Interweb.sql @@ -14,8 +14,8 @@ CREATE TABLE IF NOT EXISTS `chat` CREATE TABLE IF NOT EXISTS `chat_message` ( - `chat_id` UUID NOT NULL, `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, + `chat_id` UUID NOT NULL, `role` TINYINT UNSIGNED NOT NULL, `content` TEXT NOT NULL, `created` DATETIME DEFAULT NOW(), @@ -35,10 +35,10 @@ CREATE TABLE IF NOT EXISTS `user_token` ( `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, `user_id` BIGINT UNSIGNED NOT NULL, - `apikey` VARCHAR(64) NOT NULL, `name` VARCHAR(255) NOT NULL, `url` VARCHAR(512) DEFAULT NULL, `description` VARCHAR(1024) DEFAULT NULL, + `apikey` VARCHAR(64) NOT NULL, UNIQUE KEY `index_user_token_apikey` (`apikey`), CONSTRAINT `fk_user_token_user` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE );