package pl.polskalokalnie.message;

import java.time.Instant;

public record MessageResponse(
        Long id,
        Long senderId,
        Long recipientId,
        String content,
        Instant createdAt,
        boolean mine
) {
    public static MessageResponse from(Message message, Long currentUserId) {
        return new MessageResponse(
                message.getId(),
                message.getSenderId(),
                message.getRecipientId(),
                message.getContent(),
                message.getCreatedAt(),
                message.getSenderId().equals(currentUserId)
        );
    }
}
