package com.alttd.altitudeweb.services.chat.event_publisher;

import com.alttd.altitudeweb.model.PermissionClaimDto;

import java.util.List;
import java.util.Objects;
import java.util.UUID;

public record EventUser(UUID uuid, List<String> authorities) {

    public boolean hasPermission(PermissionClaimDto permission) {
        return authorities.contains(permission.getValue());
    }

    @Override
    public boolean equals(Object o) {
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        EventUser eventUser = (EventUser) o;
        return Objects.equals(uuid, eventUser.uuid);
    }

    @Override
    public int hashCode() {
        return Objects.hash(uuid);
    }
}
