Files
nahodka-back/src/main/java/com/krylov/refound/entity/Message.java
SlimusMinus e02f8cdb6b Add anti-fraud verification questions and scam warnings
- posts can carry up to 3 verification questions (post_verification_questions,
  changelog 026); to contact the author one answers them first
- POST /api/v1/posts/{id}/claim creates a PENDING chat with the answers as a
  CLAIM message; the claimant cannot write or see the phone until the author
  approves via POST /api/v1/chats/{chatId}/verification
- plain first message to such a post and phone reveal return 403
  VERIFICATION_REQUIRED; GET /api/v1/chats/{chatId} exposes the status
- FraudSignals flags prepayment, card data (Luhn) and SMS-code requests in
  messages (MessageDto.fraudSignal); ChatDto.otherUserCreatedAt for new accounts
- claim limits: 5 per day per account, 2 per post per 30 days, 10/h per IP
- docs/anti-fraud.md, tests

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-11-11 01:04:31 +03:00

56 lines
1.5 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.krylov.refound.entity;
import com.krylov.refound.enums.MessageKind;
import com.krylov.refound.util.TimeZoneContext;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.PrePersist;
import jakarta.persistence.Table;
import java.time.LocalDateTime;
import lombok.Getter;
import lombok.Setter;
@Entity
@Table(name = "messages")
@Getter
@Setter
public class Message {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "chat_id", nullable = false)
private Long chatId;
@Column(name = "sender_id", nullable = false)
private Long senderId;
@Column(nullable = false, columnDefinition = "TEXT")
private String content;
@Enumerated(EnumType.STRING)
@Column(nullable = false, length = 16)
private MessageKind kind = MessageKind.TEXT;
// CLAIM — JSON вопросов и ответов, VERIFICATION — статус решения; у TEXT null
@Column(columnDefinition = "TEXT")
private String payload;
@Column(name = "is_read", nullable = false)
private boolean isRead = false;
@Column(name = "created_at", nullable = false)
private LocalDateTime createdAt;
@PrePersist
protected void onCreate() {
createdAt = TimeZoneContext.now();
}
}