Merge branch 'fix/hackney_max_body_param' into 'develop'
[akkoma] / lib / pleroma / user / info.ex
index 1cf46feb3df449546f04cb14c7602fa020d135db..5afa7988cee7287750e2f6e1a0169732c12cd486 100644 (file)
@@ -41,6 +41,10 @@ defmodule Pleroma.User.Info do
     field(:pinned_activities, {:array, :string}, default: [])
     field(:flavour, :string, default: nil)
 
+    field(:notification_settings, :map,
+      default: %{"remote" => true, "local" => true, "followers" => true, "follows" => true}
+    )
+
     # Found in the wild
     # ap_id -> Where is this used?
     # bio -> Where is this used?
@@ -58,6 +62,19 @@ defmodule Pleroma.User.Info do
     |> validate_required([:deactivated])
   end
 
+  def update_notification_settings(info, settings) do
+    notification_settings =
+      info.notification_settings
+      |> Map.merge(settings)
+      |> Map.take(["remote", "local", "followers", "follows"])
+
+    params = %{notification_settings: notification_settings}
+
+    info
+    |> cast(params, [:notification_settings])
+    |> validate_required([:notification_settings])
+  end
+
   def add_to_note_count(info, number) do
     set_note_count(info, info.note_count + number)
   end