package io.github.shirainbown.sharelink.model;

import java.time.Instant;
import lombok.Data;
import lombok.EqualsAndHashCode;
import run.halo.app.extension.AbstractExtension;
import run.halo.app.extension.GVK;

/**
 * A single visit to a protected link. The metadata name is a random UUID;
 * {@code spec.linkSlug} is indexed for per-link queries.
 */
@GVK(group = "sharelink.halo.run", version = "v1alpha1", kind = "LinkVisitRecord",
    plural = "linkvisitrecords", singular = "linkvisitrecord")
@Data
@EqualsAndHashCode(callSuper = true)
public class LinkVisitRecord extends AbstractExtension {

    private Spec spec;

    @Data
    public static class Spec {

        private String linkSlug;

        /**
         * Verified email of the visitor; blank for links without email verification.
         */
        private String email;

        private String ip;

        private String userAgent;

        private Instant visitedAt;
    }
}
