mirror of
https://github.com/processone/ejabberd.git
synced 2024-10-31 15:21:38 +01:00
24 lines
547 B
Elixir
24 lines
547 B
Elixir
|
defmodule Ejabberd.Config.EjabberdHook do
|
||
|
@moduledoc """
|
||
|
Module containing functions for manipulating
|
||
|
ejabberd hooks.
|
||
|
"""
|
||
|
|
||
|
defstruct hook: nil, opts: [], fun: nil
|
||
|
|
||
|
alias Ejabberd.Config.EjabberdHook
|
||
|
|
||
|
@type t :: %EjabberdHook{}
|
||
|
|
||
|
@doc """
|
||
|
Register a hook to ejabberd.
|
||
|
"""
|
||
|
@spec start(EjabberdHook.t) :: none
|
||
|
def start(%EjabberdHook{hook: hook, opts: opts, fun: fun}) do
|
||
|
host = Keyword.get(opts, :host, :global)
|
||
|
priority = Keyword.get(opts, :priority, 50)
|
||
|
|
||
|
:ejabberd_hooks.add(hook, host, fun, priority)
|
||
|
end
|
||
|
end
|