Merge branch 'develop' into feature/delivery-tracking
authorrinpatch <rinpatch@sdf.org>
Fri, 13 Sep 2019 16:42:53 +0000 (19:42 +0300)
committerrinpatch <rinpatch@sdf.org>
Fri, 13 Sep 2019 16:42:53 +0000 (19:42 +0300)
1  2 
lib/pleroma/user.ex
lib/pleroma/web/router.ex

diff --combined lib/pleroma/user.ex
index 785b22643dc0ff33ca3db32b7b7061bf3297721f,5e10ac25fdebbafea95fd58fde2380aa34305e66..e502279155d4a67e2789ce19b22acd48629cfa97
@@@ -11,7 -11,6 +11,7 @@@ defmodule Pleroma.User d
    alias Comeonin.Pbkdf2
    alias Ecto.Multi
    alias Pleroma.Activity
 +  alias Pleroma.Delivery
    alias Pleroma.Keys
    alias Pleroma.Notification
    alias Pleroma.Object
@@@ -62,7 -61,6 +62,7 @@@
      field(:last_digest_emailed_at, :naive_datetime)
      has_many(:notifications, Notification)
      has_many(:registrations, Registration)
 +    has_many(:deliveries, Delivery)
      embeds_one(:info, User.Info)
  
      timestamps()
  
    def delete_user_activities(%User{ap_id: ap_id} = user) do
      ap_id
-     |> Activity.query_by_actor()
+     |> Activity.Queries.by_actor()
      |> RepoStreamer.chunk_stream(50)
      |> Stream.each(fn activities ->
        Enum.each(activities, &delete_activity(&1))
    def is_internal_user?(%User{local: true, nickname: "internal." <> _}), do: true
    def is_internal_user?(_), do: false
  
 +  # A hack because user delete activities have a fake id for whatever reason
 +  # TODO: Get rid of this
 +  def get_delivered_users_by_object_id("pleroma:fake_object_id"), do: []
 +
 +  def get_delivered_users_by_object_id(object_id) do
 +    from(u in User,
 +      inner_join: delivery in assoc(u, :deliveries),
 +      where: delivery.object_id == ^object_id
 +    )
 +    |> Repo.all()
 +  end
++
+   def change_email(user, email) do
+     user
+     |> cast(%{email: email}, [:email])
+     |> validate_required([:email])
+     |> unique_constraint(:email)
+     |> validate_format(:email, @email_regex)
+     |> update_and_set_cache()
+   end
  end
index badc7e048fb949b6b30942b2b8d0aad716dc144a,b0464037e83ab03dadd11ab3839a96b0b4cb12db..401133bf3d750c4a55adaf3dafce2b09467bad9b
@@@ -135,7 -135,6 +135,7 @@@ defmodule Pleroma.Web.Router d
  
    pipeline :http_signature do
      plug(Pleroma.Web.Plugs.HTTPSignaturePlug)
 +    plug(Pleroma.Web.Plugs.MappedSignatureToIdentityPlug)
    end
  
    scope "/api/pleroma", Pleroma.Web.TwitterAPI do
      scope [] do
        pipe_through(:oauth_write)
  
+       post("/change_email", UtilController, :change_email)
        post("/change_password", UtilController, :change_password)
        post("/delete_account", UtilController, :delete_account)
        put("/notification_settings", UtilController, :update_notificaton_settings)
  
    scope "/", Pleroma.Web do
      pipe_through(:ostatus)
 +    pipe_through(:http_signature)
  
      get("/objects/:uuid", OStatus.OStatusController, :object)
      get("/activities/:uuid", OStatus.OStatusController, :activity)