NCBACK-33 add email send
Test Workflow / test (push) Successful in 2s

This commit is contained in:
vladp
2026-01-19 19:26:59 +07:00
parent 4704f780e5
commit 4a8e561258
6 changed files with 62 additions and 258 deletions
@@ -36,8 +36,8 @@ public class User {
@Column(name = "email", nullable = false, length = 1024, unique = true)
private String email;
@Column(name = "email_verified", nullable = false)
private Boolean emailVerified = false;
@Column(name = "email_verified")
private boolean emailVerified = false;
@Column(name = "company")
private String company;
@@ -82,11 +82,6 @@ public class User {
@ToString.Exclude
private List<UserContent> userContents = new ArrayList<>();
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true)
@JsonIgnore
@ToString.Exclude
private List<UserAction> userActions = new ArrayList<>();
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true)
@JsonIgnore
@ToString.Exclude
@@ -1,44 +0,0 @@
package ru.soune.nocopy.entity.user;
import jakarta.persistence.*;
import lombok.*;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import java.time.LocalDateTime;
@Entity
@Table(name = "user_actions")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@ToString
@EntityListeners(AuditingEntityListener.class)
public class UserAction {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long actionId;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id", nullable = false)
@ToString.Exclude
private User user;
@Column(name = "action", nullable = false, length = 100)
private String action;
@Column(name = "details", columnDefinition = "TEXT")
private String details;
@Column(name = "ip_address", length = 45)
private String ipAddress;
@Column(name = "user_agent", columnDefinition = "TEXT")
private String userAgent;
@CreatedDate
@Column(name = "created_at", nullable = false, updatable = false)
private LocalDateTime createdAt;
}
@@ -4,6 +4,7 @@ import jakarta.mail.MessagingException;
import jakarta.mail.internet.MimeMessage;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.ClassPathResource;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
@@ -35,16 +36,17 @@ public class EmailService {
helper.setFrom("NO COPY <noreply@nocopy.com>");
helper.setTo(user.getEmail());
helper.setSubject("NO COPY - Подтверждение email адреса");
helper.setSubject("NO COPY - Подтверждение email");
String htmlContent = loadAndProcessTemplate(user.getFullName(), code);
helper.setText(htmlContent, true);
mailSender.send(message);
} catch (MessagingException | IOException e) {
log.error("Fail send email: " + e.getMessage());
log.info("Email sent to: {}", user.getEmail());
} catch (Exception e) {
log.error("Failed to send email: {}", e.getMessage());
}
}
+7 -20
View File
@@ -1,15 +1,13 @@
spring:
mail:
host: smtp.gmail.com
port: 587
username: vlad.popovtsev@gmail.com
password: aylgtjcxdtjvohrk
host: postfix
port: 25
username: noreply@nocopy.com
password: nocopy!nocopy!
properties:
mail:
smtp:
auth: true
starttls:
enable: true
mail.smtp.auth: false
mail.smtp.starttls.enable: false
mail.debug: true
datasource:
url: jdbc:postgresql://${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}
@@ -36,8 +34,6 @@ spring:
file:
storage:
base-path: ${FILE_STORAGE_PATH:/data/uploads}
# chunk-size: ${FILE_CHUNK_SIZE:5242880} # 5MB
# chunk-size: ${FILE_CHUNK_SIZE:1048576} # 1MB
chunk-size: ${FILE_CHUNK_SIZE:1000000} # 1MB
max-file-size: ${MAX_FILE_SIZE:10737418240} # 10GB
max-retry-attempts: ${MAX_RETRY_ATTEMPTS:3}
@@ -69,12 +65,3 @@ yandex:
api-key: ${YANDEX_API_KEY:AQVNyaVaUmgUb1GMCtf5zSEqFxy0woXrcMOOB43q}
folder-id: ${YANDEX_FOLDER_ID:b1gokpdbm6qfpsou8pcd}
search-url: ${YANDEX_SEARCH_URL:https://searchapi.api.cloud.yandex.net/v2/image/search_by_image}
app:
email:
verification:
expiration-hours: ${EMAIL_VERIFICATION_EXPIRATION:24}
base-url: ${EMAIL_BASE_URL:http://localhost:80}
from-email: ${EMAIL_FROM:noreply@yourdomain.com}
templates:
verification: verification-email.html