X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;ds=inline;f=lib%2Fpleroma%2Fconfig_db.ex;h=b874e0e37a08419ea7b16042fbe866d277a64a77;hb=484ba5d062d93fd0cf4841e7743724928af5a2d9;hp=e5b7811aa51b27530ef020d5bcaa0813018b9798;hpb=049ece1ef38f1aeb656a88ed1d15bf3d4a364e01;p=akkoma
diff --git a/lib/pleroma/config_db.ex b/lib/pleroma/config_db.ex
index e5b7811aa..b874e0e37 100644
--- a/lib/pleroma/config_db.ex
+++ b/lib/pleroma/config_db.ex
@@ -1,12 +1,12 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors
+# Copyright © 2017-2021 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.ConfigDB do
use Ecto.Schema
import Ecto.Changeset
- import Ecto.Query, only: [select: 3]
+ import Ecto.Query, only: [select: 3, from: 2]
import Pleroma.Web.Gettext
alias __MODULE__
@@ -41,8 +41,18 @@ defmodule Pleroma.ConfigDB do
end)
end
+ @spec get_all_by_group(atom() | String.t()) :: [t()]
+ def get_all_by_group(group) do
+ from(c in ConfigDB, where: c.group == ^group) |> Repo.all()
+ end
+
+ @spec get_by_group_and_key(atom() | String.t(), atom() | String.t()) :: t() | nil
+ def get_by_group_and_key(group, key) do
+ get_by_params(%{group: group, key: key})
+ end
+
@spec get_by_params(map()) :: ConfigDB.t() | nil
- def get_by_params(params), do: Repo.get_by(ConfigDB, params)
+ def get_by_params(%{group: _, key: _} = params), do: Repo.get_by(ConfigDB, params)
@spec changeset(ConfigDB.t(), map()) :: Changeset.t()
def changeset(config, params \\ %{}) do