mobilizon/lib/mobilizon/users/setting.ex
Thomas Citharel 7c11807c14
Allow to join an open group
Also:

* Refactor interacting with a remote event so that you can interact with
  a remote group as well
* Add a setting for group admins to pick between an open and invite-only
  group
* Fix new groups without posts/todos/resources/events/conversations URL
  set
* Repair local groups that haven't got their
  posts/todos/resources/events/conversations URL set
* Add a scheduled job to refresh remote groups every hour
* Add a user setting to pick when to receive notifications when there's
  new members to approve (will be used when this feature is available)
* Fix pagination for members

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2020-11-06 15:19:36 +01:00

60 lines
1.6 KiB
Elixir

defmodule Mobilizon.Users.Setting do
@moduledoc """
Module to manage users settings
"""
use Ecto.Schema
import Ecto.Changeset
alias Mobilizon.Users.{NotificationPendingNotificationDelay, User}
@type t :: %__MODULE__{
timezone: String.t(),
notification_on_day: boolean,
notification_each_week: boolean,
notification_before_event: boolean,
notification_pending_participation: NotificationPendingNotificationDelay.t(),
notification_pending_membership: NotificationPendingNotificationDelay.t(),
user: User.t()
}
@required_attrs [:user_id]
@optional_attrs [
:timezone,
:notification_on_day,
:notification_each_week,
:notification_before_event,
:notification_pending_participation,
:notification_pending_membership
]
@attrs @required_attrs ++ @optional_attrs
@primary_key {:user_id, :id, autogenerate: false}
schema "user_settings" do
field(:timezone, :string)
field(:notification_on_day, :boolean)
field(:notification_each_week, :boolean)
field(:notification_before_event, :boolean)
field(:notification_pending_participation, NotificationPendingNotificationDelay,
default: :one_day
)
field(:notification_pending_membership, NotificationPendingNotificationDelay,
default: :one_day
)
belongs_to(:user, User, primary_key: true, type: :id, foreign_key: :id, define_field: false)
timestamps()
end
@doc false
def changeset(setting, attrs) do
setting
|> cast(attrs, @attrs)
|> validate_required(@required_attrs)
end
end