From: rinpatch Date: Fri, 13 Sep 2019 16:42:53 +0000 (+0300) Subject: Merge branch 'develop' into feature/delivery-tracking X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;ds=sidebyside;h=ba70a8cae6c0d00963dc1d9e80f915186397ad06;hp=-c;p=akkoma Merge branch 'develop' into feature/delivery-tracking --- ba70a8cae6c0d00963dc1d9e80f915186397ad06 diff --combined lib/pleroma/user.ex index 785b22643,5e10ac25f..e50227915 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@@ -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() @@@ -1221,7 -1219,7 +1221,7 @@@ 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)) @@@ -1627,15 -1625,12 +1627,24 @@@ 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 diff --combined lib/pleroma/web/router.ex index badc7e048,b0464037e..401133bf3 --- a/lib/pleroma/web/router.ex +++ b/lib/pleroma/web/router.ex @@@ -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 @@@ -225,6 -224,7 +225,7 @@@ 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) @@@ -514,7 -514,6 +515,7 @@@ scope "/", Pleroma.Web do pipe_through(:ostatus) + pipe_through(:http_signature) get("/objects/:uuid", OStatus.OStatusController, :object) get("/activities/:uuid", OStatus.OStatusController, :activity)