defmodule OhMyExOhIrcd.IRC.Klines.Kline do
@moduledoc """
Persisted `user@host` ban (a.k.a. K-line). Lives in Postgres so it's
shared across every node in the cluster — i.e. effectively a GLINE
for our topology. The `mask` is an IRC glob like `*!badguy@evil.example`
or `*!*@1.2.3.*`; the matcher is the same `match_glob?/2` used by
channel `+b` masks.
"""
use Ecto.Schema
import Ecto.Changeset
schema "klines" do
field :mask, :string
field :reason, :string, default: ""
field :set_by, :string
field :expires_at, :utc_datetime
timestamps(type: :utc_datetime)
end
def changeset(record, attrs) do
record
|> cast(attrs, [:mask, :reason, :set_by, :expires_at])
|> validate_required([:mask, :set_by])
|> validate_length(:mask, min: 1, max: 200)
end
end
neiam
/oh-my-ex-oh-ircd
public · Issues · Pulls · Labels · Forks · Compare · Actions success · Badges · Packages
⭐
Log in to mark this repository.
816 B · text
History
4b6fe3b