Merge remote-tracking branch 'origin/develop' into pleroma-conversations
authorlain <lain@soykaf.club>
Thu, 8 Aug 2019 14:04:20 +0000 (16:04 +0200)
committerlain <lain@soykaf.club>
Thu, 8 Aug 2019 14:04:20 +0000 (16:04 +0200)
1  2 
lib/pleroma/user.ex
lib/pleroma/web/common_api/utils.ex
lib/pleroma/web/router.ex
test/web/common_api/common_api_utils_test.exs

Simple merge
index 425b6d656a10a455d3500d854845456c69db0a27,22c44a0a3927b9d0668c476db67cab86578136d0..61b96aba999d3b2b5aa979ea4ba9c62c078c3e77
@@@ -60,26 -74,21 +75,33 @@@ defmodule Pleroma.Web.CommonAPI.Utils d
    def attachments_from_ids_descs(ids, descs_str) do
      {_, descs} = Jason.decode(descs_str)
  
-     Enum.map(ids || [], fn media_id ->
-       Map.put(Repo.get(Object, media_id).data, "name", descs[media_id])
+     Enum.map(ids, fn media_id ->
+       case Repo.get(Object, media_id) do
+         %Object{data: data} = _ ->
+           Map.put(data, "name", descs[media_id])
+         _ ->
+           nil
+       end
      end)
+     |> Enum.filter(& &1)
    end
  
 -  @spec get_to_and_cc(User.t(), list(String.t()), Activity.t() | nil, String.t()) ::
 +  @spec get_to_and_cc(
 +          User.t(),
 +          list(String.t()),
 +          Activity.t() | nil,
 +          String.t(),
 +          Participation.t() | nil
 +        ) ::
            {list(String.t()), list(String.t())}
 -  def get_to_and_cc(user, mentioned_users, inReplyTo, "public") do
 +
 +  def get_to_and_cc(_, _, _, _, %Participation{} = participation) do
 +    participation = Repo.preload(participation, :recipients)
 +    {Enum.map(participation.recipients, & &1.ap_id), []}
 +  end
 +
 +  def get_to_and_cc(user, mentioned_users, inReplyTo, "public", _) do
      to = [Pleroma.Constants.as_public() | mentioned_users]
      cc = [user.follower_address]
  
Simple merge
index 7510c8def3602c3baf24096e79a259e5f799fd8b,5989d7d29e795d14609705901f7424c5285dea03..c281dd1f1c2f0e785de02eb7adb39368293ec477
@@@ -305,8 -305,7 +305,7 @@@ defmodule Pleroma.Web.CommonAPI.UtilsTe
        mentioned_user = insert(:user)
        mentions = [mentioned_user.ap_id]
  
 -      {to, cc} = Utils.get_to_and_cc(user, mentions, nil, "private")
 +      {to, cc} = Utils.get_to_and_cc(user, mentions, nil, "private", nil)
        assert length(to) == 2
        assert length(cc) == 0