mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-27 16:24:23 +00:00
41 lines
977 B
Elixir
41 lines
977 B
Elixir
# Pleroma: A lightweight social networking server
|
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
defmodule Pleroma.User.NotificationSetting do
|
|
use Ecto.Schema
|
|
import Ecto.Changeset
|
|
|
|
@derive Jason.Encoder
|
|
@primary_key false
|
|
|
|
embedded_schema do
|
|
field(:followers, :boolean, default: true)
|
|
field(:follows, :boolean, default: true)
|
|
field(:non_follows, :boolean, default: true)
|
|
field(:non_followers, :boolean, default: true)
|
|
field(:privacy_option, :boolean, default: false)
|
|
end
|
|
|
|
def changeset(schema, params) do
|
|
schema
|
|
|> cast(prepare_attrs(params), [
|
|
:followers,
|
|
:follows,
|
|
:non_follows,
|
|
:non_followers,
|
|
:privacy_option
|
|
])
|
|
end
|
|
|
|
defp prepare_attrs(params) do
|
|
Enum.reduce(params, %{}, fn
|
|
{k, v}, acc when is_binary(v) ->
|
|
Map.put(acc, k, String.downcase(v))
|
|
|
|
{k, v}, acc ->
|
|
Map.put(acc, k, v)
|
|
end)
|
|
end
|
|
end
|