twitter api: allow setting default_scope
authorWilliam Pitcock <nenolod@dereferenced.org>
Sat, 23 Jun 2018 07:02:49 +0000 (07:02 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Wed, 27 Jun 2018 13:15:55 +0000 (13:15 +0000)
lib/pleroma/web/twitter_api/twitter_api_controller.ex

index 8f5b3c786fa0a7287ffb998f1c91b1a1c95dc02d..65e67396b2284ebf54b572ae8c9f2856e48044e0 100644 (file)
@@ -431,6 +431,19 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
         user
       end
 
+    user =
+      if default_scope = params["default_scope"] do
+        with new_info <- Map.put(user.info, "default_scope", default_scope),
+             change <- User.info_changeset(user, %{info: new_info}),
+             {:ok, user} <- User.update_and_set_cache(change) do
+          user
+        else
+          _e -> user
+        end
+      else
+        user
+      end
+
     with changeset <- User.update_changeset(user, params),
          {:ok, user} <- User.update_and_set_cache(changeset) do
       CommonAPI.update(user)